forked from james-6-23/codex2api
-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (81 loc) · 2.33 KB
/
release.yml
File metadata and controls
99 lines (81 loc) · 2.33 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
env:
VERSION: ${{ github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build frontend
working-directory: frontend
env:
VITE_APP_VERSION: ${{ github.ref_name }}
run: |
npm ci
npm run build
- name: Build release assets
shell: bash
run: |
set -euo pipefail
version="${VERSION#v}"
mkdir -p dist build
build_target() {
local goos="$1"
local goarch="$2"
local archive_base="codex2api_${version}_${goos}_${goarch}"
local workdir="build/${goos}_${goarch}"
local binary_name="codex2api"
rm -rf "$workdir"
mkdir -p "$workdir"
if [[ "$goos" == "windows" ]]; then
binary_name="codex2api.exe"
fi
CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" go build -trimpath -ldflags="-s -w" -o "$workdir/$binary_name" .
cp .env.example "$workdir/.env.example"
cp README.md "$workdir/README.md"
if [[ "$goos" == "windows" ]]; then
(
cd "$workdir"
zip -r "../../dist/${archive_base}.zip" .
)
else
tar -C "$workdir" -czf "dist/${archive_base}.tar.gz" .
fi
}
build_target linux amd64
build_target linux arm64
build_target darwin amd64
build_target darwin arm64
build_target windows amd64
(
cd dist
sha256sum * > SHA256SUMS.txt
)
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
dist/*.tar.gz
dist/*.zip
dist/SHA256SUMS.txt