Merge pull request #15 from acaloiaro/make-pre-commit-4-compatible #31
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: goreleaser | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
goreleaser: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'go.mod' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT_TOKEN }} | |
- name: Bump version and push tag | |
shell: bash | |
run: | | |
git config --global user.email "actions@github.com" | |
git config --global user.name "Github Actions" | |
go install git.sr.ht/~jcmuller/semver-bumper@latest | |
newTag=$(git tag --list 'v*' | semver-bumper --increment minor) | |
buildDate=$(date --iso-8601=seconds) | |
sed -i -e "s@BUILD_DATE = \".\+\"@BUILD_DATE = \"${buildDate/v}\"@" main.go | |
sed -i -e "s@VERSION = \".\+\"@VERSION = \"${newTag/v}\"@" main.go | |
sed -i -e "s@version = \".\+\"@version = \"${newTag/v}\"@" default.nix | |
git add default.nix | |
git add main.go | |
git commit -m "Bump release version" | |
git tag $newTag | |
git push | |
git push --tags | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |