tag v2.2 #103
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# 拉取代码 | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# 安装 bun | |
- uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Get bun store directory | |
id: bun-cache | |
run: | | |
cd frontend | |
echo bun_cache_dir=$(bun pm cache) >> $GITHUB_OUTPUT | |
cd .. | |
- name: Setup bun cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.bun-cache.outputs.bun_cache_dir }} | |
key: ${{ runner.os }}-bun-store-${{ hashFiles('**/bun.lockb') }} | |
restore-keys: | | |
${{ runner.os }}-bun-store- | |
- name: Build frontend | |
run: | | |
cd frontend | |
bun install | |
bun run build | |
cd .. | |
mkdir -p pkg/server/dist | |
mv frontend/dist/* pkg/server/dist/ | |
# 安装 go | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: ">=1.22.0" | |
check-latest: true | |
- name: Setup go cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/.cache/go-build | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
# 编译 | |
- name: Build | |
run: | | |
go mod tidy | |
go env -w GOARCH=amd64 | |
echo "编译 windows 版本" | |
go env -w GOOS=windows | |
go build -ldflags="-s -w" -o ./bin/smq.exe | |
# 使用 upx 压缩可执行文件 | |
- name: Run UPX | |
uses: crazy-max/ghaction-upx@v3 | |
with: | |
version: latest | |
files: | | |
./bin/* | |
args: -fq | |
- name: Move Files | |
run: | | |
mv sample/* bin/ | |
mv assets/ bin/ | |
mv README.md bin/ | |
mv CHANGELOG.md bin/ | |
# 上传到 Artifact | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: gosmq | |
path: ./bin/ |