commit ab52bc5c2d3e4dce24d48bd4483fb1ea89241448 from: ale date: Fri Jul 24 00:49:42 2026 UTC Auto-detect the most recent tag when dispatched with no input Makes the workflow_dispatch tag input optional: when left empty, it resolves to the most recently created tag (git tag --sort=-creatordate) instead of requiring it to be typed in every time. Real 'push: tags' events and an explicit input still take priority over auto-detection. commit - c82048ab25093eae04341740a73b33b8123bc13d commit + ab52bc5c2d3e4dce24d48bd4483fb1ea89241448 blob - 9b9c7b6d6bc3179c52bf9945412d1e1976b4f08a blob + 4c51a9a52f6aab651e5facd0e4eb52b871e24e67 --- .github/workflows/release.yml +++ .github/workflows/release.yml @@ -5,14 +5,14 @@ on: tags: - "v*" # Manual fallback: mirrored pushes (e.g. Forgejo -> GitHub) don't always - # emit the `push` event Actions listens for. Always run this from the - # "main" branch (so this trigger definition is present) and provide the - # tag to release as an input; it does not need to pre-date the tag itself. + # emit the `push` event Actions listens for. Run this from the "main" + # branch (so this trigger definition is present); leave the tag input + # empty to release the most recently created tag. workflow_dispatch: inputs: tag: - description: "Tag to release (e.g. v0.1.0)" - required: true + description: "Tag to release (defaults to the most recent tag)" + required: false permissions: contents: write @@ -23,13 +23,28 @@ jobs: runs-on: ubuntu-latest env: PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} - RELEASE_TAG: ${{ inputs.tag || github.ref_name }} steps: - name: Checkout uses: actions/checkout@v4 with: - ref: ${{ env.RELEASE_TAG }} + fetch-depth: 0 + - name: Resolve release tag + id: resolve + run: | + if [ -n "${{ inputs.tag }}" ]; then + tag="${{ inputs.tag }}" + elif [ "${{ github.ref_type }}" = "tag" ]; then + tag="${{ github.ref_name }}" + else + tag="$(git tag --sort=-creatordate | head -n1)" + fi + echo "Releasing $tag" + echo "tag=$tag" >> "$GITHUB_OUTPUT" + + - name: Checkout release tag + run: git checkout "${{ steps.resolve.outputs.tag }}" + - name: Set up JDK 21 uses: actions/setup-java@v4 with: @@ -48,8 +63,8 @@ jobs: - name: Create GitHub release uses: softprops/action-gh-release@v2 with: - tag_name: ${{ env.RELEASE_TAG }} - name: ${{ env.RELEASE_TAG }} + tag_name: ${{ steps.resolve.outputs.tag }} + name: ${{ steps.resolve.outputs.tag }} generate_release_notes: true files: build/distributions/*.zip