Skip to content

Commit 23bb0f5

Browse files
zizmor!
1 parent b5739bb commit 23bb0f5

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,27 @@ jobs:
3535
persist-credentials: false
3636

3737
- name: Prepare target
38-
id: target
3938
shell: bash
39+
env:
40+
RUNNER_OS: ${{ runner.os }}
41+
PLATFORM_TARGET: ${{ matrix.platform.target }}
4042
run: |
41-
target="${{ matrix.platform.target }}"
43+
target="${PLATFORM_TARGET}"
4244
43-
if ${{ runner.os == 'Linux' }}; then
45+
if [[ "${RUNNER_OS}" == "Linux" ]]; then
4446
target+="-unknown-linux-gnu"
45-
elif ${{ runner.os == 'macOS' }}; then
47+
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
4648
target+="-apple-darwin"
47-
elif ${{ runner.os == 'Windows' }}; then
49+
elif [[ "${RUNNER_OS}" == "Windows" ]]; then
4850
target+="-pc-windows-msvc"
4951
fi
5052
51-
echo "target=$target" >> $GITHUB_OUTPUT
53+
echo "TARGET=${target}" >> $GITHUB_ENV
5254
5355
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
5456
with:
5557
cache: ${{ !startsWith(github.ref, 'refs/tags/') }}
56-
target: ${{ steps.target.outputs.target }}
58+
target: ${{ env.TARGET }}
5759

5860
- name: Cache Zig toolchain
5961
if: ${{ runner.os == 'Linux' && matrix.platform.target == 'aarch64' }}
@@ -66,41 +68,43 @@ jobs:
6668
key: ${{ runner.os }}-zig-toolchain-${{ env.ZIG_VERSION }}
6769

6870
- name: Install Zig and cargo-zigbuild
69-
if: ${{ runner.os == 'Linux' && matrix.platform.target == 'aarch64' && steps.cache-zig.outputs. cache-hit != 'true' }}
71+
if: ${{ runner.os == 'Linux' && matrix.platform.target == 'aarch64' && steps.cache-zig. outputs.cache-hit != 'true' }}
7072
shell: bash
7173
run: |
72-
wget -q https://ziglang.org/download/${{ env.ZIG_VERSION }}/zig-linux-x86_64-${{ env. ZIG_VERSION }}.tar.xz
73-
tar xf zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz
74+
wget -q "https://ziglang.org/download/${ZIG_VERSION}/zig-linux-x86_64-${ZIG_VERSION}.tar. xz"
75+
tar xf "zig-linux-x86_64-${ZIG_VERSION}.tar.xz"
7476
cargo install cargo-zigbuild
7577
7678
- name: Add Zig to PATH
7779
if: ${{ runner.os == 'Linux' && matrix.platform.target == 'aarch64' }}
7880
shell: bash
79-
run: echo "$PWD/zig-linux-x86_64-${{ env.ZIG_VERSION }}" >> $GITHUB_PATH
81+
run: echo "$PWD/zig-linux-x86_64-${ZIG_VERSION}" >> $GITHUB_PATH
8082

8183
- name: Build release binary
82-
id: build
8384
shell: bash
85+
env:
86+
RUNNER_OS: ${{ runner.os }}
87+
PLATFORM_TARGET: ${{ matrix.platform.target }}
88+
PLATFORM_RUNNER: ${{ matrix.platform.runner }}
8489
run: |
85-
if [[ "${{ runner.os }}" == "Linux" && "${{ matrix.platform.target }}" == "aarch64" ]]; then
86-
cargo zigbuild --release --target ${{ steps.target.outputs.target }}
90+
if [[ "${RUNNER_OS}" == "Linux" && "${PLATFORM_TARGET}" == "aarch64" ]]; then
91+
cargo zigbuild --release --target "${TARGET}"
8792
else
88-
cargo build --verbose --release --target ${{ steps.target.outputs.target }}
93+
cargo build --verbose --release --target "${TARGET}"
8994
fi
9095
91-
if [[ "${{ matrix.platform.runner }}" == windows-* ]]; then
92-
bin="./target/${{ steps.target.outputs.target }}/release/djls.exe"
96+
if [[ "${PLATFORM_RUNNER}" == windows-* ]]; then
97+
bin="./target/${TARGET}/release/djls.exe"
9398
else
94-
bin="./target/${{ steps.target.outputs.target }}/release/djls"
99+
bin="./target/${TARGET}/release/djls"
95100
fi
96101
97-
echo "bin=$bin" >> $GITHUB_OUTPUT
102+
echo "BIN=${bin}" >> $GITHUB_ENV
98103
99104
- name: Determine binary name
100-
id: binary-name
101105
shell: bash
102106
run: |
103-
target="${{ steps.target.outputs.target }}"
107+
target="${TARGET}"
104108
name="djls"
105109
106110
if [[ "$target" == *linux* ]]; then
@@ -121,25 +125,28 @@ jobs:
121125
name+=".exe"
122126
fi
123127
124-
echo "name=$name" >> $GITHUB_OUTPUT
128+
echo "BINARY_NAME=${name}" >> $GITHUB_ENV
125129
126130
- name: Strip release binary (Unix)
127131
if: ${{ runner.os != 'Windows' }}
128132
shell: bash
133+
env:
134+
RUNNER_OS: ${{ runner.os }}
135+
PLATFORM_TARGET: ${{ matrix.platform.target }}
129136
run: |
130-
if [[ "${{ runner.os }}" == "Linux" && "${{ matrix.platform.target }}" == "aarch64" ]]; then
137+
if [[ "${RUNNER_OS}" == "Linux" && "${PLATFORM_TARGET}" == "aarch64" ]]; then
131138
sudo apt-get update
132139
sudo apt-get install -y binutils-aarch64-linux-gnu
133-
aarch64-linux-gnu-strip "${{ steps.build.outputs.bin }}"
140+
aarch64-linux-gnu-strip "${BIN}"
134141
else
135-
strip "${{ steps.build.outputs.bin }}"
142+
strip "${BIN}"
136143
fi
137144
138145
- name: Upload binary
139146
uses: actions/upload-artifact@v4
140147
with:
141-
name: binary-${{ steps.binary-name.outputs.name }}
142-
path: ${{ steps.build.outputs.bin }}
148+
name: binary-${{ env.BINARY_NAME }}
149+
path: ${{ env.BIN }}
143150

144151
linux:
145152
runs-on: ${{ matrix.platform.runner }}

0 commit comments

Comments
 (0)