Skip to content

Commit

Permalink
Check tag exists on main on release
Browse files Browse the repository at this point in the history
This mitigates the risk of a tag being generated and pushed off of a
branch.

Signed-off-by: Hayden Blauzvern <[email protected]>
  • Loading branch information
haydentherapper committed Mar 6, 2024
1 parent f40ffbf commit 7e85003
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion .github/workflows/java-build-for-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,34 @@ on:
# if you change this pattern, make sure jobs.strip-tag still works
- 'release/java/v[0-9]+.[0-9]+.[0-9]+'
jobs:
check-tag-main:
runs-on: ubuntu-latest
steps:
- name: Checkout all branches
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0

- name: Verify tag on branch
# Check main is one of the branches where the tagged commit exists
run: |
branches=$(git branch --contains ${{ github.ref }}) --format "%(refname:short)"
found=false
for b in $raw; do
if [ "$x" = "main" ]; then
found=true
fi
done
if [ "$found" = false ]; then
exit 1
fi
ci:
needs: [check-tag-main]
uses: ./.github/workflows/java-build.yml

strip-tag:
needs: [check-tag-main]
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
Expand All @@ -21,7 +45,7 @@ jobs:
build:
runs-on: ubuntu-latest
needs: [ci, strip-tag]
needs: [ci, strip-tag, check-tag-main]
outputs:
hashes: ${{ steps.hash.outputs.hashes }}
steps:
Expand Down

0 comments on commit 7e85003

Please sign in to comment.