diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dcface6..64a53d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,11 @@ on: tags: - "v*" workflow_dispatch: + inputs: + tag: + description: "Existing tag to publish (e.g. v0.2.0). Leave empty for a non-release build from this ref." + required: false + type: string permissions: contents: write @@ -17,6 +22,7 @@ jobs: uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: fetch-depth: 0 + ref: ${{ inputs.tag || github.ref }} - name: Setup Node uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 @@ -65,11 +71,18 @@ jobs: - name: Resolve version id: version + env: + INPUT_TAG: ${{ inputs.tag }} run: | if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + echo "release_tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" + elif [[ -n "${INPUT_TAG}" ]]; then + echo "version=${INPUT_TAG#v}" >> "$GITHUB_OUTPUT" + echo "release_tag=${INPUT_TAG}" >> "$GITHUB_OUTPUT" else echo "version=0.0.0-dev.${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" + echo "release_tag=" >> "$GITHUB_OUTPUT" fi - name: Build binaries @@ -99,13 +112,14 @@ jobs: retention-days: 14 - name: Upload release assets - if: startsWith(github.ref, 'refs/tags/v') + if: steps.version.outputs.release_tag != '' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE_TAG: ${{ steps.version.outputs.release_tag }} run: | set -euo pipefail - gh release create "${GITHUB_REF_NAME}" \ - --title "${GITHUB_REF_NAME}" \ + gh release create "${RELEASE_TAG}" \ + --title "${RELEASE_TAG}" \ --generate-notes \ dist/binaries/*.tar.gz \ dist/binaries/*.zip \