|
| 1 | +# This workflow creates and pushes a release tag using the push-release-tag.sh script. |
| 2 | +# It can be triggered manually and will prompt for confirmation before creating the tag. |
| 3 | + |
| 4 | +name: Create Release Tag |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + dry_run: |
| 10 | + description: "Run in dry-run mode (show what would be done without actually creating/pushing the tag)" |
| 11 | + required: false |
| 12 | + type: boolean |
| 13 | + default: true |
| 14 | + confirm_release: |
| 15 | + description: "Type 'YES' to confirm you want to create and push the release tag" |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + |
| 19 | +jobs: |
| 20 | + check-branch: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + environment: production |
| 23 | + steps: |
| 24 | + - name: Check if running on release branch |
| 25 | + run: | |
| 26 | + if [ "${{ github.ref }}" != "refs/heads/release" ]; then |
| 27 | + echo "Error: This workflow can only be run from the 'release' branch." |
| 28 | + echo "Current branch: ${{ github.ref }}" |
| 29 | + echo "Please switch to the 'release' branch and try again." |
| 30 | + exit 1 |
| 31 | + fi |
| 32 | + echo "Running on release branch - proceeding with workflow." |
| 33 | +
|
| 34 | + create-release-tag: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + needs: check-branch |
| 37 | + environment: production |
| 38 | + if: github.ref == 'refs/heads/release' |
| 39 | + |
| 40 | + permissions: |
| 41 | + contents: write # Required to create and push tags |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Validate confirmation |
| 45 | + if: github.event.inputs.confirm_release != 'YES' && github.event.inputs.dry_run != 'true' |
| 46 | + run: | |
| 47 | + echo "Error: You must type 'YES' in the confirm_release input to proceed with creating a release tag." |
| 48 | + echo "Received: '${{ github.event.inputs.confirm_release }}'" |
| 49 | + exit 1 |
| 50 | +
|
| 51 | + - uses: actions/checkout@v4 |
| 52 | + with: |
| 53 | + fetch-depth: 0 # Fetch all history and tags |
| 54 | + |
| 55 | + - name: Make scripts executable |
| 56 | + run: | |
| 57 | + chmod +x scripts/push-release-tag.sh |
| 58 | + chmod +x scripts/get_version.sh |
| 59 | +
|
| 60 | + - name: Configure Git |
| 61 | + run: | |
| 62 | + git config --global user.name "github-actions[bot]" |
| 63 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 64 | +
|
| 65 | + - name: Run push-release-tag script (dry-run) |
| 66 | + if: github.event.inputs.dry_run == 'true' |
| 67 | + run: | |
| 68 | + echo "Running in dry-run mode..." |
| 69 | + make push-release-tag DRY_RUN=--dry-run |
| 70 | +
|
| 71 | + - name: Run push-release-tag script |
| 72 | + if: github.event.inputs.dry_run != 'true' |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + run: | |
| 76 | + echo "Creating and pushing release tag..." |
| 77 | + # Override the interactive confirmation since we already confirmed via workflow input |
| 78 | + echo "YES" | make push-release-tag |
0 commit comments