Skip to content

Publish release

Publish release #57

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
skip_publish:
description: Skip the publish step.
required: false
default: false
type: boolean
permissions:
contents: write
jobs:
release:
name: Publish Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
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
echo ""
echo "---"
echo ""
echo "[Support git-spice development](https://github.com/sponsors/abhinav)"
} > ${{ github.workspace }}-CHANGELOG.txt
echo "::group::CHANGELOG"
cat ${{ github.workspace }}-CHANGELOG.txt
echo "::endgroup::"
- name: Tag a release
if: inputs.skip_publish == false
run: |
git tag "$TAG"
git push origin "$TAG"
env:
TAG: v${{ env.VERSION }}
- name: Release
if: inputs.skip_publish == false
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@v6
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@v7
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 }}