From 3c66db9845cd6e990230fcd2cfb39ae92872815e Mon Sep 17 00:00:00 2001 From: Andy Hsu Date: Sun, 3 Sep 2023 22:53:58 +0800 Subject: [PATCH] ci: split release actions --- .github/workflows/release_linux_musl.yml | 34 ++++++++++++++++++++ .github/workflows/release_linux_musl_arm.yml | 2 +- build.sh | 22 +++++++++---- 3 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/release_linux_musl.yml diff --git a/.github/workflows/release_linux_musl.yml b/.github/workflows/release_linux_musl.yml new file mode 100644 index 00000000000..dd298c49b43 --- /dev/null +++ b/.github/workflows/release_linux_musl.yml @@ -0,0 +1,34 @@ +name: release_linux_musl + +on: + release: + types: [ published ] + +jobs: + release_linux_musl: + strategy: + matrix: + platform: [ ubuntu-latest ] + go-version: [ '1.20' ] + name: Release + runs-on: ${{ matrix.platform }} + steps: + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Build + run: | + bash build.sh release linux_musl + + - name: Upload assets + uses: softprops/action-gh-release@v1 + with: + files: build/compress/* diff --git a/.github/workflows/release_linux_musl_arm.yml b/.github/workflows/release_linux_musl_arm.yml index 4d424507d78..f5e69c1c81b 100644 --- a/.github/workflows/release_linux_musl_arm.yml +++ b/.github/workflows/release_linux_musl_arm.yml @@ -5,7 +5,7 @@ on: types: [ published ] jobs: - release_arm: + release_linux_musl_arm: strategy: matrix: platform: [ ubuntu-latest ] diff --git a/build.sh b/build.sh index 7847b568eab..7ca010a7a14 100644 --- a/build.sh +++ b/build.sh @@ -89,6 +89,18 @@ BuildDocker() { } BuildRelease() { + rm -rf .git/ + mkdir -p "build" + BuildWinArm64 ./build/alist-windows-arm64.exe + xgo -out "$appName" -ldflags="$ldflags" -tags=jsoniter . + # why? Because some target platforms seem to have issues with upx compression + upx -9 ./alist-linux-amd64 + cp ./alist-windows-amd64.exe ./alist-windows-amd64-upx.exe + upx -9 ./alist-windows-amd64-upx.exe + mv alist-* build +} + +BuildReleaseLinuxMusl() { rm -rf .git/ mkdir -p "build" muslflags="--extldflags '-static -fpic' $ldflags" @@ -112,13 +124,6 @@ BuildRelease() { export CGO_ENABLED=1 go build -o ./build/$appName-$os_arch -ldflags="$muslflags" -tags=jsoniter . done - BuildWinArm64 ./build/alist-windows-arm64.exe - xgo -out "$appName" -ldflags="$ldflags" -tags=jsoniter . - # why? Because some target platforms seem to have issues with upx compression - upx -9 ./alist-linux-amd64 - cp ./alist-windows-amd64.exe ./alist-windows-amd64-upx.exe - upx -9 ./alist-windows-amd64-upx.exe - mv alist-* build } BuildReleaseLinuxMuslArm() { @@ -192,6 +197,9 @@ elif [ "$1" = "release" ]; then elif [ "$2" = "linux_musl_arm" ]; then BuildReleaseLinuxMuslArm MakeRelease "md5-linux-musl-arm.txt" + elif [ "$2" = "linux_musl" ]; then + BuildReleaseLinuxMusl + MakeRelease "md5-linux-musl.txt" else BuildRelease MakeRelease "md5.txt"