-
Notifications
You must be signed in to change notification settings - Fork 642
86 lines (73 loc) · 2.54 KB
/
release.yml
File metadata and controls
86 lines (73 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Release
on:
release:
types: [published]
permissions:
contents: write
packages: write
id-token: write # needed for signing
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00
with:
go-version-file: 'go.mod'
cache: true
- name: Install cosign
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
- name: Install Syft
uses: anchore/sbom-action/download-syft@v0.20.10
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a
with:
distribution: goreleaser
version: v2.12.0
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ko-push:
name: Build and Push Image with ko
runs-on: ubuntu-latest
needs: goreleaser
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- name: Set up Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00
with:
go-version-file: 'go.mod'
cache: true
- name: Set up ko
uses: ko-build/setup-ko@v0.9
- name: Log in to Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get build timestamp and version
id: build-info
run: |
echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
# Extract version from tag and strip 'v' prefix (e.g., refs/tags/v1.2.3 -> 1.2.3)
VERSION="${GITHUB_REF#refs/tags/}"
VERSION="${VERSION#v}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build and push with ko
env:
KO_DOCKER_REPO: ghcr.io/${{ github.repository }}
VERSION: ${{ steps.build-info.outputs.version }}
GIT_COMMIT: ${{ github.sha }}
BUILD_TIME: ${{ steps.build-info.outputs.timestamp }}
run: |
# Build and push multi-platform image with version tag and latest
ko build ./cmd/registry \
--bare \
--platform=linux/amd64,linux/arm64 \
--tags=${{ steps.build-info.outputs.version }},latest