From 4710aabea302c18efff5ad80c714199b2ccace92 Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Wed, 30 Apr 2025 20:34:57 +0100 Subject: [PATCH] feat(workflow): require tag input for manual release creation --- .github/workflows/release.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fcccd6379..d1b00f747 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,11 @@ on: tags: - 'v*.*.*' # Trigger on version tags like v1.0.0, v1.2.3, etc. workflow_dispatch: + inputs: + tag_name: # Added input for manual trigger + description: 'Tag to create the release for (e.g., v1.2.3)' + required: true + type: string permissions: contents: write # Needed to create releases @@ -14,10 +19,19 @@ jobs: name: Create GitHub Release runs-on: ubuntu-latest steps: + - name: Determine Ref to Checkout + id: determine_ref + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + echo "ref=${{ github.event.inputs.tag_name }}" >> "$GITHUB_OUTPUT" + else + echo "ref=${{ github.ref }}" >> "$GITHUB_OUTPUT" + fi + - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ github.ref }} # Explicitly checkout the triggering tag/ref + ref: ${{ steps.determine_ref.outputs.ref }} # Use determined ref (tag or branch) - name: Set up Node.js uses: actions/setup-node@v4 @@ -51,7 +65,7 @@ jobs: platforms: linux/amd64,linux/arm64 # Add other platforms if needed push: true tags: | - rcourtman/pulse:${{ github.ref_name }} + rcourtman/pulse:${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name || github.ref_name }} rcourtman/pulse:latest # --- End Docker Steps --- @@ -60,6 +74,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Provided by GitHub Actions with: + # Use input tag for dispatch, otherwise default (inferred from github.ref) + tag_name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name || '' }} draft: true # Create the release as a draft initially # Optionally, you can generate release notes automatically: # generate_release_notes: true