-
Notifications
You must be signed in to change notification settings - Fork 2
123 lines (105 loc) · 3.19 KB
/
package.yml
File metadata and controls
123 lines (105 loc) · 3.19 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
name: Tag Release Pipeline
run-name: Release ${{ github.ref_name }}
permissions:
contents: write
on:
push:
tags:
- "v*"
jobs:
verify:
name: Verify
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run unit tests
run: go test ./...
- name: Run race tests
run: go test -race ./...
build:
name: Build ${{ matrix.artifact_suffix }}
needs: verify
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: darwin
goarch: arm64
artifact_suffix: macos-arm
binary_name: codex-gateway
archive_format: tar.gz
- goos: windows
goarch: amd64
artifact_suffix: windows-x64
binary_name: codex-gateway.exe
archive_format: zip
- goos: linux
goarch: amd64
artifact_suffix: linux-x64
binary_name: codex-gateway
archive_format: tar.gz
- goos: linux
goarch: arm64
artifact_suffix: linux-arm
binary_name: codex-gateway
archive_format: tar.gz
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Resolve Version
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build binary
shell: bash
run: |
set -euo pipefail
mkdir -p dist package
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
go build -trimpath -ldflags "-s -w" -o "package/${{ matrix.binary_name }}" ./cmd/codex-gateway
cp README.md README.zh-CN.md config.example.yaml package/
- name: Create archive
shell: bash
run: |
set -euo pipefail
VERSION="${{ steps.version.outputs.VERSION }}"
BASENAME="codex-gateway-${VERSION}-${{ matrix.artifact_suffix }}"
if [[ "${{ matrix.archive_format }}" == "zip" ]]; then
(cd package && zip -r "../dist/${BASENAME}.zip" .)
else
tar -czf "dist/${BASENAME}.tar.gz" -C package .
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: codex-gateway-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_suffix }}
path: dist/*
if-no-files-found: error
release:
name: Publish Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: codex-gateway-*
path: release_assets
merge-multiple: true
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: codex-gateway ${{ github.ref_name }}
files: release_assets/*
draft: true
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}