mirror of
https://github.com/Lifailon/lazyjournal.git
synced 2026-11-11 01:09:46 +01:00
89 lines
2.5 KiB
YAML
89 lines
2.5 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: GOTOOLCHAIN=auto go install github.com/goreleaser/goreleaser/v2@latest
|
|
|
|
- name: Import GPG key
|
|
id: import_gpg
|
|
if: ${{ github.event_name == 'push' || github.event.inputs.Tag == 'true' }}
|
|
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' || github.event.inputs.Tag == 'true' }}
|
|
uses: goreleaser/goreleaser-action@v7
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
|
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
|
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
|