Skip to content

Correct .goreleaser (#6) #73

Correct .goreleaser (#6)

Correct .goreleaser (#6) #73

Workflow file for this run

name: Go Build
on:
push:
branches:
- 'master'
- 'releases/v*'
tags:
- 'v*'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
id: go
- name: Cache go module
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build and Test
run: go test -v -race -cover ./...
goreleaser:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
flags: ""
needs: build
name: goreleaser
steps:
# not a tagged released
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: echo "flags=--snapshot" >> $GITHUB_ENV
# tagged release
- if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: echo "flags=--release-notes .github/CHANGELOG.md" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Docker Buildx
# tagged release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: docker/setup-buildx-action@v1
- name: Login - Docker Hub
# tagged release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login - GitHub Container Registry
# tagged release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Find Last Tag
# tagged release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
id: last
uses: jimschubert/query-tag-action@v1
with:
include: 'v*'
exclude: '*-rc*'
commit-ish: 'HEAD~'
skip-unshallow: 'true'
- name: Find Current Tag
# tagged release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
id: current
uses: jimschubert/query-tag-action@v1
with:
include: 'v*'
exclude: '*-rc*'
commit-ish: '@'
skip-unshallow: 'true'
- name: Create Changelog
# tagged release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
id: changelog
uses: jimschubert/beast-changelog-action@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
CONFIG_LOCATION: .github/changelog.yml
FROM: ${{steps.last.outputs.tag}}
TO: ${{steps.current.outputs.tag}}
OUTPUT: .github/CHANGELOG.md
- name: View Changelog
# tagged release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: cat .github/CHANGELOG.md
- name: Check goreleaser
uses: goreleaser/goreleaser-action@v4
with:
args: check
- name: Execute goreleaser
uses: goreleaser/goreleaser-action@v4
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAP_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
args: release --rm-dist ${{ env.flags }}