Skip to content

Publish release

Publish release #21

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@v4
with:
ref: ${{ inputs.ref }}
token: ${{ secrets.PAT }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Query changie
if: inputs.version == ''
id: changie-latest
uses: miniscruff/changie-action@v2
with:
args: latest
- name: Set version (changie)
if: inputs.version == ''
run:
echo "VERSION=${CHANGIE_VERSION#v}" >> "$GITHUB_ENV"
env:
CHANGIE_VERSION: ${{ steps.changie-latest.outputs.output }}
- 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 }}