Skip to content

Commit

Permalink
上传静态链接的二进制文件
Browse files Browse the repository at this point in the history
  • Loading branch information
lanthora committed Jun 11, 2024
1 parent e77eae1 commit c40ab1a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/standalone.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: standalone

on:
workflow_dispatch
workflow_dispatch:
release:
types: [ published ]

jobs:
build:
Expand Down Expand Up @@ -29,8 +31,22 @@ jobs:
CANDY_ARCH: ${{ matrix.arch }}
CANDY_STRIP: "1"
CANDY_UPX: "1"
CANDY_TGZ: "1"
- name: upload
uses: actions/upload-artifact@v4
with:
name: candy-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ env.WORKSPACE }}/output/${{ matrix.os }}-${{ matrix.arch }}
- name: prepare package
shell: bash
if: github.event_name == 'release'
run: |
GIT_TAG=${{ github.event.release.tag_name }}
PKG_PATH=${{ env.WORKSPACE }}/output/candy_${GIT_TAG#v}+${{ matrix.os }}_${{ matrix.arch }}.tar.gz
mv ${{ env.WORKSPACE }}/output/candy-${{ matrix.os }}-${{ matrix.arch }}.tar.gz $PKG_PATH
echo "PKG_PATH=$PKG_PATH" >> $GITHUB_ENV
- name: release
uses: softprops/action-gh-release@v2
if: github.event_name == 'release'
with:
files: ${{ env.PKG_PATH }}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18.4)

project(candy LANGUAGES C CXX VERSION 5.8.7)
project(candy LANGUAGES C CXX VERSION 5.8.8)

option(CANDY_NOEXE "Don't build executable")
option(CANDY_DEVEL "Build development library")
Expand Down
16 changes: 11 additions & 5 deletions scripts/build-standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ if [[ -z $TARGET || -z $TARGET_OPENSSL ]];then
echo "CANDY_OS: $CANDY_OS"
if [[ "$CANDY_OS" == "linux" ]]; then
if [[ "$CANDY_ARCH" == "aarch64" ]]; then TARGET="aarch64-linux-musl";TARGET_OPENSSL="linux-aarch64";UPX=1
elif [[ "$CANDY_ARCH" == "arm" ]]; then TARGET="arm-linux-musleabi";TARGET_OPENSSL="linux-armv4";UPX=0
elif [[ "$CANDY_ARCH" == "mips" ]]; then TARGET="mips-linux-musl";TARGET_OPENSSL="linux-mips32";UPX=0
elif [[ "$CANDY_ARCH" == "mipsel" ]]; then TARGET="mipsel-linux-musl";TARGET_OPENSSL="linux-mips32";UPX=0
elif [[ "$CANDY_ARCH" == "arm" ]]; then TARGET="arm-linux-musleabi";TARGET_OPENSSL="linux-armv4";UPX=1
elif [[ "$CANDY_ARCH" == "mips" ]]; then TARGET="mips-linux-musl";TARGET_OPENSSL="linux-mips32";UPX=1
elif [[ "$CANDY_ARCH" == "mipsel" ]]; then TARGET="mipsel-linux-musl";TARGET_OPENSSL="linux-mips32";UPX=1
elif [[ "$CANDY_ARCH" == "x86_64" ]]; then TARGET="x86_64-linux-musl";TARGET_OPENSSL="linux-x86_64";UPX=1
else echo "Unknown CANDY_ARCH: $CANDY_ARCH";exit 1;fi
elif [[ "$CANDY_OS" == "macos" ]]; then
Expand Down Expand Up @@ -55,13 +55,19 @@ fi

if which ninja >/dev/null 2>&1;then GENERATOR="Ninja";else GENERATOR="Unix Makefiles";fi
SOURCE_DIR="$(dirname $(readlink -f "$0"))/../"
cmake -G "$GENERATOR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DCANDY_STATIC=1 -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$OUTPUT_DIR -DTARGET_OPENSSL=$TARGET_OPENSSL $SOURCE_DIR
cmake -G "$GENERATOR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DCANDY_STATIC=1 -DTARGET_OPENSSL=$TARGET_OPENSSL $SOURCE_DIR
cmake --build $BUILD_DIR --parallel $(nproc)
mkdir -p $OUTPUT_DIR && cp $BUILD_DIR/src/main/candy $OUTPUT_DIR/candy

if [[ $CANDY_STRIP && $CANDY_STRIP -eq 1 ]];then
$STRIP $OUTPUT_DIR/candy
fi

if [[ $CANDY_UPX && $CANDY_UPX -eq 1 && $UPX -eq 1 ]];then
upx $OUTPUT_DIR/candy
upx --lzma --best -q $OUTPUT_DIR/candy
fi

if [[ $CANDY_TGZ && $CANDY_TGZ -eq 1 && $CANDY_OS && $CANDY_ARCH ]];then
cp $SOURCE_DIR/candy.cfg $OUTPUT_DIR/candy.cfg
tar zcvf $CANDY_WORKSPACE/output/candy-$CANDY_OS-$CANDY_ARCH.tar.gz -C $OUTPUT_DIR candy candy.cfg
fi

0 comments on commit c40ab1a

Please sign in to comment.