Skip to content

Commit 39d24bb

Browse files
committed
feat: add release workflow
Signed-off-by: Matthias Riegler <[email protected]>
1 parent 7ec86b2 commit 39d24bb

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

.github/workflows/release.yaml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
permissions: write-all
8+
9+
jobs:
10+
# Release-please for auto-updated PRs
11+
release-please:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: googleapis/release-please-action@v4
15+
id: release-please
16+
with:
17+
release-type: simple # actual releasing is handled by goreleaser
18+
package-name: mq-lease-service
19+
outputs:
20+
release_created: ${{ steps.release-please.outputs.release_created }}
21+
22+
# Goreleaser for binary releases / GH release
23+
goreleaser:
24+
runs-on: ubuntu-latest
25+
needs:
26+
- release-please
27+
if: needs.release-please.outputs.release_created
28+
steps:
29+
# Checkout code (full history)
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
# Setup golang with caching
36+
- name: Setup Golang
37+
uses: actions/setup-go@v4
38+
with:
39+
go-version: stable
40+
- id: go-cache-paths
41+
run: |
42+
echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
43+
echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
44+
- name: Go Build Cache
45+
uses: actions/cache@v3
46+
with:
47+
path: ${{ steps.go-cache-paths.outputs.go-build }}
48+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
49+
- name: Go Mod Cache
50+
uses: actions/cache@v3
51+
with:
52+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
53+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
54+
55+
- name: 'Login to GitHub Container Registry'
56+
uses: docker/login-action@v3
57+
with:
58+
registry: ghcr.io
59+
username: ${{github.actor}}
60+
password: ${{secrets.GITHUB_TOKEN}}
61+
62+
# Install cosign
63+
- name: Install Cosign
64+
uses: sigstore/cosign-installer@v3
65+
66+
# Run goreleaser
67+
- name: Run Goreleaser
68+
uses: goreleaser/goreleaser-action@v5
69+
with:
70+
version: latest
71+
args: release --clean
72+
env:
73+
COSIGN_YES: "true"
74+
KO_DOCKER_REPO: ghcr.io/${{ github.repository }}
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+

.goreleaser.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
project_name: mq-lease-service
2+
3+
kos:
4+
- repository: ghcr.io/ankorstore/mq-lease-service
5+
main: ./cmd/
6+
platforms:
7+
- linux/amd64
8+
- linux/arm64
9+
bare: true
10+
tags:
11+
- latest
12+
- '{{.Tag}}'
13+
- '{{if not .Prerelease}}stable{{end}}'

0 commit comments

Comments
 (0)