Skip to content

Commit

Permalink
GH Actions CI and release improvements (#89)
Browse files Browse the repository at this point in the history
- Make sure bin directory exists prior to attempting binary fetches
- Bump versions of goreleaser and krew-release-bot
- Share goreleaser workflow for PRs, branch pushes, and tags, but with
  configuration based on event type

Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
  • Loading branch information
joelanford authored Nov 17, 2023
1 parent 019ce08 commit 641f976
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

name: ci
name: test
on:
push:
pull_request:
jobs:
goreleaser:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

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

Expand All @@ -22,8 +22,3 @@ jobs:

- name: Lint
run: make lint

- name: Run GoReleaser
run: make release
env:
RELEASE_ARGS: release --rm-dist --snapshot
24 changes: 18 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
name: release
on:
push:
branches:
- 'main'
tags:
- 'v*.*.*'
pull_request:
branches:
- 'main'

jobs:
goreleaser:
release:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Set the release related variables
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo RELEASE_ARGS="--clean" >> $GITHUB_ENV
echo ENABLE_RELEASE_PIPELINE=true >> $GITHUB_ENV
- name: Run GoReleaser
run: make release
env:
RELEASE_ARGS: release --rm-dist
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}

- name: Update new version in krew-index
uses: rajatjindal/krew-release-bot@v0.0.38
if: startsWith(github.ref, 'refs/tags/v')
uses: rajatjindal/krew-release-bot@v0.0.46
3 changes: 3 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ archives:
format: tar.gz
files:
- LICENSE

release:
disable: '{{ ne .Env.ENABLE_RELEASE_PIPELINE "true" }}'
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ lint:
source ./scripts/fetch.sh; fetch golangci-lint 1.50.1 && ./bin/golangci-lint --timeout 3m run

.PHONY: release
RELEASE_ARGS?=release --rm-dist --snapshot
RELEASE_ARGS?=release --clean --snapshot
release:
source ./scripts/fetch.sh; fetch goreleaser 1.13.0 && ./bin/goreleaser $(RELEASE_ARGS)
source ./scripts/fetch.sh; fetch goreleaser 1.22.1 && ./bin/goreleaser $(RELEASE_ARGS)
1 change: 1 addition & 0 deletions scripts/fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ROOT="$( git rev-parse --show-toplevel )"

fetch() {
mkdir -p "${ROOT}/bin"
local tool=$1; shift
local ver=$1; shift

Expand Down

0 comments on commit 641f976

Please sign in to comment.