|
| 1 | +name: Updates verify-installers.md after desktop release |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + types: [desktop-release] |
| 6 | + |
| 7 | +defaults: |
| 8 | + run: |
| 9 | + shell: bash |
| 10 | + |
| 11 | + |
| 12 | +jobs: |
| 13 | + create-pr: |
| 14 | + name: Create PR to update windows signing cert |
| 15 | + runs-on: windows-latest |
| 16 | + permissions: |
| 17 | + contents: write |
| 18 | + env: |
| 19 | + DESKTOP_VERSION: ${{ github.event.client_payload.version }} |
| 20 | + steps: |
| 21 | + - name: Checkout repo |
| 22 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 23 | + - name: Create new branch |
| 24 | + run: | |
| 25 | + git config --global --add safe.directory "$GITHUB_WORKSPACE" |
| 26 | + if [[ ! "$DESKTOP_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z]+)*$ ]]; then |
| 27 | + echo "Invalid version in payload: $DESKTOP_VERSION" >&2 |
| 28 | + exit 1; |
| 29 | + fi |
| 30 | + git checkout -b "feature/desktop-${DESKTOP_VERSION}" |
| 31 | + - name: Download MSI |
| 32 | + run: | |
| 33 | + MSI_URL=$(jq -r '[.[] | select(.name | endswith(".msi"))][0].browser_download_url // "null"' <<< "$ASSETS_JSON") |
| 34 | + if [[ "$MSI_URL" == "null" || -z "$MSI_URL" ]]; then |
| 35 | + echo "No MSI asset found in repository_dispatch payload." >&2 |
| 36 | + exit 1 |
| 37 | + fi |
| 38 | + curl --silent --fail-with-body --proto "=https" -L -H "Accept: application/vnd.github+json" $MSI_URL --output cryptomator.msi |
| 39 | + env: |
| 40 | + ASSETS_JSON: ${{ toJson(github.event.client_payload.release.assets ) }} |
| 41 | + - name: Update verify-installers.md |
| 42 | + shell: pwsh |
| 43 | + run: | |
| 44 | + $Thumbprint = (Get-AuthenticodeSignature -FilePath 'cryptomator.msi' -ErrorAction Stop).SignerCertificate.Thumbprint |
| 45 | +
|
| 46 | + $DocPath = 'docs/security/verify-installers.md' |
| 47 | + $Content = Get-Content -Path $DocPath -Raw |
| 48 | +
|
| 49 | + $CurrentThumbprintRegex = [regex] ([regex]::Escape($env:AUTOMATION_MARKER) + '`[A-F0-9]+`') |
| 50 | + $UpdatedContent = $CurrentThumbprintRegex.Replace($Content, ($env:AUTOMATION_MARKER + '`' + $Thumbprint + '`'), 1) |
| 51 | + if ($UpdatedContent -eq $Content) { |
| 52 | + throw 'Failed to update the current Windows thumbprint in verify-installers.md.' |
| 53 | + } |
| 54 | + $Content = $UpdatedContent |
| 55 | +
|
| 56 | + $MarkedRow = (Get-Content -Path $DocPath | Where-Object { $_.TrimStart().StartsWith('|') -and $_.Contains($env:AUTOMATION_MARKER) } | Select-Object -First 1) |
| 57 | + if ($null -eq $MarkedRow) { |
| 58 | + throw 'Failed to find the marked Windows certificate table row in verify-installers.md.' |
| 59 | + } |
| 60 | +
|
| 61 | + $PreviousRow = $MarkedRow.Substring(0, $MarkedRow.IndexOf($env:AUTOMATION_MARKER)).TrimEnd() + " |" |
| 62 | + $NewRow = "| $env:DESKTOP_VERSION |" + '`' + $Thumbprint + '`' + "$env:AUTOMATION_MARKER |" |
| 63 | + $Content = $Content.Replace($MarkedRow, $NewRow + "`r`n" + $PreviousRow) |
| 64 | +
|
| 65 | + Set-Content -Path $DocPath -Value $Content |
| 66 | + env: |
| 67 | + AUTOMATION_MARKER: '<!-- AUTOMATION MARKER FOR WORKFLOW -->' |
| 68 | + - name: Commit and push |
| 69 | + id: commit-and-push |
| 70 | + run: | |
| 71 | + git config user.name "cryptobot" |
| 72 | + git config user.email "cryptobot@users.noreply.github.com" |
| 73 | + git config push.autoSetupRemote true |
| 74 | + git stage docs/security/verify-installers.md |
| 75 | + if git diff --cached --quiet; then |
| 76 | + echo "No changes to commit" |
| 77 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 78 | + exit 0 |
| 79 | + fi |
| 80 | + git commit -m "Update Windows section for verifying installers for release ${DESKTOP_VERSION}" |
| 81 | + git push |
| 82 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 83 | + - name: Create pull request |
| 84 | + id: create-pr |
| 85 | + if: steps.commit-and-push.outputs.changed == 'true' |
| 86 | + run: | |
| 87 | + printf "Created by $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > pr_body.md |
| 88 | + PR_URL=$(gh pr create --title "Desktop release ${DESKTOP_VERSION}" --body-file pr_body.md) |
| 89 | + echo "url=$PR_URL" >> "$GITHUB_OUTPUT" |
| 90 | + env: |
| 91 | + GH_TOKEN: ${{ secrets.CRYPTOBOT_PR_TOKEN }} |
| 92 | + - name: Slack Notification |
| 93 | + if: steps.commit-and-push.outputs.changed == 'true' |
| 94 | + uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2.3.3 |
| 95 | + env: |
| 96 | + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_CRYPTOMATOR_DESKTOP }} |
| 97 | + SLACK_USERNAME: 'Cryptobot' |
| 98 | + SLACK_ICON: false |
| 99 | + SLACK_ICON_EMOJI: ':bot:' |
| 100 | + SLACK_CHANNEL: 'cryptomator-desktop' |
| 101 | + SLACK_TITLE: "Docs update PR created for release ${{ github.event.client_payload.version }} ." |
| 102 | + SLACK_MESSAGE: "See <${{ steps.create-pr.outputs.url }}|PR> on how to proceed." |
| 103 | + SLACK_FOOTER: false |
| 104 | + MSG_MINIMAL: true |
0 commit comments