-
Notifications
You must be signed in to change notification settings - Fork 0
252 lines (210 loc) · 6.75 KB
/
Copy pathrelease.yml
File metadata and controls
252 lines (210 loc) · 6.75 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- os: macos-latest
goos: darwin
goarch: arm64
artifact: ccg-darwin-arm64
- os: macos-15-intel
goos: darwin
goarch: amd64
artifact: ccg-darwin-amd64
- os: ubuntu-24.04
goos: linux
goarch: amd64
artifact: ccg-linux-amd64
- os: ubuntu-24.04
goos: linux
goarch: arm64
artifact: ccg-linux-arm64
- os: windows-latest
goos: windows
goarch: amd64
artifact: ccg-windows-amd64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Install cross-compiler (Linux ARM64)
if: matrix.goos == 'linux' && matrix.goarch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 1
shell: bash
run: |
VERSION=${GITHUB_REF#refs/tags/}
COMMIT=${GITHUB_SHA::7}
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
BIN_EXT=""
if [ "${{ matrix.goos }}" = "windows" ]; then
BIN_EXT=".exe"
fi
mkdir -p dist
go build -tags "fts5" -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o "dist/ccg${BIN_EXT}" ./cmd/ccg/
go build -tags "fts5" -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o "dist/ccg-server${BIN_EXT}" ./cmd/ccg-server/
- name: Install UPX (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y upx-ucl
- name: Install UPX (macOS)
if: runner.os == 'macOS'
run: brew install upx
- name: Install UPX (Windows)
if: runner.os == 'Windows'
run: choco install upx -y
- name: Compress binary with UPX
continue-on-error: true
shell: bash
run: upx --best --lzma dist/*
- name: Compress (Unix)
if: matrix.goos != 'windows'
run: |
tar czf ${{ matrix.artifact }}.tar.gz -C dist ccg ccg-server
- name: Compress (Windows)
if: matrix.goos == 'windows'
run: |
Compress-Archive -Path dist/* -DestinationPath ccg-windows-amd64.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: |
*.tar.gz
*.zip
wiki-dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
cache-dependency-path: web/wiki/package-lock.json
- name: Build Wiki UI
working-directory: web/wiki
run: |
npm ci
npm run build
- name: Package Wiki UI
run: tar czf ccg-wiki-dist.tar.gz -C web/wiki/dist .
- name: Upload Wiki artifact
uses: actions/upload-artifact@v4
with:
name: ccg-wiki-dist
path: ccg-wiki-dist.tar.gz
release:
needs:
- build
- wiki-dist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
artifacts/*.tar.gz
artifacts/*.zip
publish-container:
needs: release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- name: Download Linux AMD64 artifact
uses: actions/download-artifact@v4
with:
name: ccg-linux-amd64
path: artifacts/ccg-linux-amd64
- name: Download Linux ARM64 artifact
uses: actions/download-artifact@v4
with:
name: ccg-linux-arm64
path: artifacts/ccg-linux-arm64
- name: Download Wiki artifact
uses: actions/download-artifact@v4
with:
name: ccg-wiki-dist
path: artifacts/ccg-wiki-dist
- name: Prepare container artifacts
shell: bash
run: |
mkdir -p container-artifacts/amd64 container-artifacts/arm64 container-artifacts/wiki
tar xzf artifacts/ccg-linux-amd64/ccg-linux-amd64.tar.gz -C container-artifacts/amd64
tar xzf artifacts/ccg-linux-arm64/ccg-linux-arm64.tar.gz -C container-artifacts/arm64
tar xzf artifacts/ccg-wiki-dist/ccg-wiki-dist.tar.gz -C container-artifacts/wiki
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract container metadata
id: metadata
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository }}
flavor: latest=false
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }}
- name: Build and publish container image
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
publish-npm:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Copy README for npm
run: cp README.md npm/README.md
- name: Set version from tag
run: |
VERSION=${GITHUB_REF#refs/tags/v}
cd npm
npm version $VERSION --no-git-tag-version
- name: Publish to npm
working-directory: npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public