Release #97
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright 2026 hrzlgnm | |
| # SPDX-License-Identifier: MIT-0 | |
| name: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: Version to bump | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| dry-run: | |
| description: dry-run | |
| required: true | |
| type: boolean | |
| default: false | |
| permissions: | |
| actions: write # Needed to trigger other workflows and workflow dispatch | |
| contents: write # Needed to update version and create tags | |
| id-token: write # Needed for SBOM association with build | |
| attestations: write # Needed to create attestations | |
| jobs: | |
| release: | |
| name: 📝 Draft a new release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.semantic-version }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_ADMIN_TOKEN }} | |
| steps: | |
| - name: 🔄 Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: 🔍 Get default branch protection ruleset | |
| id: ruleset | |
| shell: bash | |
| run: | | |
| RULESET="repos/${{ github.repository }}/rulesets/${{ secrets.RULESET_ID }}" | |
| echo "result=${RULESET}" >> "$GITHUB_OUTPUT" | |
| - name: 🦀🚀 | |
| uses: ./.github/actions/setup-rust-cache | |
| with: | |
| save-cache: false | |
| - name: 🛠️🚀 cargo-edit | |
| uses: baptiste0928/cargo-install@f204293d9709061b7bc1756fec3ec4e2cd57dec0 # v3 | |
| with: | |
| crate: cargo-edit | |
| version: 0.13.13 | |
| locked: true | |
| - name: 📦 Bump version in Cargo.toml | |
| id: version | |
| env: | |
| DRY_RUN: ${{ inputs.dry-run }} | |
| VERSION_BUMP: ${{ inputs.version }} | |
| run: | | |
| CURRENT_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') | |
| if [ "$DRY_RUN" = "true" ]; then | |
| # Parse version and calculate next version without semver tool | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" | |
| case "$VERSION_BUMP" in | |
| "patch") | |
| NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" | |
| ;; | |
| "minor") | |
| NEW_VERSION="$MAJOR.$((MINOR + 1)).0" | |
| ;; | |
| "major") | |
| NEW_VERSION="$((MAJOR + 1)).0.0" | |
| ;; | |
| *) | |
| echo "Error: Invalid version bump type '$VERSION_BUMP'. Must be patch, minor, or major." | |
| exit 1 | |
| ;; | |
| esac | |
| echo "semantic-version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Dry run: would bump from $CURRENT_VERSION to $NEW_VERSION" | |
| else | |
| cargo set-version --bump "$VERSION_BUMP" | |
| NEW_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') | |
| echo "semantic-version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Bumped version from $CURRENT_VERSION to $NEW_VERSION" | |
| fi | |
| - name: ⚙️ Set up SSH signing key | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.SSH_SIGNING_KEY }}" > ~/.ssh/id_ed25519_signing | |
| chmod 600 ~/.ssh/id_ed25519_signing | |
| git config --global gpg.format ssh | |
| git config --global user.signingKey ~/.ssh/id_ed25519_signing | |
| git config --global user.name "hrzlgnm" | |
| git config --global user.email "hrzlgnm@users.noreply.github.com" | |
| - name: ⏳ Temporary disable ruleset enforcement | |
| if: ${{ !inputs.dry-run }} | |
| run: | | |
| RULESET="${{ steps.ruleset.outputs.result }}" | |
| gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "${RULESET}" | jq '.enforcement = "disabled"' | \ | |
| gh api \ | |
| --method PUT \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "${RULESET}" \ | |
| --input - | |
| - name: 🔧 Install git-cliff | |
| uses: baptiste0928/cargo-install@f204293d9709061b7bc1756fec3ec4e2cd57dec0 # v3 | |
| with: | |
| crate: git-cliff | |
| version: 2.13.1 | |
| locked: true | |
| - name: 📝 Update CHANGELOG.md | |
| if: ${{ !inputs.dry-run }} | |
| run: | | |
| git-cliff --tag "v${{ steps.version.outputs.semantic-version }}" --output CHANGELOG.md | |
| - name: 💾🏷️⬆️ Commit, tag and push | |
| if: ${{ !inputs.dry-run }} | |
| run: | | |
| git add -A | |
| git commit -S -m "Bump version to ${{ steps.version.outputs.semantic-version }}" | |
| git push | |
| git tag -s -a v${{ steps.version.outputs.semantic-version }} -m "mDNS TUI Browser v${{ steps.version.outputs.semantic-version }}" | |
| git push --tags | |
| - name: 👮 Re-enable enforcement of rules | |
| if: ${{ always() && !inputs.dry-run }} | |
| run: | | |
| RULESET="${{ steps.ruleset.outputs.result }}" | |
| gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "${RULESET}" | jq '.enforcement = "active"' | \ | |
| gh api \ | |
| --method PUT \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "${RULESET}" \ | |
| --input - | |
| - name: 🧹 Cleanup SSH signing key | |
| if: always() | |
| run: | | |
| rm -f ~/.ssh/id_ed25519_signing | |
| - name: 🧹 Delete pre-existing draft releases | |
| if: ${{ !inputs.dry-run && steps.version.outputs.semantic-version != '' }} | |
| uses: hugo19941994/delete-draft-releases@v3.0.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: 🗒️ Generate release notes with release-drafter | |
| if: ${{ !inputs.dry-run && steps.version.outputs.semantic-version != '' }} | |
| uses: release-drafter/release-drafter@34d80673e067bdc0c24568d3af899c216adcfaa9 # v7.7.0 | |
| with: | |
| tag: v${{ steps.version.outputs.semantic-version }} | |
| name: mDNS TUI Browser v${{ steps.version.outputs.semantic-version }} | |
| latest: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| source-checksums: | |
| if: ${{ !inputs.dry-run && needs.release.outputs.version != '' }} | |
| needs: release | |
| uses: ./.github/workflows/source-checksums-reusable.yml | |
| with: | |
| tagName: v${{ needs.release.outputs.version }} | |
| build-and-publish: | |
| if: ${{ !inputs.dry-run && needs.release.outputs.version != '' }} | |
| needs: release | |
| uses: ./.github/workflows/build-reusable.yml | |
| with: | |
| tagName: v${{ needs.release.outputs.version }} |