Skip to content

feat: Windows Signing #107

feat: Windows Signing

feat: Windows Signing #107

Workflow file for this run

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
- 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: 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: Download signed artifact
if: matrix.platform == 'win' && steps.check-release.outputs.release-exists == '0'
uses: actions/download-artifact@v4
with:
name: signed-artifacts
path: signed-artifacts/
- 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 "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
- 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