Release #12
This file contains 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: Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version number for this release (e.g., v1.0.0 or v1.0.0-rc1)' | |
required: true | |
default: 'v1.0.0' | |
jobs: | |
goreleaser: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/[email protected] | |
with: | |
go-version: '1.22' # Adjust this to your Go version | |
- name: Set release version | |
run: | | |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
git config user.name github-action | |
git config user.email [email protected] | |
git tag ${{ github.event.inputs.version }} | |
git push origin ${{ github.event.inputs.version }} | |
else | |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
fi | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GORELEASER_CURRENT_TAG: ${{ env.RELEASE_VERSION }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: dist/* |