Skip to content
Myr

ci: resolve Zizmor-identified workflow issues

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Set dependabot cooldown timer of 7 days, which helps mitigate stability and supply-chain security risks. For more info, see https://docs.zizmor.sh/audits/#dependabot-cooldown * Restrict write permissions to the job that actually needs them. * Set `persist-credentials: false` for `actions/checkout`. See https://docs.zizmor.sh/audits/#artipacked * Use environment variables instead of template expansions in code contexts. See https://docs.zizmor.sh/audits/#template-injection * Pin action dependencies to SHA hashes.

authored by Daniel Hast · committed by Daniel Hast · parent 72e54e8 · Browse files · 2 files+51 added−27 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+51 added−27 removed

  • other:+51 added−27 removed

2 files+51 added−27 removed

modified:.github/workflows/CICD.yml+47 added-27 removed
12 unmodified lines
13 tags:14 - '*'1516permissions:17 id-token: write18 contents: write17 contents: read19 attestations: write1819jobs:20 crate_metadata:21 name: Extract crate metadata22 runs-on: ubuntu-latest23 steps:24 - uses: actions/checkout@v525 with:26 persist-credentials: false27 - name: Extract crate information28 id: crate_metadata29 run: |30 echo "name=fd" | tee -a $GITHUB_OUTPUT
15 unmodified lines
46 - uses: dtolnay/rust-toolchain@stable47 with:48 components: rustfmt49 - uses: actions/checkout@v550 with:51 persist-credentials: false52 - run: cargo fmt -- --check5354 lint_check:55 name: Ensure 'cargo clippy' has no warnings
2 unmodified lines
58 - uses: dtolnay/rust-toolchain@stable59 with:60 components: clippy61 - uses: actions/checkout@v562 with:63 persist-credentials: false64 - run: cargo clippy --all-targets --all-features -- -Dwarnings6566 min_version:67 name: Minimum supported rust version
1 unmodified line
69 needs: crate_metadata70 steps:71 - name: Checkout source code72 uses: actions/checkout@v573 with:74 persist-credentials: false7576 - name: Install rust toolchain (v${{ needs.crate_metadata.outputs.msrv }})77 uses: dtolnay/rust-toolchain@master78 with:79 toolchain: ${{ needs.crate_metadata.outputs.msrv }}80 components: clippy81 - 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}"83 - name: Run tests78 run: cargo test --locked ${{ env.MSRV_FEATURES }}84 run: cargo test --locked "${MSRV_FEATURES}"8586 build:87 name: ${{ matrix.job.target }} (${{ matrix.job.os }})88 runs-on: ${{ matrix.job.os }}89 needs: crate_metadata90 permissions:91 id-token: write92 contents: write93 attestations: write94 strategy:95 fail-fast: false96 matrix:97 job:
10 unmodified lines
108 - { target: aarch64-pc-windows-msvc , os: windows-11-arm }109 - { target: x86_64-unknown-linux-gnu , os: ubuntu-24.04, use-cross: true }110 - { target: x86_64-unknown-linux-musl , os: ubuntu-24.04, use-cross: true }111 env:102 BUILD_CMD: cargo112 BUILD_CMD: ${{ matrix.job.use-cross && cross || cargo }}113 target: ${{ matrix.job.target }}114 name: ${{ needs.crate_metadata.outputs.name }}115 steps:116 - name: Checkout source code117 uses: actions/checkout@v5118 with:119 persist-credentials: false120121 - name: Install prerequisites122 shell: bash123 run: |110 case ${{ matrix.job.target }} in124 case ${target} in125 arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;126 aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;127 esac128
4 unmodified lines
133 toolchain: "stable"134135 - name: Install cross136 if: matrix.job.use-cross123 uses: taiki-e/install-action@v2137 uses: taiki-e/install-action@6f9c7cc51aa54b13cbcbd12f8bbf69d8ba405b4b # v2.62.47138 with:139 tool: cross140127 - name: Overwrite build command env variable128 if: matrix.job.use-cross129 shell: bash130 run: echo "BUILD_CMD=cross" >> $GITHUB_ENV131141 - name: Show version information (Rust, cargo, GCC)142 shell: bash143 run: |144 gcc --version || true
4 unmodified lines
149 rustc -V150151 - name: Build152 shell: bash144 run: $BUILD_CMD build --locked --release --target=${{ matrix.job.target }}153 run: $BUILD_CMD build --locked --release --target="${target}"154155 - name: Set binary name & path156 id: bin157 shell: bash158 run: |159 # Figure out suffix of binary160 EXE_suffix=""152 case ${{ matrix.job.target }} in161 case ${target} in162 *-pc-windows-*) EXE_suffix=".exe" ;;163 esac;164165 # Setup paths157 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}"168169 # Let subsequent steps know where to find the binary170 echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT171 echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT
3 unmodified lines
175 shell: bash176 run: |177 # test only library unit tests and binary for arm-type targets178 unset CARGO_TEST_OPTIONS170 unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--bin ${{ needs.crate_metadata.outputs.name }}" ;; esac;179 case ${target} in180 arm-* | aarch64-*)181 CARGO_TEST_OPTIONS="--bin ${name}" ;;182 esac183 echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_OUTPUT184185 - name: Run tests186 shell: bash175 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}"190191 - name: Generate completions192 id: completions193 shell: bash
1 unmodified line
195196 - name: Create tarball197 id: package198 shell: bash199 env:200 BIN_PATH: ${{ steps.bin.outputs.BIN_PATH }}201 version: ${{ needs.crate_metadata.outputs.version }}202 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} in205 *-pc-windows-*) PKG_suffix=".zip" ;;206 esac207 PKG_BASENAME=${name}-v${version}-${target}208 PKG_NAME=${PKG_BASENAME}${PKG_suffix}209 echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT210191 PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package"211 PKG_STAGING="${CICD_INTERMEDIATES_DIR}/package"212 ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/"213 mkdir -p "${ARCHIVE_DIR}"214215 # Binary196 cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR"216 cp "${BIN_PATH}" "$ARCHIVE_DIR"217218 # README, LICENSE and CHANGELOG files219 cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "CHANGELOG.md" "$ARCHIVE_DIR"220221 # Man page202 cp 'doc/${{ needs.crate_metadata.outputs.name }}.1' "$ARCHIVE_DIR"222 cp "doc/${name}.1" "$ARCHIVE_DIR"223224 # Autocompletion files225 cp -r autocomplete "${ARCHIVE_DIR}"226227 # base compressed package228 pushd "${PKG_STAGING}/" >/dev/null209 case ${{ matrix.job.target }} in229 case ${target} in230 *-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;;231 *) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;;232 esac;233 popd >/dev/null
47 unmodified lines
281 subject-name: ${{ steps.debian-package.outputs.DPKG_NAME }}282 subject-digest: sha256::${{ steps.upload-deb.outputs.artifact-digest }}283284 - name: Publish archives and packages265 uses: softprops/action-gh-release@v2285 uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1286 if: steps.is-release.outputs.IS_RELEASE287 with:288 files: |289 ${{ steps.package.outputs.PKG_PATH }}
6 unmodified lines
296 runs-on: ubuntu-latest297 needs: build298 if: startsWith(github.ref, 'refs/tags/v')299 steps:280 - uses: vedantmgoyal2009/winget-releaser@v2300 - uses: vedantmgoyal9/winget-releaser@4ffc7888bffd451b357355dc214d43bb9f23917e # v2301 with:302 identifier: sharkdp.fd303 installers-regex: '-pc-windows-msvc\.zip$'304 token: ${{ secrets.WINGET_TOKEN }}
modified:.github/dependabot.yml+4 added