Skip to content

Commit 2f5ab52

Browse files
authored
Merge pull request #1828 from HastD/zizmor
ci: resolve Zizmor-identified workflow issues
2 parents 19e752d + 7014993 commit 2f5ab52

File tree

2 files changed

+51
-27
lines changed

2 files changed

+51
-27
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "monthly"
7+
cooldown:
8+
default-days: 7
79
- package-ecosystem: "github-actions"
810
directory: "/"
911
schedule:
1012
interval: "daily"
13+
cooldown:
14+
default-days: 7

.github/workflows/CICD.yml

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ on:
1414
- '*'
1515

1616
permissions:
17-
id-token: write
18-
contents: write
19-
attestations: write
17+
contents: read
2018

2119
jobs:
2220
crate_metadata:
2321
name: Extract crate metadata
2422
runs-on: ubuntu-latest
2523
steps:
2624
- uses: actions/checkout@v5
25+
with:
26+
persist-credentials: false
2727
- name: Extract crate information
2828
id: crate_metadata
2929
run: |
@@ -47,6 +47,8 @@ jobs:
4747
with:
4848
components: rustfmt
4949
- uses: actions/checkout@v5
50+
with:
51+
persist-credentials: false
5052
- run: cargo fmt -- --check
5153

5254
lint_check:
@@ -57,6 +59,8 @@ jobs:
5759
with:
5860
components: clippy
5961
- uses: actions/checkout@v5
62+
with:
63+
persist-credentials: false
6064
- run: cargo clippy --all-targets --all-features -- -Dwarnings
6165

6266
min_version:
@@ -66,21 +70,27 @@ jobs:
6670
steps:
6771
- name: Checkout source code
6872
uses: actions/checkout@v5
73+
with:
74+
persist-credentials: false
6975

7076
- name: Install rust toolchain (v${{ needs.crate_metadata.outputs.msrv }})
7177
uses: dtolnay/rust-toolchain@master
7278
with:
7379
toolchain: ${{ needs.crate_metadata.outputs.msrv }}
7480
components: clippy
7581
- name: Run clippy (on minimum supported rust version to prevent warnings we can't fix)
76-
run: cargo clippy --locked --all-targets ${{ env.MSRV_FEATURES }}
82+
run: cargo clippy --locked --all-targets "${MSRV_FEATURES}"
7783
- name: Run tests
78-
run: cargo test --locked ${{ env.MSRV_FEATURES }}
84+
run: cargo test --locked "${MSRV_FEATURES}"
7985

8086
build:
8187
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
8288
runs-on: ${{ matrix.job.os }}
8389
needs: crate_metadata
90+
permissions:
91+
id-token: write
92+
contents: write
93+
attestations: write
8494
strategy:
8595
fail-fast: false
8696
matrix:
@@ -99,15 +109,19 @@ jobs:
99109
- { target: x86_64-unknown-linux-gnu , os: ubuntu-24.04, use-cross: true }
100110
- { target: x86_64-unknown-linux-musl , os: ubuntu-24.04, use-cross: true }
101111
env:
102-
BUILD_CMD: cargo
112+
BUILD_CMD: ${{ matrix.job.use-cross && cross || cargo }}
113+
target: ${{ matrix.job.target }}
114+
name: ${{ needs.crate_metadata.outputs.name }}
103115
steps:
104116
- name: Checkout source code
105117
uses: actions/checkout@v5
118+
with:
119+
persist-credentials: false
106120

107121
- name: Install prerequisites
108122
shell: bash
109123
run: |
110-
case ${{ matrix.job.target }} in
124+
case ${target} in
111125
arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
112126
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
113127
esac
@@ -120,15 +134,10 @@ jobs:
120134

121135
- name: Install cross
122136
if: matrix.job.use-cross
123-
uses: taiki-e/install-action@v2
137+
uses: taiki-e/install-action@6f9c7cc51aa54b13cbcbd12f8bbf69d8ba405b4b # v2.62.47
124138
with:
125139
tool: cross
126140

127-
- name: Overwrite build command env variable
128-
if: matrix.job.use-cross
129-
shell: bash
130-
run: echo "BUILD_CMD=cross" >> $GITHUB_ENV
131-
132141
- name: Show version information (Rust, cargo, GCC)
133142
shell: bash
134143
run: |
@@ -141,21 +150,21 @@ jobs:
141150
142151
- name: Build
143152
shell: bash
144-
run: $BUILD_CMD build --locked --release --target=${{ matrix.job.target }}
153+
run: $BUILD_CMD build --locked --release --target="${target}"
145154

146155
- name: Set binary name & path
147156
id: bin
148157
shell: bash
149158
run: |
150159
# Figure out suffix of binary
151160
EXE_suffix=""
152-
case ${{ matrix.job.target }} in
161+
case ${target} in
153162
*-pc-windows-*) EXE_suffix=".exe" ;;
154163
esac;
155164
156165
# Setup paths
157-
BIN_NAME="${{ needs.crate_metadata.outputs.name }}${EXE_suffix}"
158-
BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}"
166+
BIN_NAME="${name}${EXE_suffix}"
167+
BIN_PATH="target/${target}/release/${BIN_NAME}"
159168
160169
# Let subsequent steps know where to find the binary
161170
echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT
@@ -167,12 +176,17 @@ jobs:
167176
run: |
168177
# test only library unit tests and binary for arm-type targets
169178
unset CARGO_TEST_OPTIONS
170-
unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--bin ${{ needs.crate_metadata.outputs.name }}" ;; esac;
179+
case ${target} in
180+
arm-* | aarch64-*)
181+
CARGO_TEST_OPTIONS="--bin ${name}" ;;
182+
esac
171183
echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_OUTPUT
172184
173185
- name: Run tests
174186
shell: bash
175-
run: $BUILD_CMD test --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}
187+
env:
188+
cargo_test_options: ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}
189+
run: $BUILD_CMD test --locked --target="${target}" "${cargo_test_options}"
176190

