-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (132 loc) · 3.88 KB
/
Copy pathrelease.yml
File metadata and controls
152 lines (132 loc) · 3.88 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
name: Release
on:
push:
tags:
- 'v*'
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
permissions:
contents: write
jobs:
guard:
name: Release Guard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Block stable release from non-main branch
run: |
TAG="${GITHUB_REF#refs/tags/}"
if [[ "$TAG" == *-* ]]; then
echo "Prerelease tag ($TAG) — allowed from any branch."
exit 0
fi
# Check if this tag points to a commit on main
if git branch -r --contains HEAD | grep -q 'origin/main'; then
echo "Stable tag ($TAG) on main — allowed."
else
echo "ERROR: Stable release tag ($TAG) must be on the main branch."
echo "Use a prerelease tag (e.g. ${TAG}-beta.1) for feature branches."
exit 1
fi
build:
needs: [guard]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Build Web UI
working-directory: web
run: |
npm ci
npm run build
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build -ldflags="-s -w" -o zen .
- name: Create tarball and copy binary
run: |
tar -czvf zen-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz zen
cp zen zen-${{ matrix.goos }}-${{ matrix.goarch }}
- uses: actions/upload-artifact@v4
with:
name: zen-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
zen-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
zen-${{ matrix.goos }}-${{ matrix.goarch }}
build-migrate:
needs: [guard]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build migration tool
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: go build -ldflags="-s -w" -o opencc ./cmd/opencc-migrate
- name: Create tarball and copy binary
run: |
tar -czvf opencc-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz opencc
cp opencc opencc-${{ matrix.goos }}-${{ matrix.goarch }}
- uses: actions/upload-artifact@v4
with:
name: opencc-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
opencc-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
opencc-${{ matrix.goos }}-${{ matrix.goarch }}
release:
needs: [build, build-migrate]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Detect prerelease
id: meta
run: |
TAG="${GITHUB_REF#refs/tags/}"
if [[ "$TAG" == *-* ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
prerelease: ${{ steps.meta.outputs.prerelease == 'true' }}
files: dist/*