Skip to content

Commit d974b38

Browse files
committed
Add GHA release workflow
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
1 parent c6bb05b commit d974b38

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/release.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on all tag pushes with "v" prefix
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write # Needed for GH releases
13+
packages: write # Needed for pushing to GHCR
14+
steps:
15+
- name: Authenticate with GHCR
16+
run: |
17+
echo "${{ secrets.GHCR_TOKEN }}" | skopeo login ghcr.io -u ${{ github.actor }} --password-stdin
18+
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version-file: go.mod
28+
29+
- name: Determine version info
30+
id: version
31+
run: |
32+
TAG_NAME=${GITHUB_REF#refs/tags/}
33+
echo "tag=$TAG_NAME" >> $GITHUB_ENV
34+
LATEST_TAG=$(git tag -l --sort=-v:refname | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
35+
if [[ "$TAG_NAME" == "$LATEST_TAG" ]]; then
36+
echo "latest=true" >> $GITHUB_ENV
37+
else
38+
echo "latest=false" >> $GITHUB_ENV
39+
fi
40+
41+
- name: Install ko
42+
run: |
43+
go install github.com/google/ko@latest
44+
45+
- name: Build and push image
46+
run: |
47+
ko build --oci-layout-path kpm.oci --push=false --platform all .
48+
skopeo copy --all oci:./kpm.oci docker://ghcr.io/${{ github.repository_owner }}/kpm:$tag
49+
50+
- name: If latest version, push latest tag
51+
if: env.latest == 'true'
52+
run: |
53+
skopeo copy --all oci:./kpm.oci docker://ghcr.io/${{ github.repository_owner }}/kpm:latest
54+
55+
- name: Create/Update Release
56+
uses: softprops/action-gh-release@v2
57+
with:
58+
generate_release_notes: true
59+
make_latest: "${{ env.latest }}"

0 commit comments

Comments
 (0)