Files
lazyjournal/.github/workflows/go-release.yml
2026-10-30 16:10:17 +03:00

86 lines
2.2 KiB
YAML

name: "[GO] Release publish on GitHub"
on:
workflow_dispatch:
inputs:
Tag:
description: 'Create GitHub tag and branch for new version'
default: false
type: boolean
Upload:
description: 'Upload artifacts'
default: false
type: boolean
push:
tags:
- '*'
permissions:
contents: write
jobs:
goreleaser:
runs-on: ubuntu-latest
env:
VERSION: ''
steps:
- name: Checkout repository (all commits)
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v7
with:
go-version: 1.27.0
- name: Get app version for tag
if: ${{ github.event.inputs.Tag == 'true' }}
run: |
VERSION=$(go run main.go -v)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create git tag and branch for new version
if: ${{ github.event.inputs.Tag == 'true' }}
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
git tag $VERSION
git checkout -b "release/$VERSION"
git push origin "release/$VERSION" $VERSION
- name: Install goreleaser
run: go install ://github.com
- name: Import GPG key
if: ${{ github.event_name == 'push' }}
uses: crazy-max/ghaction-import-gpg@v7
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Go release check
run: goreleaser --clean --skip=publish --skip=validate 2>&1 | tee goreleaser.log
- name: Upload changelog to summary
run: cat dist/CHANGELOG.md >> $GITHUB_STEP_SUMMARY
- name: Go release publish
if: ${{ github.event_name == 'push' }}
uses: goreleaser/goreleaser-action@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
distribution: goreleaser
args: release --clean
- name: Upload artifacts
if: ${{ github.event.inputs.Upload == 'true' }}
uses: actions/upload-artifact@v7
with:
name: binary-packages
path: dist/*
retention-days: 7