mirror of
https://gh-proxy.org/https://github.com/klinsmaya/CLIProxyAPI.git
synced 2026-11-08 01:16:47 +08:00
chore(build): remove goreleaser configuration and refactor release workflow
- Deleted `.goreleaser.yml` configuration and migrated functionality to GitHub Actions workflows. - Replaced `goreleaser` with matrix-based build and archiving process for improved flexibility. - Enhanced platform and architecture-specific builds, including FreeBSD support and custom runners. - Streamlined artifact upload, checksum generation, and release publishing.
This commit is contained in:
+187
-20
@@ -1,4 +1,4 @@
|
||||
name: goreleaser
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -9,37 +9,204 @@ on:
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
GO_VERSION: '1.26.4'
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: macos-latest
|
||||
build-hosted:
|
||||
name: build ${{ matrix.target }}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- target: linux-amd64
|
||||
runner: ubuntu-latest
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
asset_arch: amd64
|
||||
archive_format: tar.gz
|
||||
- target: linux-arm64
|
||||
runner: ubuntu-24.04-arm
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
asset_arch: aarch64
|
||||
archive_format: tar.gz
|
||||
- target: darwin-amd64
|
||||
runner: macos-15-intel
|
||||
goos: darwin
|
||||
goarch: amd64
|
||||
asset_arch: amd64
|
||||
archive_format: tar.gz
|
||||
- target: darwin-arm64
|
||||
runner: macos-15
|
||||
goos: darwin
|
||||
goarch: arm64
|
||||
asset_arch: aarch64
|
||||
archive_format: tar.gz
|
||||
- target: windows-amd64
|
||||
runner: windows-latest
|
||||
goos: windows
|
||||
goarch: amd64
|
||||
asset_arch: amd64
|
||||
archive_format: zip
|
||||
- target: windows-arm64
|
||||
runner: windows-11-arm
|
||||
goos: windows
|
||||
goarch: arm64
|
||||
asset_arch: aarch64
|
||||
archive_format: zip
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Refresh models catalog
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git fetch --depth 1 https://github.com/router-for-me/models.git main
|
||||
git show FETCH_HEAD:models.json > internal/registry/models/models.json
|
||||
- name: Fetch tags
|
||||
shell: bash
|
||||
run: git fetch --force --tags
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: true
|
||||
- name: Generate Build Metadata
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
echo "RELEASE_VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"
|
||||
echo "COMMIT=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
|
||||
echo "BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_ENV"
|
||||
- name: Build archive
|
||||
shell: bash
|
||||
env:
|
||||
TARGET: ${{ matrix.target }}
|
||||
GOOS: ${{ matrix.goos }}
|
||||
GOARCH: ${{ matrix.goarch }}
|
||||
ASSET_ARCH: ${{ matrix.asset_arch }}
|
||||
ARCHIVE_FORMAT: ${{ matrix.archive_format }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
binary_name="cli-proxy-api"
|
||||
if [[ "$GOOS" == "windows" ]]; then
|
||||
binary_name="cli-proxy-api.exe"
|
||||
fi
|
||||
|
||||
archive_dir="dist/${TARGET}/archive"
|
||||
archive_name="CLIProxyAPI_${RELEASE_VERSION}_${GOOS}_${ASSET_ARCH}.${ARCHIVE_FORMAT}"
|
||||
rm -rf "dist/${TARGET}"
|
||||
mkdir -p "$archive_dir"
|
||||
|
||||
CGO_ENABLED=1 GOOS="$GOOS" GOARCH="$GOARCH" go build \
|
||||
-ldflags="-s -w -X main.Version=${RELEASE_VERSION} -X main.Commit=${COMMIT} -X main.BuildDate=${BUILD_DATE}" \
|
||||
-o "$archive_dir/$binary_name" ./cmd/server/
|
||||
|
||||
cp LICENSE README.md README_CN.md config.example.yaml "$archive_dir/"
|
||||
if [[ "$ARCHIVE_FORMAT" == "zip" ]]; then
|
||||
powershell -NoProfile -Command "Compress-Archive -Path '${archive_dir}/*' -DestinationPath 'dist/${archive_name}' -Force"
|
||||
else
|
||||
tar -C "$archive_dir" -czf "dist/$archive_name" "$binary_name" LICENSE README.md README_CN.md config.example.yaml
|
||||
fi
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.target }}
|
||||
path: dist/CLIProxyAPI_*
|
||||
if-no-files-found: error
|
||||
|
||||
build-freebsd:
|
||||
name: build freebsd-${{ matrix.goarch }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- goarch: amd64
|
||||
vm_arch: x86-64
|
||||
asset_arch: amd64
|
||||
- goarch: arm64
|
||||
vm_arch: arm64
|
||||
asset_arch: aarch64
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Refresh models catalog
|
||||
run: |
|
||||
git fetch --depth 1 https://github.com/router-for-me/models.git main
|
||||
git show FETCH_HEAD:models.json > internal/registry/models/models.json
|
||||
- run: git fetch --force --tags
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '>=1.26.0'
|
||||
cache: true
|
||||
- uses: mlugg/setup-zig@v2
|
||||
with:
|
||||
version: 0.16.0
|
||||
- name: Fetch tags
|
||||
run: git fetch --force --tags
|
||||
- name: Generate Build Metadata
|
||||
run: |
|
||||
echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
|
||||
echo "RELEASE_VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
|
||||
echo COMMIT=`git rev-parse --short HEAD` >> $GITHUB_ENV
|
||||
echo BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` >> $GITHUB_ENV
|
||||
- uses: goreleaser/goreleaser-action@v4
|
||||
- name: Start FreeBSD ${{ matrix.goarch }} VM
|
||||
uses: cross-platform-actions/[email protected]
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: latest
|
||||
args: release --clean --skip=validate
|
||||
operating_system: freebsd
|
||||
architecture: ${{ matrix.vm_arch }}
|
||||
version: '13.5'
|
||||
shell: sh
|
||||
memory: 5G
|
||||
cpu_count: 4
|
||||
environment_variables: GO_VERSION RELEASE_VERSION COMMIT BUILD_DATE
|
||||
- name: Build FreeBSD archive
|
||||
shell: cpa.sh {0}
|
||||
env:
|
||||
TARGET: freebsd-${{ matrix.goarch }}
|
||||
GOARCH: ${{ matrix.goarch }}
|
||||
ASSET_ARCH: ${{ matrix.asset_arch }}
|
||||
run: |
|
||||
set -eu
|
||||
fetch -o /tmp/go.tar.gz "https://go.dev/dl/go${GO_VERSION}.freebsd-${GOARCH}.tar.gz"
|
||||
rm -rf /tmp/go
|
||||
tar -C /tmp -xzf /tmp/go.tar.gz
|
||||
export PATH="/tmp/go/bin:$PATH"
|
||||
go version
|
||||
|
||||
archive_dir="dist/${TARGET}/archive"
|
||||
archive_name="CLIProxyAPI_${RELEASE_VERSION}_freebsd_${ASSET_ARCH}.tar.gz"
|
||||
rm -rf "dist/${TARGET}"
|
||||
mkdir -p "$archive_dir"
|
||||
|
||||
CGO_ENABLED=1 GOOS=freebsd GOARCH="$GOARCH" go build \
|
||||
-ldflags="-s -w -X main.Version=${RELEASE_VERSION} -X main.Commit=${COMMIT} -X main.BuildDate=${BUILD_DATE}" \
|
||||
-o "$archive_dir/cli-proxy-api" ./cmd/server/
|
||||
|
||||
cp LICENSE README.md README_CN.md config.example.yaml "$archive_dir/"
|
||||
tar -C "$archive_dir" -czf "dist/$archive_name" cli-proxy-api LICENSE README.md README_CN.md config.example.yaml
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: freebsd-${{ matrix.goarch }}
|
||||
path: dist/CLIProxyAPI_*
|
||||
if-no-files-found: error
|
||||
|
||||
publish-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- build-hosted
|
||||
- build-freebsd
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: dist
|
||||
merge-multiple: true
|
||||
- name: Create checksums
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd dist
|
||||
sha256sum CLIProxyAPI_* | sort -k2 > checksums.txt
|
||||
- name: Publish release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
VERSION: ${{ env.VERSION }}
|
||||
COMMIT: ${{ env.COMMIT }}
|
||||
BUILD_DATE: ${{ env.BUILD_DATE }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
|
||||
gh release upload "$GITHUB_REF_NAME" dist/* --clobber
|
||||
else
|
||||
gh release create "$GITHUB_REF_NAME" dist/* --title "$GITHUB_REF_NAME" --generate-notes
|
||||
fi
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
version: 2
|
||||
|
||||
builds:
|
||||
- id: "cli-proxy-api"
|
||||
env:
|
||||
- CGO_ENABLED=1
|
||||
- >-
|
||||
{{- if eq .Os "linux" }}
|
||||
{{- if eq .Arch "amd64" }}CC=zig cc -target x86_64-linux-gnu{{- end }}
|
||||
{{- if eq .Arch "arm64" }}CC=zig cc -target aarch64-linux-gnu{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "freebsd" }}
|
||||
{{- if eq .Arch "amd64" }}CC=zig cc -target x86_64-freebsd{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "windows" }}
|
||||
{{- if eq .Arch "amd64" }}CC=zig cc -target x86_64-windows-gnu{{- end }}
|
||||
{{- if eq .Arch "arm64" }}CC=zig cc -target aarch64-windows-gnu{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "darwin" }}CC=clang{{- end }}
|
||||
- >-
|
||||
{{- if eq .Os "linux" }}
|
||||
{{- if eq .Arch "amd64" }}CXX=zig c++ -target x86_64-linux-gnu{{- end }}
|
||||
{{- if eq .Arch "arm64" }}CXX=zig c++ -target aarch64-linux-gnu{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "freebsd" }}
|
||||
{{- if eq .Arch "amd64" }}CXX=zig c++ -target x86_64-freebsd{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "windows" }}
|
||||
{{- if eq .Arch "amd64" }}CXX=zig c++ -target x86_64-windows-gnu{{- end }}
|
||||
{{- if eq .Arch "arm64" }}CXX=zig c++ -target aarch64-windows-gnu{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .Os "darwin" }}CXX=clang++{{- end }}
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
- darwin
|
||||
- freebsd
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
ignore:
|
||||
- goos: freebsd
|
||||
goarch: arm64
|
||||
main: ./cmd/server/
|
||||
binary: cli-proxy-api
|
||||
ldflags:
|
||||
- -s -w -X 'main.Version={{.Version}}' -X 'main.Commit={{.ShortCommit}}' -X 'main.BuildDate={{.Date}}'
|
||||
archives:
|
||||
- id: "cli-proxy-api"
|
||||
formats:
|
||||
- tar.gz
|
||||
name_template: >-
|
||||
{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{- if eq .Arch "arm64" -}}aarch64{{- else -}}{{ .Arch }}{{- end -}}
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
formats:
|
||||
- zip
|
||||
files:
|
||||
- LICENSE
|
||||
- README.md
|
||||
- README_CN.md
|
||||
- config.example.yaml
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
|
||||
snapshot:
|
||||
version_template: "{{ incpatch .Version }}-next"
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^test:'
|
||||
Reference in New Issue
Block a user