-
Notifications
You must be signed in to change notification settings - Fork 3
169 lines (143 loc) · 4.71 KB
/
Copy pathrelease.yml
File metadata and controls
169 lines (143 loc) · 4.71 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: "1.23"
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.11
test:
name: Test
runs-on: ubuntu-22.04
needs: lint
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: "1.23"
- name: Run all tests
run: go test -race ./...
build-binaries:
name: Build (${{ matrix.goos }}/${{ matrix.goarch }})
runs-on: ubuntu-22.04
needs: test
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: "1.23"
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
run: |
mkdir -p dist
go build -ldflags="-s -w" -o dist/paude-proxy-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/paude-proxy/
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: paude-proxy-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/paude-proxy-${{ matrix.goos }}-${{ matrix.goarch }}
publish-containers:
name: Publish Container Images
runs-on: ubuntu-22.04
needs: test
steps:
- uses: actions/checkout@v6
- name: Set up QEMU for multi-arch builds
run: sudo apt-get update && sudo apt-get install -y qemu-user-static
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
- name: Log in to Quay.io
run: podman login -u "${{ secrets.QUAY_USERNAME }}" -p "${{ secrets.QUAY_PASSWORD }}" quay.io
- name: Check if pre-release
id: prerelease
run: |
if echo "${GITHUB_REF_NAME}" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
fi
- name: Build and push multi-arch image
env:
VERSION: ${{ steps.version.outputs.version }}
IS_PRERELEASE: ${{ steps.prerelease.outputs.is_prerelease }}
run: |
IMAGE=quay.io/bbrowning/paude-proxy-go-centos10
FULL="${IMAGE}:${VERSION}"
podman manifest create "${FULL}"
podman build --platform linux/amd64,linux/arm64 --manifest "${FULL}" .
podman manifest push --all "${FULL}" "docker://${FULL}"
# Only update latest for stable releases
if [ "${IS_PRERELEASE}" = "false" ]; then
podman manifest push --all "${FULL}" "docker://${IMAGE}:latest"
else
echo "Skipping latest tag for pre-release ${VERSION}"
fi
github-release:
name: GitHub Release
runs-on: ubuntu-22.04
needs: [build-binaries, publish-containers]
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Check if pre-release
id: prerelease
run: |
if echo "${GITHUB_REF_NAME}" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
fi
- name: Generate release notes
run: |
PREV_TAG=$(git tag --sort=-version:refname | grep '^v' | sed -n '2p')
if [ -n "${PREV_TAG}" ]; then
git log --pretty=format:"- %s" "${PREV_TAG}..${GITHUB_REF_NAME}" \
| grep -v "^- Release v" > /tmp/release-notes.txt || true
else
git log --pretty=format:"- %s" "${GITHUB_REF_NAME}" \
| grep -v "^- Release v" > /tmp/release-notes.txt || true
fi
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
PRERELEASE_FLAG=""
if [ "${{ steps.prerelease.outputs.is_prerelease }}" = "true" ]; then
PRERELEASE_FLAG="--prerelease"
fi
gh release create "${GITHUB_REF_NAME}" dist/* \
--title "${GITHUB_REF_NAME}" \
--notes-file /tmp/release-notes.txt \
${PRERELEASE_FLAG}