Publish release #50
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
| name: Publish release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: >- | |
| Version to release (e.g. v1.2.3). | |
| Uses latest version from changelog if unset. | |
| default: '' | |
| type: string | |
| ref: | |
| description: Git ref to release from. | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ inputs.ref }} | |
| token: ${{ secrets.PAT }} | |
| - uses: jdx/mise-action@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set version (changie) | |
| if: inputs.version == '' | |
| run: | | |
| CHANGIE_VERSION=$(changie latest) | |
| echo "VERSION=${CHANGIE_VERSION#v}" >> "$GITHUB_ENV" | |
| - name: Set version (input) | |
| if: inputs.version != '' | |
| run: | |
| echo "VERSION=${INPUT_VERSION#v}" >> "$GITHUB_ENV" | |
| env: | |
| INPUT_VERSION: ${{ inputs.version }} | |
| - name: Verify version | |
| run: | | |
| if [[ -z "$VERSION" ]]; then | |
| echo "No version set" | |
| exit 1 | |
| fi | |
| - name: Extract changelog | |
| run: | | |
| tail -n+2 .changes/v${{ env.VERSION }}.md \ | |
| | tee ${{ github.workspace }}-CHANGELOG.txt | |
| - name: Tag a release | |
| run: | | |
| git tag "$TAG" | |
| git push origin "$TAG" | |
| env: | |
| TAG: v${{ env.VERSION }} | |
| - name: Release | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| distribution: goreleaser | |
| version: latest | |
| args: release --clean --release-notes ${{ github.workspace }}-CHANGELOG.txt | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| AUR_KEY: ${{ secrets.AUR_KEY }} | |
| HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} | |
| GORELEASER_CURRENT_TAG: v${{ env.VERSION }} | |
| # Run only if the release was successful. | |
| homebrew: | |
| name: Bump Homebrew Formula | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ inputs.ref }} | |
| - uses: jdx/mise-action@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set version (changie) | |
| if: inputs.version == '' | |
| run: | | |
| CHANGIE_VERSION=$(changie latest) | |
| echo "VERSION=${CHANGIE_VERSION#v}" >> "$GITHUB_ENV" | |
| - name: Set version (input) | |
| if: inputs.version != '' | |
| run: | |
| echo "VERSION=${INPUT_VERSION#v}" >> "$GITHUB_ENV" | |
| env: | |
| INPUT_VERSION: ${{ inputs.version }} | |
| - name: Verify version | |
| run: | | |
| if [[ -z "$VERSION" ]]; then | |
| echo "No version set" | |
| exit 1 | |
| fi | |
| - name: Update Homebrew Formula | |
| uses: dawidd6/action-homebrew-bump-formula@v3.11.0 | |
| with: | |
| token: ${{ secrets.ROBOT_PAT }} | |
| user_name: Abhinav Gupta | |
| user_email: "187913561+abhinav-robot@users.noreply.github.com" | |
| formula: git-spice | |
| tag: v${{ env.VERSION }} |