-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from Cysharp/feature/validate_tag
feat: add validate-tag action to check release tag is reverting to old or not
- Loading branch information
Showing
10 changed files
with
169 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Test validate-tag | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: "tag: GitHub Tag to release. ex) 1.1.0" | ||
required: true | ||
default: "" | ||
pull_request: | ||
branches: ["main"] | ||
push: | ||
branches: ["main"] | ||
|
||
jobs: | ||
validate: | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
uses: ./.github/workflows/validate-tag.yaml | ||
with: | ||
tag: "1.10.0" | ||
fail-on-invalid: true | ||
secrets: inherit | ||
|
||
validate2: | ||
if: ${{ github.actor != 'dependabot[bot]' }} | ||
uses: ./.github/workflows/validate-tag.yaml | ||
with: | ||
tag: "1.0.0" | ||
fail-on-invalid: false | ||
secrets: inherit | ||
|
||
test: | ||
needs: [validate, validate2] | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 3 | ||
steps: | ||
- name: Test | ||
run: | | ||
echo "DEBUG: validate: ${{ needs.validate.outputs.validated }} (${{ needs.validate.outputs.tag }})" | ||
echo "DEBUG: validate2: ${{ needs.validate2.outputs.validated }} (${{ needs.validate2.outputs.tag }})" | ||
echo -n "FACT: tag is newer then current release. " | ||
if [[ "${{ needs.validate.outputs.validated }}" == "true" ]]; then echo "[O PASS]"; else echo "[X FAIL]" && exit 1; fi | ||
echo -n "FACT: tag is old then current release. " | ||
if [[ "${{ needs.validate2.outputs.validated }}" == "false" ]]; then echo "[O PASS]"; else echo "[X FAIL]" && exit 1; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: (R) Validate Tag | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
fail-on-invalid: | ||
description: "fail-on-invalid: allow old tag or not" | ||
required: false | ||
default: false | ||
type: boolean | ||
tag: | ||
description: "tag: tag to validate" | ||
required: true | ||
type: string | ||
outputs: | ||
tag: | ||
description: input tag | ||
value: ${{ jobs.validate.outputs.tag }} | ||
validated: | ||
description: result of the validation is validated or not | ||
value: ${{ jobs.validate.outputs.validated }} | ||
workflow_dispatch: | ||
inputs: | ||
fail-on-invalid: | ||
description: "fail-on-invalid: allow old tag or not" | ||
required: false | ||
default: false | ||
type: boolean | ||
tag: | ||
description: "tag: tag to validate" | ||
required: true | ||
type: string | ||
|
||
permissions: | ||
contents: read | ||
actions: read | ||
|
||
jobs: | ||
validate: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
outputs: | ||
tag: ${{ steps.validate.outputs.tag }} | ||
validated: ${{ steps.validate.outputs.validated }} | ||
steps: | ||
# Only check released tag, allow override draft and pre-release. Old to new sort by version number. | ||
- name: Validate tag is not reverting | ||
shell: bash | ||
id: validate | ||
run: | | ||
echo "tag=${{ inputs.tag }}" | tee -a "$GITHUB_OUTPUT" | ||
release_latest=$(gh release list --exclude-drafts --exclude-pre-releases --json tagName,isLatest | jq -c -r ".[] | select(.isLatest == true) | .tagName") | ||
sorted_latest=$(echo -e "${release_latest}\n${{ inputs.tag }}" | sort -V | tail -n 1) | ||
if [[ "$release_latest" == "" ]]; then | ||
echo "There is not release tag." | ||
echo "validated=true" | tee -a "$GITHUB_OUTPUT" | ||
elif [[ "$sorted_latest" == "$release_latest" ]]; then | ||
echo "Tag is reverting to old version. Please bump the version. tag: ${{ inputs.tag }}, latest: $release_latest" | ||
echo "validated=false" | tee -a "$GITHUB_OUTPUT" | ||
if [[ "${{ inputs.fail-on-invalid }}" == "true" ]]; then | ||
exit 1 | ||
fi | ||
else | ||
echo "Great, tag is latest. tag: ${{ inputs.tag }}, latest: $release_latest" | ||
echo "validated=true" | tee -a "$GITHUB_OUTPUT" | ||
fi | ||
env: | ||
GH_REPO: ${{ github.repository }} | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<VersionPrefix>1.0.188</VersionPrefix> | ||
<VersionPrefix>1.0.194</VersionPrefix> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.188 | ||
1.0.194 |