@@ -2,7 +2,17 @@ name: build
22
33on :
44 workflow_call :
5+ inputs :
6+ version :
7+ description : " Version tag for release packaging"
8+ required : false
9+ type : string
510 workflow_dispatch :
11+ inputs :
12+ version :
13+ description : " Version tag for release packaging"
14+ required : false
15+ type : string
616
717concurrency :
818 group : build-${{ github.head_ref }}
@@ -34,23 +44,34 @@ jobs:
3444 with :
3545 persist-credentials : false
3646
37- - name : Prepare target
47+ - name : Prepare target and platform identifiers
3848 shell : bash
3949 env :
40- RUNNER_OS : ${{ runner.os }}
4150 PLATFORM_TARGET : ${{ matrix.platform.target }}
51+ RUNNER_OS : ${{ runner.os }}
4252 run : |
43- target="${ PLATFORM_TARGET} "
53+ target="$PLATFORM_TARGET"
4454
45- if [[ "${ RUNNER_OS} " == "Linux" ]]; then
55+ if [[ "$RUNNER_OS" == "Linux" ]]; then
4656 target+="-unknown-linux-gnu"
47- elif [[ "${RUNNER_OS}" == "macOS" ]]; then
57+ os="linux"
58+ elif [[ "$RUNNER_OS" == "macOS" ]]; then
4859 target+="-apple-darwin"
49- elif [[ "${RUNNER_OS}" == "Windows" ]]; then
60+ os="darwin"
61+ elif [[ "$RUNNER_OS" == "Windows" ]]; then
5062 target+="-pc-windows-msvc"
63+ os="windows"
64+ fi
65+
66+ if [[ "$PLATFORM_TARGET" == "x86_64" ]]; then
67+ arch="x64"
68+ elif [[ "$PLATFORM_TARGET" == "aarch64" ]]; then
69+ arch="arm64"
5170 fi
5271
5372 echo "TARGET=${target}" >> $GITHUB_ENV
73+ echo "OS=${os:-'unknown'}" >> $GITHUB_ENV
74+ echo "ARCH=${arch:-'unknown'}" >> $GITHUB_ENV
5475
5576 - uses : actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
5677 with :
6889 key : ${{ runner.os }}-zig-toolchain-${{ env.ZIG_VERSION }}
6990
7091 - name : Install Zig and cargo-zigbuild
71- if : ${{ runner.os == 'Linux' && matrix.platform.target == 'aarch64' && steps.cache-zig. outputs.cache-hit != 'true' }}
92+ if : ${{ runner.os == 'Linux' && matrix.platform.target == 'aarch64' && steps.cache-zig.outputs.cache-hit != 'true' }}
7293 shell : bash
7394 run : |
7495 wget -q "https://ziglang.org/download/${ZIG_VERSION}/zig-linux-x86_64-${ZIG_VERSION}.tar.xz"
@@ -78,75 +99,82 @@ jobs:
7899 - name : Add Zig to PATH
79100 if : ${{ runner.os == 'Linux' && matrix.platform.target == 'aarch64' }}
80101 shell : bash
81- run : echo "$PWD/zig-linux-x86_64-${ZIG_VERSION}" >> $GITHUB_PATH
102+ run : echo "${ PWD} /zig-linux-x86_64-${ZIG_VERSION}" >> $GITHUB_PATH
82103
83104 - name : Build release binary
84105 shell : bash
85106 env :
86107 RUNNER_OS : ${{ runner.os }}
87- PLATFORM_TARGET : ${{ matrix.platform.target }}
88- PLATFORM_RUNNER : ${{ matrix.platform.runner }}
89108 run : |
90- if [[ "${ RUNNER_OS} " == "Linux" && "${PLATFORM_TARGET} " == " aarch64" ]]; then
91- cargo zigbuild --release --target "${TARGET} "
109+ if [[ "$RUNNER_OS" == "Linux" && "$TARGET " == aarch64* ]]; then
110+ build_command="zigbuild "
92111 else
93- cargo build --verbose --release --target "${TARGET} "
112+ build_command="build "
94113 fi
95114
96- if [[ "${PLATFORM_RUNNER}" == windows-* ]]; then
115+ cargo "$build_command" --verbose --release --target "$TARGET"
116+
117+ if [[ "$RUNNER_OS" == "Windows" ]]; then
97118 bin="./target/${TARGET}/release/djls.exe"
98119 else
99120 bin="./target/${TARGET}/release/djls"
100121 fi
101122
102123 echo "BIN=${bin}" >> $GITHUB_ENV
103-
104- - name : Determine binary name
105- shell : bash
106- run : |
107- target="${TARGET}"
108- name="djls"
109-
110- if [[ "$target" == *linux* ]]; then
111- name+="-linux"
112- elif [[ "$target" == *apple* ]]; then
113- name+="-darwin"
114- elif [[ "$target" == *windows* ]]; then
115- name+="-windows"
116- fi
117-
118- if [[ "$target" == x86_64* ]]; then
119- name+="-x64"
120- elif [[ "$target" == aarch64* ]]; then
121- name+="-arm64"
122- fi
123-
124- if [[ "$target" == *windows* ]]; then
125- name+=".exe"
126- fi
127-
128- echo "BINARY_NAME=${name}" >> $GITHUB_ENV
124+ echo "ARTIFACT_PATH=${bin}" >> $GITHUB_ENV
129125
130126 - name : Strip release binary (Unix)
131127 if : ${{ runner.os != 'Windows' }}
132128 shell : bash
133129 env :
134130 RUNNER_OS : ${{ runner.os }}
135- PLATFORM_TARGET : ${{ matrix.platform.target }}
136131 run : |
137- if [[ "${ RUNNER_OS} " == "Linux" && "${PLATFORM_TARGET} " == " aarch64" ]]; then
132+ if [[ "$RUNNER_OS" == "Linux" && "$TARGET " == aarch64* ]]; then
138133 sudo apt-get update
139134 sudo apt-get install -y binutils-aarch64-linux-gnu
140- aarch64-linux-gnu-strip "${ BIN} "
135+ aarch64-linux-gnu-strip "$BIN"
141136 else
142- strip "${ BIN} "
137+ strip "$BIN"
143138 fi
144139
140+ - name : Package for release
141+ if : ${{ inputs.version != '' }}
142+ shell : bash
143+ env :
144+ RUNNER_OS : ${{ runner.os }}
145+ VERSION : ${{ inputs.version }}
146+ run : |
147+ archive_name="djls-${VERSION}-${OS}-${ARCH}"
148+
149+ mkdir -p "$archive_name"
150+
151+ if [[ "$RUNNER_OS" == "Windows" ]]; then
152+ cp "$BIN" "$archive_name/djls.exe"
153+ else
154+ cp "$BIN" "$archive_name/djls"
155+ fi
156+
157+ cp README.md "$archive_name/"
158+ cp LICENSE "$archive_name/"
159+ cp CHANGELOG.md "$archive_name/"
160+
161+ if [[ "$RUNNER_OS" == "Windows" ]]; then
162+ 7z a "${archive_name}.zip" "$archive_name"
163+ sha256sum "${archive_name}.zip" > "${archive_name}.zip.sha256"
164+ echo "ARTIFACT_PATH=${archive_name}.zip*" >> $GITHUB_ENV
165+ else
166+ tar czf "${archive_name}.tar.gz" "$archive_name"
167+ sha256sum "${archive_name}.tar.gz" > "${archive_name}.tar.gz.sha256"
168+ echo "ARTIFACT_PATH=${archive_name}.tar.gz*" >> $GITHUB_ENV
169+ fi
170+
171+ rm -rf "$archive_name"
172+
145173 - name : Upload binary
146174 uses : actions/upload-artifact@v4
147175 with :
148- name : binary-${{ env.BINARY_NAME }}
149- path : ${{ env.BIN }}
176+ name : binary-${{ env.OS }}-${{ env.ARCH }}
177+ path : ${{ env.ARTIFACT_PATH }}
150178
151179 linux :
152180 runs-on : ${{ matrix.platform.runner }}
@@ -343,3 +371,20 @@ jobs:
343371 with :
344372 name : wheels-sdist
345373 path : dist
374+
375+ attest :
376+ runs-on : ubuntu-latest
377+ if : ${{ inputs.version != '' }}
378+ needs : [binary, linux, musllinux, windows, macos, sdist]
379+ permissions :
380+ id-token : write
381+ attestations : write
382+ steps :
383+ - uses : actions/download-artifact@v5
384+
385+ - name : Generate artifact attestation
386+ uses : actions/attest-build-provenance@v3
387+ with :
388+ subject-path : |
389+ binary-*/*
390+ wheels-*/*
0 commit comments