Skip to content

Commit

Permalink
workflow: combine goreleaser stages, separate tap token
Browse files Browse the repository at this point in the history
  • Loading branch information
jimschubert committed Jan 16, 2023
1 parent ea989dd commit 6e0992a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 38 deletions.
63 changes: 25 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,65 +35,43 @@ jobs:
- name: Build and Test
run: go test -v -race -cover ./...

goreleser-branch:
if: false == startsWith(github.ref, 'refs/tags/')
goreleaser:
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
flags: ""
needs: build
name: goreleaser (branch)
name: goreleaser

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod

- name: GoReleaser
uses: goreleaser/goreleaser-action@v4
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 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
version: latest
args: release --rm-dist
# 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

goreleaser-release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
needs: build
name: goreleaser (release)

steps:
- 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
Expand All @@ -106,6 +84,8 @@ jobs:
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:
Expand All @@ -115,6 +95,8 @@ jobs:
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:
Expand All @@ -124,6 +106,8 @@ jobs:
skip-unshallow: 'true'

- name: Create Changelog
# tagged release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
id: changelog
uses: jimschubert/beast-changelog-action@v1
with:
Expand All @@ -134,6 +118,8 @@ jobs:
OUTPUT: .github/CHANGELOG.md

- name: View Changelog
# tagged release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: cat .github/CHANGELOG.md

- name: Check goreleaser
Expand All @@ -146,9 +132,10 @@ jobs:
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 --release-notes .github/CHANGELOG.md
args: release --rm-dist ${{ env.flags }}
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ brews:
- tap:
owner: jimschubert
name: homebrew-tap
token: "{{ .Env.TAP_GITHUB_TOKEN }}"
folder: Formula
homepage: https://github.com/jimschubert/docked
description: A Dockerfile linter
Expand Down

0 comments on commit 6e0992a

Please sign in to comment.