177191
- name: Generate completions
178192
id: completions
@@ -182,31 +196,37 @@ jobs:
182196
- name: Create tarball
183197
id: package
184198
shell: bash
199+
env:
200+
BIN_PATH: ${{ steps.bin.outputs.BIN_PATH }}
201+
version: ${{ needs.crate_metadata.outputs.version }}
185202
run: |
186-
PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
187-
PKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-v${{ needs.crate_metadata.outputs.version }}-${{ matrix.job.target }}
203+
PKG_suffix=".tar.gz"
204+
case ${target} in
205+
*-pc-windows-*) PKG_suffix=".zip" ;;
206+
esac
207+
PKG_BASENAME=${name}-v${version}-${target}
188208
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
189209
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT
190210
191-
PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package"
211+
PKG_STAGING="${CICD_INTERMEDIATES_DIR}/package"
192212
ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/"
193213
mkdir -p "${ARCHIVE_DIR}"
194214
195215
# Binary
196-
cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR"
216+
cp "${BIN_PATH}" "$ARCHIVE_DIR"
197217
198218
# README, LICENSE and CHANGELOG files
199219
cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "CHANGELOG.md" "$ARCHIVE_DIR"
200220
201221
# Man page
202-
cp 'doc/${{ needs.crate_metadata.outputs.name }}.1' "$ARCHIVE_DIR"
222+
cp "doc/${name}.1" "$ARCHIVE_DIR"
203223
204224
# Autocompletion files
205225
cp -r autocomplete "${ARCHIVE_DIR}"
206226
207227
# base compressed package
208228
pushd "${PKG_STAGING}/" >/dev/null
209-
case ${{ matrix.job.target }} in
229+
case ${target} in
210230
*-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;;
211231
*) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;;
212232
esac;
@@ -262,7 +282,7 @@ jobs:
262282
subject-digest: sha256::${{ steps.upload-deb.outputs.artifact-digest }}
263283

264284
- name: Publish archives and packages
265-
uses: softprops/action-gh-release@v2
285+
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
266286
if: steps.is-release.outputs.IS_RELEASE
267287
with:
268288
files: |
@@ -277,7 +297,7 @@ jobs:
277297
needs: build
278298
if: startsWith(github.ref, 'refs/tags/v')
279299
steps:
280-
- uses: vedantmgoyal2009/winget-releaser@v2
300+
- uses: vedantmgoyal9/winget-releaser@4ffc7888bffd451b357355dc214d43bb9f23917e # v2
281301
with:
282302
identifier: sharkdp.fd
283303
installers-regex: '-pc-windows-msvc\.zip$'

0 commit comments

Comments
 (0)