Skip to content

Commit

Permalink
CI: add automatic release on tag
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-dartigues committed May 24, 2024
1 parent dc67c03 commit 39dacb5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
61 changes: 61 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: goreleaser

on:
push:
# do not consider simple commit
branches:
- '!*'
# consider only release and pre-release tags
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: set up go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: cache go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: "${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}"
restore-keys: |
${{ runner.os }}-go-
- name: tests modules
run: |
go mod vendor
if [ ! -z "$(git status --porcelain)" ]; then
echo "::error::vendor directory if not synced with go.mod, please run go mod vendor"
exit 1
fi
go mod tidy
if [ ! -z "$(git status --porcelain)" ]; then
echo "::error::modules are not tidy, please run go mod tidy"
exit 1
fi
- name: tests
run: |
go test -v ./...
- name: run goreleaser
uses: goreleaser/goreleaser-action@v5
if: success() && startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: github-actions
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: set up go
uses: actions/setup-go@v5
with:
go-version: 1.22
go-version: "1.22"

- name: cache go modules
uses: actions/cache@v4
Expand Down

0 comments on commit 39dacb5

Please sign in to comment.