|
7 | 7 | push: |
8 | 8 | branches: |
9 | 9 | - main |
| 10 | + - windowsSigning |
10 | 11 |
|
11 | 12 | jobs: |
12 | 13 | build-and-publish: |
@@ -49,11 +50,64 @@ jobs: |
49 | 50 | npm run postinstall |
50 | 51 | npm run build |
51 | 52 |
|
52 | | - - name: Publish Windows release |
| 53 | + - name: Get package version |
53 | 54 | if: matrix.platform == 'win' |
| 55 | + id: get-version |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + VERSION=$(node -p "require('./package.json').version") |
| 59 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 60 | + echo "artifact-name=Cobolt-Setup-$VERSION.exe" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | + - name: Check if release already exists |
| 63 | + if: matrix.platform == 'win' |
| 64 | + id: check-release |
| 65 | + shell: bash |
| 66 | + run: | |
| 67 | + RELEASE_EXISTS=$(gh release view "v${{ steps.get-version.outputs.version }}" --json assets,draft --jq 'if .draft == false then .assets | map(select(.name == "${{ steps.get-version.outputs.artifact-name }}")) | length else 0 end' 2>/dev/null || echo "0") |
| 68 | + echo "release-exists=$RELEASE_EXISTS" >> $GITHUB_OUTPUT |
54 | 69 | env: |
55 | 70 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
56 | | - run: npm exec electron-builder -- --publish --win |
| 71 | + |
| 72 | + - name: Build Windows executable (no publish) |
| 73 | + if: matrix.platform == 'win' |
| 74 | + run: npm exec electron-builder -- --win --publish=never |
| 75 | + |
| 76 | + - name: upload-unsigned-artifact |
| 77 | + id: upload-unsigned-artifact |
| 78 | + if: matrix.platform == 'win' && steps.check-release.outputs.release-exists == '0' |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: unsigned-installer |
| 82 | + retention-days: 1 |
| 83 | + path: release/build/Cobolt-Setup-${{ steps.get-version.outputs.version }}.exe |
| 84 | + |
| 85 | + - name: Sign artifact |
| 86 | + if: matrix.platform == 'win' && steps.check-release.outputs.release-exists == '0' |
| 87 | + uses: signpath/github-action-submit-signing-request@v1.1 |
| 88 | + with: |
| 89 | + api-token: ${{secrets.SIGNPATH_API_TOKEN}} |
| 90 | + organization-id: 3fe5dc9d-e6f6-4c25-83e5-70c5844441b9 |
| 91 | + project-slug: cobolt |
| 92 | + signing-policy-slug: test-signing |
| 93 | + github-artifact-id: ${{steps.upload-unsigned-artifact.outputs.artifact-id}} |
| 94 | + wait-for-completion: true |
| 95 | + output-artifact-directory: signed-artifacts |
| 96 | + |
| 97 | + - name: Download signed artifact |
| 98 | + if: matrix.platform == 'win' && steps.check-release.outputs.release-exists == '0' |
| 99 | + uses: actions/download-artifact@v4 |
| 100 | + with: |
| 101 | + name: signed-artifacts |
| 102 | + path: signed-artifacts/ |
| 103 | + |
| 104 | + - name: Publish Windows release with signed executable |
| 105 | + if: matrix.platform == 'win' && steps.check-release.outputs.release-exists == '0' |
| 106 | + env: |
| 107 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 108 | + run: | |
| 109 | + # Create or update release with signed executable |
| 110 | + gh release create "v${{ steps.get-version.outputs.version }}" signed-artifacts/${{ steps.get-version.outputs.artifact-name }} --title "v${{ steps.get-version.outputs.version }}" --notes "Release v${{ steps.get-version.outputs.version }}" || gh release upload "v${{ steps.get-version.outputs.version }}" signed-artifacts/${{ steps.get-version.outputs.artifact-name }} --clobber |
57 | 111 |
|
58 | 112 | - name: Publish macOS release |
59 | 113 | if: matrix.platform == 'mac' |
|
0 commit comments