Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Add Windows recovery workflow and update SignPath

Richie McIlroy22b45608981e
diff --git a/.github/workflows/publish-windows-recovery.yml b/.github/workflows/publish-windows-recovery.yml
new file mode 100644
index 000000000..5ac83a6cd
--- /dev/null
+++ b/.github/workflows/publish-windows-recovery.yml
@@ -0,0 +1,232 @@
+name: "publish-windows-recovery"
+
+on:
+ workflow_dispatch:
+ inputs:
+ source_run_id:
+ description: "Workflow run ID that uploaded the unsigned Windows installer"
+ required: true
+ type: string
+ source_artifact_name:
+ description: "Unsigned Windows installer artifact name"
+ default: "unsigned-windows-installer"
+ required: true
+ type: string
+ expected_artifact_digest:
+ description: "Optional GitHub artifact digest, e.g. sha256:..."
+ required: false
+ type: string
+ upload_to_crabnebula:
+ description: "Upload signed Windows assets to the existing CrabNebula release"
+ default: true
+ required: true
+ type: boolean
+
+run-name: "recover Windows release from run ${{ inputs.source_run_id }}"
+
+concurrency:
+ group: publish-windows-recovery-${{ inputs.source_run_id }}
+ cancel-in-progress: false
+
+env:
+ CN_APPLICATION: cap/cap
+ APP_CARGO_TOML: apps/desktop/src-tauri/Cargo.toml
+ WINDOWS_TARGET: x86_64-pc-windows-msvc
+
+jobs:
+ recover-windows:
+ runs-on: windows-2022
+ timeout-minutes: 45
+ permissions:
+ actions: read
+ contents: write
+ steps:
+ - name: Resolve source artifact
+ id: source
+ uses: actions/github-script@v7
+ env:
+ SOURCE_RUN_ID: ${{ inputs.source_run_id }}
+ SOURCE_ARTIFACT_NAME: ${{ inputs.source_artifact_name }}
+ EXPECTED_ARTIFACT_DIGEST: ${{ inputs.expected_artifact_digest }}
+ with:
+ script: |
+ const runId = Number(process.env.SOURCE_RUN_ID);
+
+ if (!Number.isSafeInteger(runId) || runId <= 0)
+ throw new Error("source_run_id must be a positive integer.");
+
+ const { owner, repo } = context.repo;
+ const { data: run } = await github.rest.actions.getWorkflowRun({
+ owner,
+ repo,
+ run_id: runId,
+ });
+
+ const artifacts = await github.paginate(
+ github.rest.actions.listWorkflowRunArtifacts,
+ {
+ owner,
+ repo,
+ run_id: runId,
+ per_page: 100,
+ },
+ );
+
+ const artifactName = process.env.SOURCE_ARTIFACT_NAME ?? "";
+ const matches = artifacts.filter(
+ (artifact) => artifact.name === artifactName && !artifact.expired,
+ );
+
+ if (matches.length !== 1)
+ throw new Error(`Expected exactly one non-expired artifact named '${artifactName}', found ${matches.length}.`);
+
+ const artifact = matches[0];
+ const expectedDigest = (process.env.EXPECTED_ARTIFACT_DIGEST ?? "")
+ .trim()
+ .toLowerCase();
+ const artifactDigest = (artifact.digest ?? "").toLowerCase();
+
+ if (expectedDigest && artifactDigest !== expectedDigest)
+ throw new Error(`Artifact digest mismatch. Expected ${expectedDigest}, got ${artifactDigest || "no digest"}.`);
+
+ core.setOutput("artifact_id", artifact.id);
+ core.setOutput("artifact_digest", artifact.digest ?? "");
+ core.setOutput("head_sha", run.head_sha);
+ core.setOutput("head_branch", run.head_branch ?? "");
+ core.setOutput("source_url", run.html_url);
+
+ - name: Checkout source commit
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ steps.source.outputs.head_sha }}
+
+ - name: Read version number
+ uses: SebRollen/[email protected]
+ id: read_version
+ with:
+ file: ${{ env.APP_CARGO_TOML }}
+ field: "package.version"
+
+ - name: Download unsigned Windows installer
+ uses: actions/download-artifact@v4
+ with:
+ artifact-ids: ${{ steps.source.outputs.artifact_id }}
+ github-token: ${{ github.token }}
+ repository: ${{ github.repository }}
+ run-id: ${{ inputs.source_run_id }}
+ path: unsigned-windows-installer
+
+ - name: Inspect unsigned Windows installer
+ id: unsigned_installer
+ shell: pwsh
+ run: |
+ $executables = @(Get-ChildItem -Path "unsigned-windows-installer" -Filter "*.exe" -File -Recurse)
+
+ if ($executables.Count -ne 1) {
+ throw "Expected exactly one unsigned Windows installer, found $($executables.Count)."
+ }
+
+ $hash = (Get-FileHash -Path $executables[0].FullName -Algorithm SHA256).Hash.ToLowerInvariant()
+
+ "path=$($executables[0].FullName)" >> $env:GITHUB_OUTPUT
+ "file_name=$($executables[0].Name)" >> $env:GITHUB_OUTPUT
+ "sha256=$hash" >> $env:GITHUB_OUTPUT
+
+ - name: Re-upload unsigned Windows installer for SignPath
+ id: upload_unsigned_windows_installer
+ uses: actions/upload-artifact@v4
+ with:
+ name: unsigned-windows-installer
+ path: ${{ steps.unsigned_installer.outputs.path }}
+ if-no-files-found: error
+
+ - name: Submit SignPath signing request
+ id: submit_signpath_signing_request
+ uses: signpath/github-action-submit-signing-request@v2
+ with:
+ api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
+ organization-id: ${{ secrets.SIGNPATH_ORGANIZATION_ID }}
+ project-slug: ${{ secrets.SIGNPATH_PROJECT_SLUG }}
+ signing-policy-slug: ${{ secrets.SIGNPATH_SIGNING_POLICY_SLUG }}
+ artifact-configuration-slug: ${{ secrets.SIGNPATH_ARTIFACT_CONFIGURATION_SLUG }}
+ github-artifact-id: ${{ steps.upload_unsigned_windows_installer.outputs.artifact-id }}
+ wait-for-completion: true
+ output-artifact-directory: signed-windows-installer
+
+ - name: Restore signed Windows installer
+ id: signed_installer
+ shell: pwsh
+ run: |
+ $signedDir = "signed-windows-installer"
+ $bundleDir = "target/${{ env.WINDOWS_TARGET }}/release/bundle/nsis"
+
+ if (-not (Test-Path $signedDir)) {
+ throw "Signed artifact directory '$signedDir' not found."
+ }
+
+ $executables = @(Get-ChildItem -Path $signedDir -Filter "*.exe" -File -Recurse)
+
+ if ($executables.Count -ne 1) {
+ throw "Expected exactly one signed Windows installer, found $($executables.Count)."
+ }
+
+ New-Item -ItemType Directory -Force -Path $bundleDir | Out-Null
+ Copy-Item -Path $executables[0].FullName -Destination $bundleDir -Force
+
+ $signedPath = Join-Path $bundleDir $executables[0].Name
+ $hash = (Get-FileHash -Path $signedPath -Algorithm SHA256).Hash.ToLowerInvariant()
+
+ "path=$signedPath" >> $env:GITHUB_OUTPUT
+ "file_name=$($executables[0].Name)" >> $env:GITHUB_OUTPUT
+ "sha256=$hash" >> $env:GITHUB_OUTPUT
+
+ - uses: ./.github/actions/setup-js
+
+ - name: Re-sign Windows installer for Tauri updater
+ shell: bash
+ working-directory: apps/desktop
+ run: |
+ BUNDLE_DIR="../../target/${{ env.WINDOWS_TARGET }}/release/bundle/nsis"
+ for exe in "$BUNDLE_DIR"/*.exe; do
+ echo "Re-signing $(basename "$exe") for Tauri updater..."
+ rm -f "${exe}.sig"
+ pnpm tauri signer sign -k "$TAURI_SIGNING_PRIVATE_KEY" -p "$TAURI_SIGNING_PRIVATE_KEY_PASSWORD" "$exe"
+ done
+ echo "Signature files after re-signing:"
+ ls -la "$BUNDLE_DIR"/*.sig
+ env:
+ TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
+ TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
+
+ - name: Upload recovered Windows assets
+ uses: actions/upload-artifact@v4
+ with:
+ name: signed-windows-installer-${{ steps.read_version.outputs.value }}
+ path: |
+ target/${{ env.WINDOWS_TARGET }}/release/bundle/nsis/*.exe
+ target/${{ env.WINDOWS_TARGET }}/release/bundle/nsis/*.sig
+ if-no-files-found: error
+
+ - name: Upload assets
+ if: ${{ inputs.upload_to_crabnebula }}
+ uses: crabnebula-dev/cloud-release@v0
+ with:
+ working-directory: apps/desktop
+ command: release upload ${{ env.CN_APPLICATION }} "${{ steps.read_version.outputs.value }}" --framework tauri
+ api-key: ${{ secrets.CN_API_KEY }}
+ env:
+ TAURI_BUNDLE_PATH: ../..
+
+ - name: Write summary
+ if: ${{ always() }}
+ shell: pwsh
+ run: |
+ "### Windows release recovery" >> $env:GITHUB_STEP_SUMMARY
+ "" >> $env:GITHUB_STEP_SUMMARY
+ "- Source run: ${{ steps.source.outputs.source_url }}" >> $env:GITHUB_STEP_SUMMARY
+ "- Source artifact ID: ${{ steps.source.outputs.artifact_id }}" >> $env:GITHUB_STEP_SUMMARY
+ "- Source artifact digest: ${{ steps.source.outputs.artifact_digest }}" >> $env:GITHUB_STEP_SUMMARY
+ "- Source commit: ${{ steps.source.outputs.head_sha }}" >> $env:GITHUB_STEP_SUMMARY
+ "- Version: ${{ steps.read_version.outputs.value }}" >> $env:GITHUB_STEP_SUMMARY
+ "- Unsigned installer SHA-256: ${{ steps.unsigned_installer.outputs.sha256 }}" >> $env:GITHUB_STEP_SUMMARY
+ "- Signed installer SHA-256: ${{ steps.signed_installer.outputs.sha256 }}" >> $env:GITHUB_STEP_SUMMARY
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 4bd0f38b3..1a299e703 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -274,7 +274,7 @@ jobs:
- name: Submit SignPath signing request
if: ${{ runner.os == 'Windows' }}
id: submit_signpath_signing_request
- uses: signpath/github-action-submit-signing-request@v1
+ uses: signpath/github-action-submit-signing-request@v2
with:
api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
organization-id: ${{ secrets.SIGNPATH_ORGANIZATION_ID }}