Skip to content

Commit 408a2d7

Browse files
committed
refactor zip file directory structure
1 parent e9fc9d3 commit 408a2d7

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

.github/build-release.sh

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
#!/usr/bin/env bash
22

3-
out_dir="/tmp/zigcli-release/"
4-
version=${RELEASE_VERSION:-unknown}
3+
OUT_DIR=${OUT_DIR:-/tmp/zigcli}
4+
VERSION=${RELEASE_VERSION:-unknown}
5+
6+
echo "Building zigcli ${VERSION} to ${OUT_DIR}..."
57

68
set -Eeuo pipefail
79
trap cleanup SIGINT SIGTERM ERR EXIT
810
cleanup() {
911
trap - SIGINT SIGTERM ERR EXIT
10-
ls -ltrh "${out_dir}"
11-
rm -rf "${out_dir}/*"
12+
ls -ltrh "${OUT_DIR}"
13+
rm -rf "${OUT_DIR}"
1214
}
1315

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

1719
cd "${script_dir}/.."
@@ -28,11 +30,23 @@ targets=(
2830
export BUILD_DATE=$(date +'%Y-%m-%dT%H:%M:%S%z')
2931
export GIT_COMMIT=$(git rev-parse --short HEAD)
3032

33+
pandoc -f org -t markdown README.org -o README.md
34+
3135
for target in "${targets[@]}"; do
3236
echo "Building for ${target}..."
33-
zig build -Doptimize=ReleaseSafe -Dtarget="${target}" \
37+
filename=zigcli-${VERSION}-${target}
38+
dst_dir=zig-out/${filename}
39+
40+
# 1. Build
41+
zig build -Doptimize=ReleaseSafe -Dtarget="${target}" -p ${dst_dir} \
3442
-Dgit_commit=${GIT_COMMIT} -Dbuild_date=${BUILD_DATE} -Dis_ci=true
43+
44+
# 2. Prepare files
45+
rm -f ${dst_dir}/bin/*demo
46+
cp LICENSE README.md ${dst_dir}
47+
48+
# 3. Zip final file
3549
pushd zig-out
36-
zip -r zigcli-${version}-${target}.zip bin ../LICENSE ../README.org
50+
zip -r ${OUT_DIR}/${filename}.zip "${filename}"
3751
popd
3852
done

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ jobs:
2121
- name: Set env
2222
run: |
2323
echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
24+
echo "OUT_DIR=/tmp/zigcli-release" >> $GITHUB_ENV
25+
- name: Install
26+
uses: pandoc/actions/setup@v1
27+
with:
28+
version: 2.19
2429
- name: Build
2530
run: |
2631
bash .github/build-release.sh
2732
- name: Release
2833
uses: softprops/action-gh-release@v2
2934
if: startsWith(github.ref, 'refs/tags/')
3035
with:
31-
files: /tmp/zigcli-release/*
36+
files: ${{ env.OUT_DIR }}/*

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/.zig-cache
44
*lock
55
docs/resources
6-
docs/public
6+
docs/public
7+
README.md

docs/content/programs/_index.org

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#+TITLE: Programs
22
#+DATE: 2023-10-21T12:26:45+0800
3-
#+LASTMOD: 2024-09-01T09:57:50+0800
3+
#+LASTMOD: 2024-09-28T11:50:42+0800
44
#+TYPE: docs
55
#+WEIGHT: 20
66
#+DESCRIPTION: Binary programs which can be used directly
77

88
* Install
9-
Prebuilt binaries can be found in [[https://github.com/jiacai2050/zigcli/actions/workflows/binary.yml][CI's artifacts]], or you can build from source:
9+
Latest pre-built binaries can be downloaded on the [[https://github.com/jiacai2050/zigcli/releases][release page]], or you can build from source:
10+
1011
#+begin_src bash
1112
git clone https://github.com/jiacai2050/zigcli.git
1213
#+end_src

0 commit comments

Comments
 (0)