This commit is contained in:
ryan
2026-06-09 22:00:01 +08:00
parent 1b5d37a8e8
commit df1961c42d
+35 -10
View File
@@ -21,6 +21,12 @@ env:
FRONTEND_BUILD_COMMAND: pnpm build:embed FRONTEND_BUILD_COMMAND: pnpm build:embed
FRONTEND_OUT_DIR: frontend/out FRONTEND_OUT_DIR: frontend/out
EMBED_DIST_DIR: internal/router/dist EMBED_DIST_DIR: internal/router/dist
EXTRA_FILES: |
LICENSE
README.md
README_zh.md
config.example.yaml
DEPLOYMENT_zh.md
permissions: permissions:
contents: write contents: write
@@ -152,16 +158,19 @@ jobs:
include: include:
- goos: linux - goos: linux
goarch: amd64 goarch: amd64
archive: tar.gz
- goos: linux - goos: linux
goarch: arm64 goarch: arm64
archive: tar.gz
- goos: darwin - goos: darwin
goarch: amd64 goarch: amd64
archive: tar.gz
- goos: darwin - goos: darwin
goarch: arm64 goarch: arm64
archive: tar.gz
- goos: windows - goos: windows
goarch: amd64 goarch: amd64
- goos: windows archive: zip
goarch: arm64
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -181,7 +190,6 @@ jobs:
- name: Build binary - name: Build binary
shell: bash shell: bash
env: env:
VERSION: ${{ needs.create-release.outputs.version }}
GOOS: ${{ matrix.goos }} GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }} GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0" CGO_ENABLED: "0"
@@ -196,7 +204,7 @@ jobs:
build_args=( build_args=(
-trimpath -trimpath
-ldflags "$GO_LDFLAGS -X github.com/Rain-kl/Wavelet/internal/cmd.Version=$VERSION" -ldflags "$GO_LDFLAGS"
-o "dist/$binary_name" -o "dist/$binary_name"
) )
@@ -206,25 +214,42 @@ jobs:
go build "${build_args[@]}" "$GO_MAIN" go build "${build_args[@]}" "$GO_MAIN"
- name: Rename binary for release - name: Package artifact
id: package id: package
shell: bash shell: bash
env: env:
VERSION: ${{ needs.create-release.outputs.version }} VERSION: ${{ needs.create-release.outputs.version }}
GOOS: ${{ matrix.goos }} GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }} GOARCH: ${{ matrix.goarch }}
ARCHIVE_FORMAT: ${{ matrix.archive }}
run: | run: |
set -euo pipefail set -euo pipefail
package_name="${APP_NAME}_${VERSION}_${GOOS}_${GOARCH}"
staging_dir="dist/$package_name"
mkdir -p "$staging_dir"
if [[ "$GOOS" == "windows" ]]; then if [[ "$GOOS" == "windows" ]]; then
src="dist/${APP_NAME}.exe" cp "dist/${APP_NAME}.exe" "$staging_dir/"
artifact="dist/${APP_NAME}_${VERSION}_${GOOS}_${GOARCH}.exe"
else else
src="dist/${APP_NAME}" cp "dist/${APP_NAME}" "$staging_dir/"
artifact="dist/${APP_NAME}_${VERSION}_${GOOS}_${GOARCH}" fi
while IFS= read -r extra_file; do
[[ -z "$extra_file" ]] && continue
if [[ -e "$extra_file" ]]; then
cp -R "$extra_file" "$staging_dir/"
fi
done <<< "$EXTRA_FILES"
if [[ "$ARCHIVE_FORMAT" == "zip" ]]; then
(cd dist && zip -r "${package_name}.zip" "$package_name")
artifact="dist/${package_name}.zip"
else
tar -C dist -czf "dist/${package_name}.tar.gz" "$package_name"
artifact="dist/${package_name}.tar.gz"
fi fi
mv "$src" "$artifact"
echo "artifact=$artifact" >> "$GITHUB_OUTPUT" echo "artifact=$artifact" >> "$GITHUB_OUTPUT"
- name: Upload release artifact - name: Upload release artifact