jdaugherty commented on code in PR #22:
URL:
https://github.com/apache/grails-github-actions/pull/22#discussion_r2147369055
##########
post-release/action.yml:
##########
@@ -6,7 +6,155 @@ inputs:
required: true
default: ${{ github.token }}
runs:
- using: 'docker'
- image: 'Dockerfile'
- args:
- - ${{ inputs.token }}
\ No newline at end of file
+ using: 'composite'
+ steps:
+ - name: 'Post Release - Revert Snapshot Version'
+ shell: bash
+ env:
+ GITHUB_TOKEN: ${{ inputs.token }}
+ run: |
+ #!/bin/bash
+
+ # The following permissions are required to successfully execute this
script:
+ # permissions:
+ # issues: write # to close milestone (script will silently fail if
not set)
+ # contents: write # to commit
+ #
+ # This script expects the github action to have checked out the
repository with fetch-depth: 0
+
+ set_value_or_error() {
+ local value="$1"
+ local defaultValue="$2"
+ local variableName="$3"
+ local validValues="${4:-}" # optional argument (if empty, skip
validation)
+
+ if [[ -z "$value" && -z "$defaultValue" ]]; then
+ echo "ERROR: A value for $variableName is required." >&2
+ exit 1
+ fi
+
+ if [[ -n "$value" ]]; then
+ decidedValue="$value"
+ else
+ echo "${variableName}: Using default value: ${defaultValue}"
+ decidedValue="$defaultValue"
+ fi
+
+ if [[ -n "$validValues" ]]; then
+ local match=false
+ local v
+ for v in $validValues; do
+ if [[ "$decidedValue" == "$v" ]]; then
+ match=true
+ break
+ fi
+ done
+
+ if ! $match; then
+ echo "ERROR: Invalid value for '$variableName':
'$decidedValue'." >&2
+ echo " Must be one of: $validValues" >&2
+ return 1
+ fi
+ fi
+
+ eval "export $variableName=\"\$decidedValue\""
+ }
+
+ set -e
+
+ set_value_or_error "${GIT_USER_NAME}" "${GITHUB_ACTOR}" "GIT_USER_NAME"
+ set_value_or_error "${GITHUB_WORKSPACE}" "." "GIT_SAFE_DIR"
+ set_value_or_error "${GITHUB_REPOSITORY}" "" "GITHUB_REPOSITORY"
+ set_value_or_error "${RELEASE_VERSION}" "${GITHUB_REF:11}"
"RELEASE_VERSION"
+
+ if [[ ! "${RELEASE_VERSION}" =~ ^v?[^.]+\.[^.]+\.[^.]+$ ]]; then
Review Comment:
I think we should continue supporting semver only. This logic already has
enough nuance that I don't want to add to it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]