|
| 1 | +name: Update Release Tags |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - 'v*.*.*' |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + update-version-tags: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Determine version tag numbers |
| 18 | + id: extract_version_tags |
| 19 | + run: | |
| 20 | + echo "Determining major and minor tag numbers for:" |
| 21 | + echo "${{ github.sha }} ${{ github.ref }} " |
| 22 | + tag="${GITHUB_REF#refs/tags/v}" |
| 23 | + minor_version="${tag%.*}" |
| 24 | + major_version="${tag%%.*}" |
| 25 | + echo "minor_version=v$minor_version" >> "$GITHUB_OUTPUT" |
| 26 | + echo "major_version=v$major_version" >> "$GITHUB_OUTPUT" |
| 27 | +
|
| 28 | + - name: Create tags locally |
| 29 | + run: | |
| 30 | + git tag "${{ steps.extract_version_tags.outputs.minor_version }}" -f |
| 31 | + echo "Created minor release tag: ${{ steps.extract_version_tags.outputs.minor_version }}" |
| 32 | + git tag "${{ steps.extract_version_tags.outputs.major_version }}" -f |
| 33 | + echo "Created major release tag: ${{ steps.extract_version_tags.outputs.major_version }}" |
| 34 | +
|
| 35 | + - name: Check tag hashes match original sha |
| 36 | + run: | |
| 37 | + minor_sha=$(git rev-parse "${{ steps.extract_version_tags.outputs.minor_version }}") |
| 38 | + major_sha=$(git rev-parse "${{ steps.extract_version_tags.outputs.major_version }}") |
| 39 | + if [ "$minor_sha" != "${{ github.sha }}" ]; then |
| 40 | + echo "Minor tag does not match original sha" |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | + if [ "$major_sha" != "${{ github.sha }}" ]; then |
| 44 | + echo "Minor tag does not match original sha" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + echo "Tag hashes verified." |
| 48 | +
|
| 49 | + - name: Force push tags to remote |
| 50 | + env: |
| 51 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + run: | |
| 53 | + git push origin "${{ steps.extract_version_tags.outputs.minor_version }}" -f |
| 54 | + git push origin "${{ steps.extract_version_tags.outputs.major_version }}" -f |
| 55 | + echo "Pushed tags to origin" |
0 commit comments