feat: Windows Signing #113
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish | |
| permissions: | |
| contents: write | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - windowsSigning | |
| jobs: | |
| build-and-publish: | |
| if: ${{ github.repository_owner == 'platinum-hill' }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: windows-latest | |
| platform: win | |
| - os: macos-latest | |
| platform: mac | |
| - os: ubuntu-latest | |
| platform: linux | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout git repo | |
| uses: actions/checkout@v3 | |
| - name: Install Node and NPM | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 22.14.0 | |
| cache: npm | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install setuptools wheel | |
| - name: Install and build | |
| run: | | |
| npm install | |
| npm run postinstall | |
| npm run build | |
| - name: Get package version | |
| if: matrix.platform == 'win' | |
| id: get-version | |
| shell: bash | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "artifact-name=Cobolt-Setup-$VERSION.exe" >> $GITHUB_OUTPUT | |
| - name: Check if release already exists | |
| if: matrix.platform == 'win' | |
| id: check-release | |
| shell: bash | |
| run: | | |
| 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") | |
| echo "release-exists=$RELEASE_EXISTS" >> $GITHUB_OUTPUT | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build Windows executable (no publish) | |
| if: matrix.platform == 'win' | |
| run: npm exec electron-builder -- --win --publish=never | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: upload-unsigned-artifact | |
| id: upload-unsigned-artifact | |
| if: matrix.platform == 'win' && steps.check-release.outputs.release-exists == '0' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cobolt-unsigned-installer | |
| retention-days: 1 | |
| path: | | |
| release/build/Cobolt-Setup-${{ steps.get-version.outputs.version }}.exe | |
| - name: Sign artifact | |
| if: matrix.platform == 'win' && steps.check-release.outputs.release-exists == '0' | |
| uses: signpath/github-action-submit-signing-request@v1.1 | |
| with: | |
| api-token: ${{secrets.SIGNPATH_API_TOKEN}} | |
| organization-id: 3fe5dc9d-e6f6-4c25-83e5-70c5844441b9 | |
| project-slug: cobolt | |
| signing-policy-slug: test-signing | |
| github-artifact-id: ${{steps.upload-unsigned-artifact.outputs.artifact-id}} | |
| wait-for-completion: true | |
| output-artifact-directory: signed-artifacts | |
| - name: Update latest.yml with signed artifact details | |
| if: matrix.platform == 'win' && steps.check-release.outputs.release-exists == '0' | |
| shell: bash | |
| run: | | |
| # Get the size of the signed executable | |
| SIGNED_SIZE=$(stat -c%s "signed-artifacts/${{ steps.get-version.outputs.artifact-name }}") | |
| # Update latest.yml to point to signed artifacts | |
| if [ -f "release/build/latest.yml" ]; then | |
| # Update the file reference and size in latest.yml | |
| sed -i "s|size: [0-9]*|size: $SIGNED_SIZE|g" release/build/latest.yml | |
| # Copy updated latest.yml to signed-artifacts directory | |
| cp release/build/latest.yml signed-artifacts/ | |
| fi | |
| - name: Publish Windows release with signed executable | |
| if: matrix.platform == 'win' && steps.check-release.outputs.release-exists == '0' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Create or update release with signed executable | |
| gh release create "${{ steps.get-version.outputs.version }}" signed-artifacts/${{ steps.get-version.outputs.artifact-name }} signed-artifacts/latest.yml --title "v${{ steps.get-version.outputs.version }}" --notes "Release v${{ steps.get-version.outputs.version }}" --draft || (gh release upload "v${{ steps.get-version.outputs.version }}" signed-artifacts/${{ steps.get-version.outputs.artifact-name }} --clobber && gh release upload "v${{ steps.get-version.outputs.version }}" signed-artifacts/latest.yml --clobber) | |
| - name: Publish macOS release | |
| if: matrix.platform == 'mac' | |
| env: | |
| APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASS }} | |
| APPLE_ID: ${{ secrets.APPLE_ID }} | |
| APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
| CSC_LINK: ${{ secrets.CSC_LINK }} | |
| CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npm exec electron-builder -- --publish always --mac --linux | |
| - name: Publish Linux release | |
| if: matrix.platform == 'linux' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npm exec electron-builder -- --publish always --linux |