Skip to content

Commit

Permalink
refactor zip file directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed Sep 28, 2024
1 parent e9fc9d3 commit 408a2d7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
28 changes: 21 additions & 7 deletions .github/build-release.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#!/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}"
rm -rf "${OUT_DIR}"
}

mkdir -p "${out_dir}"
mkdir -p "${OUT_DIR}"
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)

cd "${script_dir}/.."
Expand All @@ -28,11 +30,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
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ jobs:
- name: Set env
run: |
echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
echo "OUT_DIR=/tmp/zigcli-release" >> $GITHUB_ENV
- name: Install
uses: pandoc/actions/setup@v1
with:
version: 2.19
- name: Build
run: |
bash .github/build-release.sh
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: /tmp/zigcli-release/*
files: ${{ env.OUT_DIR }}/*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.zig-cache
*lock
docs/resources
docs/public
docs/public
README.md
5 changes: 3 additions & 2 deletions docs/content/programs/_index.org
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 408a2d7

Please sign in to comment.