From 9e01903d3286deb70ac43296071193fc5f899772 Mon Sep 17 00:00:00 2001 From: jiacai2050 Date: Sat, 28 Sep 2024 11:35:16 +0800 Subject: [PATCH] refactor zip file directory structure --- .github/build-release.sh | 27 ++++++++++++++++++++------- .github/workflows/release.yml | 7 ++++++- .gitignore | 3 ++- docs/content/programs/_index.org | 5 +++-- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.github/build-release.sh b/.github/build-release.sh index 44fe145..4c04332 100755 --- a/.github/build-release.sh +++ b/.github/build-release.sh @@ -1,17 +1,18 @@ #!/usr/bin/env bash -out_dir="/tmp/zigcli-release/" -version=${RELEASE_VERSION:-unknown} +OUT_DIR=${OUT_DIR:-/tmp/zigcli} +VERSION=${RELEASE_VERSION:-unknown} + +echo "Building zigcli ${VERSION} to ${OUT_DIR}..." set -Eeuo pipefail trap cleanup SIGINT SIGTERM ERR EXIT cleanup() { trap - SIGINT SIGTERM ERR EXIT - ls -ltrh "${out_dir}" - rm -rf "${out_dir}/*" + ls -ltrh "${OUT_DIR}" } -mkdir -p "${out_dir}" +mkdir -p "${OUT_DIR}" script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) cd "${script_dir}/.." @@ -28,11 +29,23 @@ targets=( export BUILD_DATE=$(date +'%Y-%m-%dT%H:%M:%S%z') export GIT_COMMIT=$(git rev-parse --short HEAD) +pandoc -f org -t markdown README.org -o README.md + for target in "${targets[@]}"; do echo "Building for ${target}..." - zig build -Doptimize=ReleaseSafe -Dtarget="${target}" \ + filename=zigcli-${VERSION}-${target} + dst_dir=zig-out/${filename} + + # 1. Build + zig build -Doptimize=ReleaseSafe -Dtarget="${target}" -p ${dst_dir} \ -Dgit_commit=${GIT_COMMIT} -Dbuild_date=${BUILD_DATE} -Dis_ci=true + + # 2. Prepare files + rm -f ${dst_dir}/bin/*demo + cp LICENSE README.md ${dst_dir} + + # 3. Zip final file pushd zig-out - zip -r zigcli-${version}-${target}.zip bin ../LICENSE ../README.org + zip -r ${OUT_DIR}/${filename}.zip "${filename}" popd done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dac49d8..d83d0c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,11 @@ jobs: - name: Set env run: | echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + echo "OUT_DIR=/tmp/zigcli-${{ github.ref_name }}" >> $GITHUB_ENV + - name: Install + uses: pandoc/actions/setup@v1 + with: + version: 2.19 - name: Build run: | bash .github/build-release.sh @@ -28,4 +33,4 @@ jobs: uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') with: - files: /tmp/zigcli-release/* + files: ${{ env.OUT_DIR }}/* diff --git a/.gitignore b/.gitignore index 256dc69..c042e8e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /.zig-cache *lock docs/resources -docs/public \ No newline at end of file +docs/public +README.md \ No newline at end of file diff --git a/docs/content/programs/_index.org b/docs/content/programs/_index.org index e4f71d7..07c2270 100644 --- a/docs/content/programs/_index.org +++ b/docs/content/programs/_index.org @@ -1,12 +1,13 @@ #+TITLE: Programs #+DATE: 2023-10-21T12:26:45+0800 -#+LASTMOD: 2024-09-01T09:57:50+0800 +#+LASTMOD: 2024-09-28T11:50:42+0800 #+TYPE: docs #+WEIGHT: 20 #+DESCRIPTION: Binary programs which can be used directly * Install -Prebuilt binaries can be found in [[https://github.com/jiacai2050/zigcli/actions/workflows/binary.yml][CI's artifacts]], or you can build from source: +Latest pre-built binaries can be downloaded on the [[https://github.com/jiacai2050/zigcli/releases][release page]], or you can build from source: + #+begin_src bash git clone https://github.com/jiacai2050/zigcli.git #+end_src