refactor: simplify release workflow

This commit is contained in:
Chang lue Tsen 2025-04-25 16:40:57 +09:00
parent f45b128efa
commit 5f37d2727f
2 changed files with 32 additions and 84 deletions

View File

@ -15,7 +15,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git describe --tags
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
@ -32,10 +32,10 @@ jobs:
- name: Extract version from git tag
id: version
run: |
# Extract version from git tag (e.g., v1.2.3)
VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
echo "VERSION=$VERSION"
BUILD_NUMBER=$(echo $VERSION | tr -d '.' | sed 's/^0*//')
echo "BUILD_NUMBER=$BUILD_NUMBER"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
@ -54,7 +54,7 @@ jobs:
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.GIT_SHA }}
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.BUILD_NUMBER }}
- name: Build and push Docker image for beta release
if: contains(github.ref_name, 'beta')
@ -67,21 +67,21 @@ jobs:
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:beta
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-beta
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.GIT_SHA }}-beta
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.BUILD_NUMBER }}-beta
release-notes:
runs-on: ubuntu-latest
needs: build-docker # Ensure Docker image is built first
needs: build-docker
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for changelog generation
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21' # Match Dockerfile
go-version: '1.21'
- name: Install GoReleaser
run: |
@ -97,49 +97,43 @@ jobs:
releases-matrix:
name: Release ppanel-server binary
runs-on: ubuntu-latest
needs: release-notes # Wait for release-notes job
needs: release-notes
strategy:
matrix:
goos: [ linux, windows, darwin, freebsd ]
goos: [ linux, windows, darwin ]
goarch: [ '386', amd64, arm64 ]
exclude:
- goos: darwin
goarch: '386'
- goos: freebsd
goarch: '386' # FreeBSD 386 not in Makefile
include:
- goos: linux
goarch: arm
goarm: 5
target: linux-armv5
- goos: linux
goarch: arm
goarm: 6
target: linux-armv6
- goos: linux
goarch: arm
goarm: 7
target: linux-armv7
- goos: windows
goarch: arm
goarm: 7
target: windows-armv7
- goos: linux
goarch: mips
gomips: softfloat
- goos: linux
goarch: mips
gomips: hardfloat
- goos: linux
goarch: mipsle
gomips: softfloat
- goos: linux
goarch: mipsle
gomips: hardfloat
- goos: linux
goarch: mips64
- goos: linux
goarch: mips64le
- goos: linux
goarch: riscv64
- goos: linux
goarch: loong64
goarch: amd64
goamd64: v3
target: linux-amd64-v3
- goos: windows
goarch: amd64
goamd64: v3
target: windows-amd64-v3
- goos: darwin
goarch: amd64
goamd64: v3
target: darwin-amd64-v3
steps:
- name: Checkout repository
@ -148,7 +142,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21' # Match Dockerfile
go-version: '1.21'
- name: Build binary with Makefile
env:
@ -157,8 +151,10 @@ jobs:
GOARM: ${{ matrix.goarm }}
GOMIPS: ${{ matrix.gomips }}
run: |
make BINDIR=bin ${GOOS}-${GOARCH}${GOARM}${GOMIPS}
mv bin/ppanel-server-${GOOS}-${GOARCH}${GOARM}${GOMIPS}* ppanel-server${GOOS}-${GOARCH}${GOARM}${GOMIPS}
# Use default target for non-special architectures, otherwise use matrix.target
TARGET=${{ matrix.target != '' && matrix.target || format('{0}-{1}', matrix.goos, matrix.goarch) }}
make BINDIR=bin $TARGET
mv bin/ppanel-server-$TARGET* ppanel-server-$TARGET
- name: Upload release asset
uses: actions/upload-release-asset@v1
@ -166,8 +162,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ppanel-server${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}${{ matrix.gomips }}
asset_name: ppanel-server-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}${{ matrix.gomips }}${{ matrix.goos == 'windows' && '.exe' || '' }}
asset_path: ppanel-server-${{ matrix.target != '' && matrix.target || format('{0}-{1}', matrix.goos, matrix.goarch) }}
asset_name: ppanel-server-${{ matrix.target != '' && matrix.target || format('{0}-{1}', matrix.goos, matrix.goarch) }}${{ matrix.goos == 'windows' && '.exe' || '' }}
asset_content_type: application/octet-stream
- name: Upload additional files

View File

@ -17,18 +17,6 @@ PLATFORM_LIST = \
linux-armv6 \
linux-armv7 \
linux-arm64 \
linux-mips-softfloat \
linux-mips-hardfloat \
linux-mipsle-softfloat \
linux-mipsle-hardfloat \
linux-mips64 \
linux-mips64le \
linux-riscv64 \
linux-loong64 \
freebsd-386 \
freebsd-amd64 \
freebsd-amd64-v3 \
freebsd-arm64
WINDOWS_ARCH_LIST = \
windows-386 \
@ -69,42 +57,6 @@ linux-armv7:
linux-arm64:
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-mips-softfloat:
GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-mips-hardfloat:
GOARCH=mips GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-mipsle-softfloat:
GOARCH=mipsle GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-mipsle-hardfloat:
GOARCH=mipsle GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-mips64:
GOARCH=mips64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-mips64le:
GOARCH=mips64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-riscv64:
GOARCH=riscv64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-loong64:
GOARCH=loong64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
freebsd-386:
GOARCH=386 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
freebsd-amd64:
GOARCH=amd64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
freebsd-amd64-v3:
GOARCH=amd64 GOOS=freebsd GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
freebsd-arm64:
GOARCH=arm64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
windows-386:
GOARCH=386 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe