From 3381d5c7db92d4732511331d04f9d506dcdf3fcc Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Wed, 30 Nov 2022 22:24:23 +0800 Subject: [PATCH 1/7] ci: release ci --- .github/workflows/release.yml | 103 ++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..a8673e58 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,103 @@ +name: Make Distribution + +on: + workflow_dispatch: + push: + +jobs: + make_dist: + name: Make Distribution File(${{ matrix.os }}) + runs-on: ${{ matrix.os }}-latest + strategy: + fail-fast: false + matrix: + include: + - os: windows + filetag: win-x86_64 + - os: ubuntu + filetag: linux-x86_64 + - os: macos + filetag: macos-x86_64 + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: 7 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: | + mkdir dist + pushd frontend + pnpm install && pnpm build + popd + + - name: Make executable windows + if: matrix.os == 'windows' + run: | + cargo build --release -p zlib-searcher.exe + mv target/release/zlib-searcher dist + - name: Make executable linux + if: matrix.os != 'windows' + run: | + cargo build --release -p zlib-searcher + mv target/release/zlib-searcher dist + - name: Make dist(MacOS) + if: matrix.os == 'macos' + run: | + cargo build --release -p zlib-searcher + mv target/release/zlib-searcher dist + + - name: Archive Distribution Files + uses: actions/upload-artifact@v2 + with: + name: dist + path: downloads/* + + create_release: + name: Create GitHub Release + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + needs: make_dist + + steps: + - uses: actions/checkout@v3 + + - name: Get Dists + uses: actions/download-artifact@v2 + with: + name: dist + path: dist + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: dist/* + + - uses: actions/setup-node@v3 + with: + node-version: 16.x From 041645f0dfff9108bd5db4ac065a50bd63aab189 Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Wed, 30 Nov 2022 22:42:44 +0800 Subject: [PATCH 2/7] fix: build error --- .github/workflows/release.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a8673e58..66bfe07d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: filetag: macos-x86_64 steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 + - uses: actions-rs/toolchain@v2 with: toolchain: stable - name: Install Node.js @@ -56,21 +56,25 @@ jobs: pnpm install && pnpm build popd - - name: Make executable windows - if: matrix.os == 'windows' - run: | - cargo build --release -p zlib-searcher.exe - mv target/release/zlib-searcher dist - - name: Make executable linux - if: matrix.os != 'windows' + - name: Make executable run: | cargo build --release -p zlib-searcher - mv target/release/zlib-searcher dist + - name: Make dist(MacOS) if: matrix.os == 'macos' run: | - cargo build --release -p zlib-searcher - mv target/release/zlib-searcher dist + cp target/release/zlib-searcher . + zip zlib-searcher-macos.zip zlib-searcher && cp zlib-searcher-macos.zip dist/ + - name: Make dist(Windows) + if: matrix.os == 'windows' + run: | + cp target/release/zlib-searcher.exe . + zip zlib-searcher-windows.zip zlib-searcher.exe && cp zlib-searcher-windows.zip dist/ + - name: Make dist(Linux) + if: matrix.os == 'ubuntu' + run: | + cp target/release/zlib-searcher . + zip zlib-searcher-linux.zip zlib-searcher && cp zlib-searcher-linux.zip dist/ - name: Archive Distribution Files uses: actions/upload-artifact@v2 From 95cf13c1a69e471e1ab5bd33900021d40e20f1d8 Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Wed, 30 Nov 2022 22:46:40 +0800 Subject: [PATCH 3/7] fix: no v2 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 66bfe07d..12f69a55 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: filetag: macos-x86_64 steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v2 + - uses: actions-rs/toolchain@v1 with: toolchain: stable - name: Install Node.js From 6412813e0b60b17521db6ab8cfba04aa0ee376fe Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Wed, 30 Nov 2022 23:06:22 +0800 Subject: [PATCH 4/7] fix: windows no zip --- .github/workflows/release.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 12f69a55..44c144b8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,9 +20,7 @@ jobs: filetag: macos-x86_64 steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable + - uses: dtolnay/rust-toolchain@stable - name: Install Node.js uses: actions/setup-node@v3 with: @@ -69,7 +67,7 @@ jobs: if: matrix.os == 'windows' run: | cp target/release/zlib-searcher.exe . - zip zlib-searcher-windows.zip zlib-searcher.exe && cp zlib-searcher-windows.zip dist/ + Compress-Archive -Path zlib-searcher.exe -DestinationPath dist/zlib-searcher-windows.zip - name: Make dist(Linux) if: matrix.os == 'ubuntu' run: | From 644e4767b9c1a0ac34922d110833036f050496e0 Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Wed, 30 Nov 2022 23:23:12 +0800 Subject: [PATCH 5/7] fix: dir name --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 44c144b8..7b64cb23 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,7 +78,7 @@ jobs: uses: actions/upload-artifact@v2 with: name: dist - path: downloads/* + path: dist/* create_release: name: Create GitHub Release From 1ee141a5d70a203997fa2ab55980c0baadb390b0 Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Wed, 30 Nov 2022 23:43:49 +0800 Subject: [PATCH 6/7] fix: new tag then release --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7b64cb23..eff98a4a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,8 @@ name: Make Distribution on: workflow_dispatch: push: + tags: + - "*" jobs: make_dist: From 5ac10e926a69df656889ab400cc59929879ba0f6 Mon Sep 17 00:00:00 2001 From: zu1k Date: Sun, 1 Jan 2023 19:15:15 +0800 Subject: [PATCH 7/7] chore: add release ci --- .github/workflows/release.yml | 107 +++++++++++++--------------------- Makefile | 3 + scripts/build_release.sh | 42 +++++++++---- 3 files changed, 73 insertions(+), 79 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eff98a4a..3e9bd5e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,46 +1,39 @@ -name: Make Distribution - +name: Build Releases on: - workflow_dispatch: - push: - tags: - - "*" + release: + types: [published] + +env: + CARGO_TERM_COLOR: always + AUTH_SERVER_IP: ${{ secrets.AUTH_SERVER_IP }} + jobs: make_dist: - name: Make Distribution File(${{ matrix.os }}) - runs-on: ${{ matrix.os }}-latest + name: Build Release on (${{ matrix.platform }}) strategy: fail-fast: false matrix: - include: - - os: windows - filetag: win-x86_64 - - os: ubuntu - filetag: linux-x86_64 - - os: macos - filetag: macos-x86_64 + platform: [macos-latest, ubuntu-20.04, windows-latest] + runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable + - name: Install Node.js uses: actions/setup-node@v3 with: node-version: 16 - - uses: pnpm/action-setup@v2 name: Install pnpm id: pnpm-install with: version: 7 run_install: false - - name: Get pnpm store directory id: pnpm-cache shell: bash run: | echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 name: Setup pnpm cache with: @@ -48,60 +41,38 @@ jobs: key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-store- - - name: Install dependencies run: | - mkdir dist - pushd frontend - pnpm install && pnpm build - popd - - - name: Make executable + make frontend_preinstall + - name: Build dist run: | - cargo build --release -p zlib-searcher - - - name: Make dist(MacOS) - if: matrix.os == 'macos' + make frontend + - name: Build on Linux + if: matrix.platform == 'ubuntu-20.04' run: | - cp target/release/zlib-searcher . - zip zlib-searcher-macos.zip zlib-searcher && cp zlib-searcher-macos.zip dist/ - - name: Make dist(Windows) - if: matrix.os == 'windows' + cargo install cross + make releases + - name: Build on MacOS + if: matrix.platform == 'macos-latest' run: | - cp target/release/zlib-searcher.exe . - Compress-Archive -Path zlib-searcher.exe -DestinationPath dist/zlib-searcher-windows.zip - - name: Make dist(Linux) - if: matrix.os == 'ubuntu' + mkdir -p target/dist + rustup target add x86_64-apple-darwin + cargo build --release --target x86_64-apple-darwin -p zlib-searcher + cd target/x86_64-apple-darwin/release && zip zlib-searcher-x86_64-apple-darwin.zip zlib-searcher && cp zlib-searcher-x86_64-apple-darwin.zip ../../dist/ && cd ../../../ + rustup target add aarch64-apple-darwin + cargo build --release --target aarch64-apple-darwin -p zlib-searcher + cd target/aarch64-apple-darwin/release && zip zlib-searcher-aarch64-apple-darwin.zip zlib-searcher && cp zlib-searcher-aarch64-apple-darwin.zip ../../dist/ && cd ../../../ + - name: Build on Windows + if: matrix.platform == 'windows-latest' run: | - cp target/release/zlib-searcher . - zip zlib-searcher-linux.zip zlib-searcher && cp zlib-searcher-linux.zip dist/ - - - name: Archive Distribution Files - uses: actions/upload-artifact@v2 - with: - name: dist - path: dist/* - - create_release: - name: Create GitHub Release - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - needs: make_dist - - steps: - - uses: actions/checkout@v3 - - - name: Get Dists - uses: actions/download-artifact@v2 - with: - name: dist - path: dist - - - name: Create GitHub Release + mkdir -p target/dist + rustup target add x86_64-pc-windows-msvc + cargo build --release --target x86_64-pc-windows-msvc -p zlib-searcher + cd target/x86_64-pc-windows-msvc/release && Compress-Archive -Path zlib-searcher.exe -DestinationPath zlib-searcher-x86_64-pc-windows-msvc.zip && cp zlib-searcher-x86_64-pc-windows-msvc.zip ../../dist/ && cd ../../../ + - name: Upload Github Assets uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - files: dist/* - - - uses: actions/setup-node@v3 - with: - node-version: 16.x + files: target/dist/* + prerelease: ${{ contains(github.ref, '-') }} diff --git a/Makefile b/Makefile index 9100ac13..66df8fa8 100644 --- a/Makefile +++ b/Makefile @@ -22,3 +22,6 @@ endif clean: cargo clean rm -rf release + +releases: + cd scripts && ./build_release.sh -a a diff --git a/scripts/build_release.sh b/scripts/build_release.sh index be4e1ddf..b871dbe3 100755 --- a/scripts/build_release.sh +++ b/scripts/build_release.sh @@ -6,7 +6,22 @@ project=zlib-searcher targets=() features=() -while getopts "t:f:u" opt; do +ALL_TARGETS=" +i686-unknown-linux-musl +x86_64-pc-windows-gnu +x86_64-unknown-linux-gnu +x86_64-unknown-linux-musl +armv7-unknown-linux-musleabihf +armv7-unknown-linux-gnueabihf +arm-unknown-linux-gnueabi +arm-unknown-linux-gnueabihf +arm-unknown-linux-musleabi +arm-unknown-linux-musleabihf +aarch64-unknown-linux-gnu +aarch64-unknown-linux-musl +" + +while getopts "p:t:a:f" opt; do case $opt in p) project=($OPTARG) @@ -14,6 +29,9 @@ while getopts "t:f:u" opt; do t) targets+=($OPTARG) ;; + a) + targets+=($ALL_TARGETS) + ;; f) features+=($OPTARG) ;; @@ -44,11 +62,13 @@ function build() { cross build --target "${TARGET}" \ --default-features=false --features "${TARGET_FEATURES}" \ + -p zlib-searcher \ --release else echo "* Building ${project} package for ${TARGET} ..." cross build --target "${TARGET}" \ + -p zlib-searcher \ --release fi @@ -59,14 +79,13 @@ function build() { PKG_DIR="${CUR_DIR}/../release" mkdir -p "${PKG_DIR}" - if [[ "$TARGET" == *"-linux-"* ]]; then - PKG_NAME="${project}-${TARGET}.tar.gz" + if [[ "$TARGET" == *"-windows-"* ]]; then + PKG_NAME="${project}-${TARGET}.zip" PKG_PATH="${PKG_DIR}/${PKG_NAME}" + echo "* Packaging ZIP in ${PKG_PATH} ..." cd ${RELEASE_DIR} - - echo "* Packaging gz in ${PKG_PATH} ..." - tar -czf ${PKG_PATH} ${project} + zip ${PKG_PATH} ${project}.exe if [[ $? != "0" ]]; then exit 1 @@ -74,13 +93,14 @@ function build() { cd "${PKG_DIR}" shasum -a 256 "${PKG_NAME}" > "${PKG_NAME}.sha256" - elif [[ "$TARGET" == *"-windows-"* ]]; then - PKG_NAME="${project}-${TARGET}.zip" + else + PKG_NAME="${project}-${TARGET}.tar.gz" PKG_PATH="${PKG_DIR}/${PKG_NAME}" - echo "* Packaging ZIP in ${PKG_PATH} ..." cd ${RELEASE_DIR} - zip ${PKG_PATH} ${project}.exe + + echo "* Packaging gz in ${PKG_PATH} ..." + tar -czf ${PKG_PATH} ${project} if [[ $? != "0" ]]; then exit 1 @@ -96,4 +116,4 @@ function build() { for target in "${targets[@]}"; do cargo clean; build "$target"; -done \ No newline at end of file +done