diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 04712f5..9075a12 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,10 @@ on: description: "Existing tag to (re)build, e.g. v0.9.0" required: true +# Every job uploads to the release, so every job needs to write. The token +# reaches only the steps that name it: no checkout keeps it, and every +# action is pinned to a commit, since a tag can be moved under a release +# that signs with the secrets below. permissions: contents: write @@ -25,9 +29,10 @@ jobs: tag: ${{ steps.version.outputs.tag }} version: ${{ steps.version.outputs.version }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 with: ref: ${{ inputs.tag || github.ref }} + persist-credentials: false - name: Version id: version @@ -69,9 +74,10 @@ jobs: - { runner: ubuntu-22.04-arm, arch: aarch64 } runs-on: ${{ matrix.runner }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 with: ref: ${{ inputs.tag || github.ref }} + persist-credentials: false - name: System libraries run: | @@ -81,11 +87,11 @@ jobs: libx11-xcb-dev libxcb1-dev libfontconfig-dev libfreetype-dev \ libvulkan-dev libasound2-dev libssl-dev libzstd-dev - - uses: dtolnay/rust-toolchain@master + - uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # master with: toolchain: "1.97" - - uses: Swatinem/rust-cache@v2 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 - name: Test run: cargo xtask test @@ -137,29 +143,31 @@ jobs: # MACOS_SIGN_IDENTITY "Developer ID Application: Name (TEAMID)" # NOTARY_KEY_P8 base64 of an App Store Connect API key # NOTARY_KEY_ID, NOTARY_ISSUER that key's ID and issuer - MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }} - MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }} - MACOS_SIGN_IDENTITY: ${{ secrets.MACOS_SIGN_IDENTITY }} - NOTARY_KEY_P8: ${{ secrets.NOTARY_KEY_P8 }} - NOTARY_KEY_ID: ${{ secrets.NOTARY_KEY_ID }} - NOTARY_ISSUER: ${{ secrets.NOTARY_ISSUER }} + # Only whether there is a certificate is known to the whole job. The + # secrets themselves go to the two steps that use them, not to the + # tests and every dependency's build script before those. + HAS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE != '' }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 with: ref: ${{ inputs.tag || github.ref }} + persist-credentials: false - - uses: dtolnay/rust-toolchain@master + - uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # master with: toolchain: "1.97" - - uses: Swatinem/rust-cache@v2 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 - name: Test run: cargo xtask test # A keychain of its own for the certificate, deleted with the runner. - name: Signing certificate - if: env.MACOS_CERTIFICATE != '' + if: env.HAS_CERTIFICATE == 'true' + env: + MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }} + MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }} run: | keychain="$RUNNER_TEMP/signing.keychain-db" password=$(uuidgen) @@ -176,9 +184,14 @@ jobs: rm "$RUNNER_TEMP/cert.p12" - name: Bundle + env: + MACOS_SIGN_IDENTITY: ${{ secrets.MACOS_SIGN_IDENTITY }} + NOTARY_KEY_P8: ${{ secrets.NOTARY_KEY_P8 }} + NOTARY_KEY_ID: ${{ secrets.NOTARY_KEY_ID }} + NOTARY_ISSUER: ${{ secrets.NOTARY_ISSUER }} run: | args=() - if [ -n "$MACOS_CERTIFICATE" ]; then + if [ "$HAS_CERTIFICATE" = true ]; then args+=(--sign "$MACOS_SIGN_IDENTITY") if [ -n "$NOTARY_KEY_P8" ]; then echo "$NOTARY_KEY_P8" | base64 --decode \ @@ -218,15 +231,16 @@ jobs: steps: - run: git config --global core.autocrlf false - - uses: actions/checkout@v5 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 with: ref: ${{ inputs.tag || github.ref }} + persist-credentials: false - - uses: dtolnay/rust-toolchain@master + - uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # master with: toolchain: "1.97" - - uses: Swatinem/rust-cache@v2 + - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2 - name: Test run: cargo xtask test