From 174219456d295d71e04f9b162c96952159561afb Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Tue, 17 Nov 2026 21:46:17 +0000 Subject: [PATCH] ci: check artifact checksums between release jobs Each job records a checksum of what it uploads, and the job that downloads it checks the file before using it. --- .github/workflows/release-sign.yml | 131 ++++++++++++++++++++++++++++- RELEASING.md | 4 + 2 files changed, 133 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-sign.yml b/.github/workflows/release-sign.yml index 57af5744..f7bc4c17 100644 --- a/.github/workflows/release-sign.yml +++ b/.github/workflows/release-sign.yml @@ -19,6 +19,9 @@ name: release-sign # sign-sparkle macOS. Signs the installer for Sparkle. # publish macOS. Publishes the installer. # +# Each job records the SHA-256 of what it uploads as a job output, and the job that downloads +# it checks the file against that before using it. +# # The three signing jobs run in the "signing" environment, which only main and # v* tags may use. The publish job runs in the "publish" environment, under # the same restriction. Neither environment has reviewers, so that preview @@ -64,6 +67,9 @@ jobs: if: ${{ github.repository_owner == 'coder' }} permissions: contents: read + outputs: + app-sha256: ${{ steps.checksums.outputs.app }} + dsyms-sha256: ${{ steps.checksums.outputs.dsyms }} steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -84,6 +90,17 @@ jobs: shell: nix develop .#ci --command bash --noprofile --norc -eo pipefail {0} run: ./scripts/build.sh build/release + - name: Record checksums + id: checksums + run: | + set -euo pipefail + app="$(shasum -a 256 build/release/coder-desktop-unsigned.tar | cut -d ' ' -f 1)" + dsyms="$(shasum -a 256 build/release/coder-desktop-dsyms.zip | cut -d ' ' -f 1)" + { + echo "app=$app" + echo "dsyms=$dsyms" + } >> "$GITHUB_OUTPUT" + - name: Upload unsigned app uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: @@ -109,6 +126,8 @@ jobs: if: ${{ github.repository_owner == 'coder' }} permissions: contents: read + outputs: + sha256: ${{ steps.checksum.outputs.sha256 }} steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -118,6 +137,13 @@ jobs: - name: Build rcodesign uses: ./.github/actions/install-rcodesign + - name: Record checksum + id: checksum + run: | + set -euo pipefail + sha256="$(sha256sum /tmp/rcodesign-bin/rcodesign | cut -d ' ' -f 1)" + echo "sha256=$sha256" >> "$GITHUB_OUTPUT" + - name: Upload rcodesign uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: @@ -157,6 +183,8 @@ jobs: contents: read # To authenticate to Google Cloud id-token: write + outputs: + sha256: ${{ steps.checksum.outputs.sha256 }} steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -171,6 +199,14 @@ jobs: name: rcodesign path: ${{ runner.temp }}/rcodesign + - name: Check rcodesign + env: + SHA256: ${{ needs.rcodesign.outputs.sha256 }} + run: | + set -euo pipefail + [[ "$SHA256" =~ ^[0-9a-f]{64}$ ]] || { echo "::error::No checksum from the rcodesign job."; exit 1; } + sha256sum -c <<<"$SHA256 $RUNNER_TEMP/rcodesign/rcodesign" + - name: Install rcodesign run: | set -euo pipefail @@ -252,6 +288,14 @@ jobs: name: unsigned-app path: build/unsigned + - name: Check unsigned app + env: + SHA256: ${{ needs.build.outputs.app-sha256 }} + run: | + set -euo pipefail + [[ "$SHA256" =~ ^[0-9a-f]{64}$ ]] || { echo "::error::No checksum from the build job."; exit 1; } + sha256sum -c <<<"$SHA256 build/unsigned/coder-desktop-unsigned.tar" + - name: Sign env: APP_PROF_PATH: /tmp/app.provisionprofile @@ -284,6 +328,13 @@ jobs: "build/app/Coder Desktop.app" tar -C build/app -cf build/coder-desktop-signed.tar "Coder Desktop.app" + - name: Record checksum + id: checksum + run: | + set -euo pipefail + sha256="$(sha256sum build/coder-desktop-signed.tar | cut -d ' ' -f 1)" + echo "sha256=$sha256" >> "$GITHUB_OUTPUT" + - name: Upload signed app uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: @@ -302,6 +353,8 @@ jobs: if: ${{ !cancelled() && github.repository_owner == 'coder' && needs.sign-app.result == 'success' }} permissions: contents: read + outputs: + sha256: ${{ steps.checksum.outputs.sha256 }} steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -314,6 +367,14 @@ jobs: name: signed-app path: build/signed + - name: Check signed app + env: + SHA256: ${{ needs.sign-app.outputs.sha256 }} + run: | + set -euo pipefail + [[ "$SHA256" =~ ^[0-9a-f]{64}$ ]] || { echo "::error::No checksum from the sign-app job."; exit 1; } + shasum -a 256 -c <<<"$SHA256 build/signed/coder-desktop-signed.tar" + # The installer comes out unsigned. The sign-installer job signs it. - name: Build the installer run: | @@ -329,6 +390,13 @@ jobs: --install-location "/Applications/" \ build/package/Coder-Desktop.pkg + - name: Record checksum + id: checksum + run: | + set -euo pipefail + sha256="$(shasum -a 256 build/package/Coder-Desktop.pkg | cut -d ' ' -f 1)" + echo "sha256=$sha256" >> "$GITHUB_OUTPUT" + - name: Upload unsigned installer uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: @@ -349,6 +417,8 @@ jobs: contents: read # To authenticate to Google Cloud id-token: write + outputs: + sha256: ${{ steps.checksum.outputs.sha256 }} steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -362,6 +432,14 @@ jobs: name: rcodesign path: ${{ runner.temp }}/rcodesign + - name: Check rcodesign + env: + SHA256: ${{ needs.rcodesign.outputs.sha256 }} + run: | + set -euo pipefail + [[ "$SHA256" =~ ^[0-9a-f]{64}$ ]] || { echo "::error::No checksum from the rcodesign job."; exit 1; } + sha256sum -c <<<"$SHA256 $RUNNER_TEMP/rcodesign/rcodesign" + - name: Install rcodesign run: | set -euo pipefail @@ -434,6 +512,14 @@ jobs: name: unsigned-installer path: build/package + - name: Check unsigned installer + env: + SHA256: ${{ needs.package.outputs.sha256 }} + run: | + set -euo pipefail + [[ "$SHA256" =~ ^[0-9a-f]{64}$ ]] || { echo "::error::No checksum from the package job."; exit 1; } + sha256sum -c <<<"$SHA256 build/package/Coder-Desktop.pkg" + - name: Sign env: AC_CERTIFICATE_FILE: /tmp/installer_cert.pem @@ -462,6 +548,13 @@ jobs: --staple \ build/out/Coder-Desktop.pkg + - name: Record checksum + id: checksum + run: | + set -euo pipefail + sha256="$(sha256sum build/out/Coder-Desktop.pkg | cut -d ' ' -f 1)" + echo "sha256=$sha256" >> "$GITHUB_OUTPUT" + - name: Upload installer uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: @@ -486,6 +579,8 @@ jobs: # See the sign-app job. environment: signing permissions: {} + outputs: + sha256: ${{ steps.checksum.outputs.sha256 }} steps: - name: Download installer uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 @@ -493,6 +588,14 @@ jobs: name: installer path: build/out + - name: Check installer + env: + SHA256: ${{ needs.sign-installer.outputs.sha256 }} + run: | + set -euo pipefail + [[ "$SHA256" =~ ^[0-9a-f]{64}$ ]] || { echo "::error::No checksum from the sign-installer job."; exit 1; } + shasum -a 256 -c <<<"$SHA256 build/out/Coder-Desktop.pkg" + # The tool comes from the Sparkle release the app is built with. - name: Install Sparkle's signing tool run: | @@ -517,6 +620,13 @@ jobs: > build/out/Coder-Desktop.pkg.sig cat build/out/Coder-Desktop.pkg.sig + - name: Record checksum + id: checksum + run: | + set -euo pipefail + sha256="$(shasum -a 256 build/out/Coder-Desktop.pkg.sig | cut -d ' ' -f 1)" + echo "sha256=$sha256" >> "$GITHUB_OUTPUT" + - name: Upload Sparkle signature uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: @@ -529,11 +639,12 @@ jobs: # identity that may write to the releases bucket. publish: name: Publish - needs: [build, sign-sparkle] + needs: [build, sign-installer, sign-sparkle] runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-26' || 'macos-26'}} if: >- ${{ !cancelled() && github.repository_owner == 'coder' && - needs.build.result == 'success' && needs.sign-sparkle.result == 'success' }} + needs.build.result == 'success' && needs.sign-installer.result == 'success' && + needs.sign-sparkle.result == 'success' }} environment: publish permissions: # To upload assets to the release @@ -572,6 +683,22 @@ jobs: name: dsyms path: build/out + - name: Check downloads + env: + INSTALLER_SHA256: ${{ needs.sign-installer.outputs.sha256 }} + SIGNATURE_SHA256: ${{ needs.sign-sparkle.outputs.sha256 }} + DSYMS_SHA256: ${{ needs.build.outputs.dsyms-sha256 }} + run: | + set -euo pipefail + for sha256 in "$INSTALLER_SHA256" "$SIGNATURE_SHA256" "$DSYMS_SHA256"; do + [[ "$sha256" =~ ^[0-9a-f]{64}$ ]] || { echo "::error::A checksum from an earlier job is missing."; exit 1; } + done + shasum -a 256 -c <