Merge pull request #24 from snhane/master #58
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
# This workflow will build a golang project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |
name: Go | |
on: | |
push: | |
pull_request: | |
types: | |
- opened | |
- edited | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- run: go mod tidy | |
- run: go build | |
- run: go test -v ./... | |
continue-on-error: true | |
# temporarily continue even if unit tests fail | |
create_tag: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/master' | |
# outputs: | |
# release_id: ${{ steps.create_release.outputs.id }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Bump release version and push tag | |
id: release | |
uses: anothrNick/github-tag-action@1.64.0 # Don't use @master or @v1 unless you're happy to test the latest version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # if you don't want to set write permissions use a PAT token | |
WITH_V: true | |
PRERELEASE: false | |
- name: get the latest tag | |
id: tag | |
run: | | |
latest_tag=$(git describe --tags --abbrev=0) | |
echo "tag_name=$latest_tag" >> $GITHUB_OUTPUT | |
- name: create release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
tag: ${{ steps.tag.outputs.tag_name }} | |
name: ${{ steps.tag.outputs.tag_name }} | |
draft: false | |
prerelease: false | |
goreleaser: | |
needs: create_tag | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
# either 'goreleaser' (default) or 'goreleaser-pro' | |
distribution: goreleaser | |
version: latest | |
args: release --clean | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |