Skip to content

release

release #71

Workflow file for this run

# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name (e.g., v1.0.0)'
required: true
release_name:
description: 'Release name (e.g., Release v1.0.0)'
required: true
jobs:
goreleaser:
permissions: write-all
runs-on: ubuntu-latest
steps:
-
name: Remove Ruby, CodeQL, PyPy and Python folders
run: |
echo "Cleaning up disk space..."
echo "Removing /opt/hostedtoolcache/Ruby, /opt/hostedtoolcache/CodeQL, /opt/hostedtoolcache/PyPy, /opt/hostedtoolcache/Python, /usr/share/dotnet, and /usr/local/lib/android"
sudo rm -rf /opt/hostedtoolcache/Ruby || true
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
sudo rm -rf /opt/hostedtoolcache/PyPy || true
sudo rm -rf /opt/hostedtoolcache/Python || true
sudo rm -rf /usr/share/dotnet || true
sudo rm -rf /usr/local/lib/android || true
echo "Cleanup complete."
-
name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
-
name: Set Git Identity
run: |
git config --global user.email "${{ github.event.inputs.email || 'actions@github.com' }}"
git config --global user.name "${{ github.event.inputs.name || github.actor }}"
-
name: Create Tag if Not Exists
id: create_tag
run: |
TAG_NAME=${{ github.event.inputs.tag_name }}
TAG_EXISTS=$(git tag -l "$TAG_NAME")
if [ -z "$TAG_EXISTS" ]; then
git tag -a "$TAG_NAME" -m "Tagging version $TAG_NAME"
git push origin "$TAG_NAME"
echo "::set-output name=tag_created::true"
else
echo "::set-output name=tag_created::false"
fi
-
name: Fetch all tags and branches
run: git fetch --prune --unshallow --tags
-
name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: 'go.mod'
-
name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6.3.0 # v6.3.0
with:
# These secrets will need to be configured for the repository:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
-
name: List keys
run: gpg -K
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
with:
version: latest
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}