-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (158 loc) · 5.96 KB
/
release.yml
File metadata and controls
190 lines (158 loc) · 5.96 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
name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Get tag version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
name: Release ${{ steps.get_version.outputs.VERSION }}
body: |
## 🚀 Release ${{ steps.get_version.outputs.VERSION }}
### 📦 安装方式
**Python SDK:**
```bash
pip install go-server-sdk==${{ steps.get_version.outputs.VERSION }}
```
**Node.js SDK:**
```bash
npm install go-server-sdk@${{ steps.get_version.outputs.VERSION }}
```
**Rust SDK:**
```bash
cargo add go-server-sdk@${{ steps.get_version.outputs.VERSION }}
```
**Go SDK:**
```bash
go get github.com/go-enols/go-server@${{ steps.get_version.outputs.VERSION }}
```
### 📋 更新内容
- 请查看 [CHANGELOG.md](https://github.com/go-enols/go-server/blob/main/CHANGELOG.md) 了解详细更新内容
### 🔗 相关链接
- [PyPI Package](https://pypi.org/project/go-server-sdk/${{ steps.get_version.outputs.VERSION }}/)
- [NPM Package](https://www.npmjs.com/package/go-server-sdk/v/${{ steps.get_version.outputs.VERSION }})
- [Crates.io Package](https://crates.io/crates/go-server-sdk/${{ steps.get_version.outputs.VERSION }})
- [Documentation](https://github.com/go-enols/go-server/blob/main/README.md)
draft: false
prerelease: false
build-and-upload:
name: Build and Upload Assets
needs: create-release
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: windows
goarch: amd64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
- name: Get tag version
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
mkdir -p dist
if [ "$GOOS" = "windows" ]; then
go build -ldflags "-s -w -X main.version=${{ steps.get_version.outputs.VERSION }}" -o dist/go-server-${{ matrix.goos }}-${{ matrix.goarch }}.exe .
else
go build -ldflags "-s -w -X main.version=${{ steps.get_version.outputs.VERSION }}" -o dist/go-server-${{ matrix.goos }}-${{ matrix.goarch }} .
fi
- name: Create archive
run: |
cd dist
if [ "${{ matrix.goos }}" = "windows" ]; then
zip go-server-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip go-server-${{ matrix.goos }}-${{ matrix.goarch }}.exe
echo "ASSET_PATH=dist/go-server-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip" >> $GITHUB_ENV
echo "ASSET_NAME=go-server-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip" >> $GITHUB_ENV
echo "ASSET_TYPE=application/zip" >> $GITHUB_ENV
else
tar -czf go-server-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz go-server-${{ matrix.goos }}-${{ matrix.goarch }}
echo "ASSET_PATH=dist/go-server-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz" >> $GITHUB_ENV
echo "ASSET_NAME=go-server-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz" >> $GITHUB_ENV
echo "ASSET_TYPE=application/gzip" >> $GITHUB_ENV
fi
- name: Upload Release Asset
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
files: ${{ env.ASSET_PATH }}
publish-packages:
name: Publish Packages
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install Python build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build and publish Python package
working-directory: ./python-sdk
run: |
python -m build
twine upload dist/* --skip-existing
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
- name: Install Node.js dependencies and publish
working-directory: ./node-sdk
run: |
npm ci
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Login to crates.io
working-directory: ./rust-sdk
run: cargo login ${{ secrets.RUST_TOKEN }}
- name: Publish Rust package
working-directory: ./rust-sdk
run: cargo publish