Merge pull request #17 from acaloiaro/git-add-optional #34
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 github.com/caarlos0/svu@latest | |
OLD_TAG=$(svu current --strip-prefix) | |
NEW_TAG=$(svu next --strip-prefix) | |
[ "$OLD_TAG" == "$NEW_TAG" ] && echo "no version bump" && exit 0 | |
sed -i "s/$OLD_TAG/$NEW_TAG/g" default.nix | |
sed -i "s/$OLD_TAG/$NEW_TAG/g" main.go | |
git add default.nix | |
git add main.go | |
git commit -m "bump release version" --allow-empty | |
git tag v$NEW_TAG | |
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 }} |