Skip to content

Publish release

Publish release #1

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: action/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: Install parse-changelog
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- 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.version }}
- name: Set veresion (input)
if: inputs.version != ''
run:
echo "VERSION=${INPUT_VERSION#v}" >> "$GITHUB_ENV"
env:
INPUT_VERSION: ${{ inputs.version }}
- name: Extract changelog
run: |
parse-changelog CHANGELOG.md ${{ env.VERSION }} > ${{ github.workspace }}-CHANGELOG.txt
echo ::group::CHANGELOG
cat ${{ github.workspace }}-CHANGELOG.txt
echo ::endgroup::
- name: Tag a release
run: |
git tag v${{ env.VERSION }}
git push origin v${{ env.VERSION }}
- name: Release
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean --release-notes ${{ github.workspace }}-CHANGELOG.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: v${{ env.VERSION }}