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.
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
Provenance
- Commit
7014993- Tree
574b12c- Author
Daniel Hast <hast.daniel@protonmail.com>- Committer
Daniel Hast <hast.daniel@protonmail.com>- Parent
72e54e8
2 files changed+51 added−27 removed
modified:.github/workflows/CICD.yml+47 added-27 removed
12 unmodified lines13 tags:14 - '*'15 16 permissions:17- id-token: write18- contents: write17+ contents: read19- attestations: write18 19 jobs: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_OUTPUT15 unmodified lines46 - uses: dtolnay/rust-toolchain@stable47 with:48 components: rustfmt49 - uses: actions/checkout@v550+ with:51+ persist-credentials: false52 - run: cargo fmt -- --check53 54 lint_check:55 name: Ensure 'cargo clippy' has no warnings2 unmodified lines58 - 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 -- -Dwarnings65 66 min_version:67 name: Minimum supported rust version1 unmodified line69 needs: crate_metadata70 steps:71 - name: Checkout source code72 uses: actions/checkout@v573+ with:74+ persist-credentials: false75 76 - 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}"85 86 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 lines108 - { 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: false120 121 - 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 lines133 toolchain: "stable"134 135 - 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: cross140 127- - name: Overwrite build command env variable128- if: matrix.job.use-cross129- shell: bash130- run: echo "BUILD_CMD=cross" >> $GITHUB_ENV131-141 - name: Show version information (Rust, cargo, GCC)142 shell: bash143 run: |144 gcc --version || true4 unmodified lines149 rustc -V150 151 - name: Build152 shell: bash144- run: $BUILD_CMD build --locked --release --target=${{ matrix.job.target }}153+ run: $BUILD_CMD build --locked --release --target="${target}"154 155 - 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;164 165 # 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}"168 169 # Let subsequent steps know where to find the binary170 echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT171 echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT3 unmodified lines175 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_OUTPUT184 185 - 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}"190 191 - name: Generate completions192 id: completions193 shell: bash1 unmodified line195 196 - 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_OUTPUT210 191- 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}"214 215 # Binary196- cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR"216+ cp "${BIN_PATH}" "$ARCHIVE_DIR"217 218 # README, LICENSE and CHANGELOG files219 cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "CHANGELOG.md" "$ARCHIVE_DIR"220 221 # Man page202- cp 'doc/${{ needs.crate_metadata.outputs.name }}.1' "$ARCHIVE_DIR"222+ cp "doc/${name}.1" "$ARCHIVE_DIR"223 224 # Autocompletion files225 cp -r autocomplete "${ARCHIVE_DIR}"226 227 # 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/null47 unmodified lines281 subject-name: ${{ steps.debian-package.outputs.DPKG_NAME }}282 subject-digest: sha256::${{ steps.upload-deb.outputs.artifact-digest }}283 284 - 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 lines296 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
2 unmodified lines345678910111213142 unmodified lines - package-ecosystem: "cargo" directory: "/" schedule: interval: "monthly" cooldown: default-days: 7 - package-ecosystem: "github-actions" directory: "/" schedule: interval: "daily" cooldown: default-days: 7