-
-
Notifications
You must be signed in to change notification settings - Fork 26
211 lines (182 loc) · 6.3 KB
/
Copy pathbuild.yml
File metadata and controls
211 lines (182 loc) · 6.3 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
name: Build
on:
push:
branches: [ master, main, develop ]
tags:
- 'v*'
pull_request:
branches: [ master, main ]
workflow_dispatch:
jobs:
build:
name: Build for ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux
- os: ubuntu-latest
platform: linux-amd64
goos: linux
goarch: amd64
artifact_name: CodeKanban-linux-amd64
exe_name: CodeKanban
- os: ubuntu-latest
platform: linux-arm64
goos: linux
goarch: arm64
artifact_name: CodeKanban-linux-arm64
exe_name: CodeKanban
# Windows
- os: windows-latest
platform: windows-amd64
goos: windows
goarch: amd64
artifact_name: CodeKanban-windows-amd64
exe_name: CodeKanban.exe
# macOS
- os: macos-latest
platform: darwin-amd64
goos: darwin
goarch: amd64
artifact_name: CodeKanban-macos-amd64
exe_name: CodeKanban
- os: macos-latest
platform: darwin-arm64
goos: darwin
goarch: arm64
artifact_name: CodeKanban-macos-arm64
exe_name: CodeKanban
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.25.x'
cache: true
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.9
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: 'ui/pnpm-lock.yaml'
- name: Install frontend dependencies
working-directory: ./ui
run: pnpm install --frozen-lockfile
- name: Build frontend
working-directory: ./ui
run: pnpm build
- name: Copy frontend dist to static
shell: bash
run: |
rm -rf static/*
cp -r ui/dist/* static/
- name: Extract version info
id: version
shell: bash
run: |
BUILD_DATE=$(date +%Y%m%d)
echo "BUILD_METADATA=+${BUILD_DATE}" >> $GITHUB_OUTPUT
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
# Tag build (stable release)
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
echo "VERSION_MAIN=${TAG_VERSION}" >> $GITHUB_OUTPUT
echo "VERSION_PRERELEASE=" >> $GITHUB_OUTPUT
echo "APP_CHANNEL=stable" >> $GITHUB_OUTPUT
else
# Commit build (development)
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
TAG_VERSION="${LATEST_TAG#v}"
echo "VERSION_MAIN=${TAG_VERSION}" >> $GITHUB_OUTPUT
echo "VERSION_PRERELEASE=-alpha" >> $GITHUB_OUTPUT
echo "APP_CHANNEL=dev" >> $GITHUB_OUTPUT
fi
- name: Build Go binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
go build -ldflags="-s -w -X 'main.VERSION_MAIN=${{ steps.version.outputs.VERSION_MAIN }}' -X 'main.VERSION_PRERELEASE=${{ steps.version.outputs.VERSION_PRERELEASE }}' -X 'main.VERSION_BUILD_METADATA=${{ steps.version.outputs.BUILD_METADATA }}' -X 'main.APP_CHANNEL=${{ steps.version.outputs.APP_CHANNEL }}'" -trimpath -o ${{ matrix.exe_name }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.exe_name }}
retention-days: 30
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
CURRENT_TAG="${GITHUB_REF#refs/tags/}"
PREVIOUS_TAG=$(git describe --tags --abbrev=0 ${CURRENT_TAG}^ 2>/dev/null || echo "")
echo "Current tag: ${CURRENT_TAG}"
echo "Previous tag: ${PREVIOUS_TAG}"
{
echo "CHANGELOG<<EOF"
echo "## What's Changed"
echo ""
if [ -n "${PREVIOUS_TAG}" ]; then
# Get commits between previous tag and current tag
git log ${PREVIOUS_TAG}..${CURRENT_TAG} --pretty=format:"- %s (%h)" --no-merges
else
# First release, get all commits
git log ${CURRENT_TAG} --pretty=format:"- %s (%h)" --no-merges | head -20
fi
echo ""
echo ""
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_TAG}...${CURRENT_TAG}"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Package binaries
run: |
mkdir -p release
# Package Windows binaries as .zip
cd artifacts/CodeKanban-windows-amd64
zip ../../release/CodeKanban-windows-amd64.zip CodeKanban.exe
cd ../..
# Package Linux binaries as .tar.gz
cd artifacts/CodeKanban-linux-amd64
tar -czf ../../release/CodeKanban-linux-amd64.tar.gz CodeKanban
cd ../..
cd artifacts/CodeKanban-linux-arm64
tar -czf ../../release/CodeKanban-linux-arm64.tar.gz CodeKanban
cd ../..
# Package macOS binaries as .tar.gz
cd artifacts/CodeKanban-macos-amd64
tar -czf ../../release/CodeKanban-macos-amd64.tar.gz CodeKanban
cd ../..
cd artifacts/CodeKanban-macos-arm64
tar -czf ../../release/CodeKanban-macos-arm64.tar.gz CodeKanban
cd ../..
# List packaged files
ls -lh release/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: release/*
body: ${{ steps.changelog.outputs.CHANGELOG }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}