Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: release pipeline for #5 #25

Merged
merged 8 commits into from
Jan 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build Releases
on:
release:
types: [published]

env:
CARGO_TERM_COLOR: always
AUTH_SERVER_IP: ${{ secrets.AUTH_SERVER_IP }}


jobs:
make_dist:
name: Build Release on (${{ matrix.platform }})
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3

- 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: |
make frontend_preinstall
- name: Build dist
run: |
make frontend
- name: Build on Linux
if: matrix.platform == 'ubuntu-20.04'
run: |
cargo install cross
make releases
- name: Build on MacOS
if: matrix.platform == 'macos-latest'
run: |
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: |
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: target/dist/*
prerelease: ${{ contains(github.ref, '-') }}
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ endif
clean:
cargo clean
rm -rf release

releases:
cd scripts && ./build_release.sh -a a
42 changes: 31 additions & 11 deletions scripts/build_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,32 @@ 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)
;;
t)
targets+=($OPTARG)
;;
a)
targets+=($ALL_TARGETS)
;;
f)
features+=($OPTARG)
;;
Expand Down Expand Up @@ -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

Expand All @@ -59,28 +79,28 @@ 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
fi

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
Expand All @@ -96,4 +116,4 @@ function build() {
for target in "${targets[@]}"; do
cargo clean;
build "$target";
done
done