Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 126 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@ jobs:
compile:
name: ${{matrix.buildname}}
runs-on: ${{matrix.os}}
# SignPath Foundation requires a manual approval for every signing request,
# so only builds that will be released may ask for one, and whether a
# development build releases is only known once check-new-games has run.
needs: check-new-games
# actions: read is SignPath's - its action hands the job's GITHUB_TOKEN to
# SignPath, which uses it to read job details and download the artifact
permissions:
actions: read
contents: read
env:
# Deliberately not conditional on the SignPath secrets being set: a build
# that should be signed fails if they are missing, rather than quietly
# publishing unsigned launchers.
# Signed: tags, and development builds that check-new-games will release.
# A manual workflow_dispatch is signed on any branch too, so a SignPath
# change can be tried out before it is merged - it still needs approving.
SIGNPATH_SIGNING_ENABLED: ${{ github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' && github.repository == 'Mudlet/bootstrap' && (startsWith(github.ref, 'refs/tags/') || needs.check-new-games.outputs.new-games == 'true' || github.event_name == 'workflow_dispatch') }}
# test-signing is left for verifying a SignPath configuration change by
# hand; its self-signed certificate isn't trusted, so the verify step
# fails such a build before anything is published.
SIGNPATH_POLICY_SLUG: 'release-signing'
# The version the release will carry, written into each Windows launcher
# and enforced by the artifact configuration's product-version.
RELEASE_TAG: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || needs.check-new-games.outputs.tag }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -91,6 +115,21 @@ jobs:
chmod +x ./CI/build-qt-statemachine.sh
./CI/build-qt-statemachine.sh

# Builds that aren't released get 0.0.0. The launcher's version resource
# takes four numbers, so a tag must be vX.Y.Z.
- name: (Windows) Set launcher version
if: runner.os == 'Windows'
shell: bash
run: |
version="${RELEASE_TAG#v}"
version="${version:-0.0.0}"
if ! [[ "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Release tag ${RELEASE_TAG} is not of the form vX.Y.Z."
exit 1
fi
echo "Launcher version: ${version}"
echo "LAUNCHER_VERSION=${version}" >> "$GITHUB_ENV"

- name: (Windows) Setup MSYS2
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
Expand Down Expand Up @@ -166,25 +205,97 @@ jobs:
shell: msys2 {0}
run: $GITHUB_WORKSPACE/CI/package-win.sh

- name: (Windows) Login to Azure
uses: azure/login@v2
if: runner.os == 'Windows' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' && github.repository == 'Mudlet/bootstrap'
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: (Windows) Prepare launchers for signing
if: runner.os == 'Windows'
shell: msys2 {0}
run: $GITHUB_WORKSPACE/CI/prepare-signing-win.sh

- name: Get Azure access token for code signing
- name: (Windows) Check SignPath secrets
if: runner.os == 'Windows' && env.SIGNPATH_SIGNING_ENABLED == 'true'
shell: bash
env:
SIGNPATH_API_TOKEN: ${{secrets.SIGNPATH_API_TOKEN}}
SIGNPATH_ORGANIZATION_ID: ${{secrets.SIGNPATH_ORGANIZATION_ID}}
run: |
if [ -z "${SIGNPATH_API_TOKEN}" ] || [ -z "${SIGNPATH_ORGANIZATION_ID}" ]; then
echo "::error::This build must be signed, but SIGNPATH_API_TOKEN or SIGNPATH_ORGANIZATION_ID is not set."
exit 1
fi

# Every game's launcher goes up in one artifact, and the artifact
# configuration's MudletInstaller-*.exe wildcard covers the lot, so a
# GameList of any length still costs a single signing request.
- name: (Windows) Upload unsigned launchers for signing
id: upload-unsigned-launchers
if: runner.os == 'Windows' && env.SIGNPATH_SIGNING_ENABLED == 'true'
uses: actions/upload-artifact@v6
with:
name: unsigned-launchers
path: ${{env.SIGNING_DIR}}
retention-days: 1
# so re-running a job whose signing request failed can upload again
overwrite: true

# Extracts the signed launchers into signed-launchers/, which
# prepare-signing-win.sh made sure does not exist yet. The action extracts
# over whatever is already in its output directory, so it must not be the
# staging directory: the unsigned copies there would pass deploy-win.sh's
# check that a signed copy exists.
- name: (Windows) Sign launchers with SignPath
id: sign-launchers
if: steps.upload-unsigned-launchers.outcome == 'success'
uses: signpath/github-action-submit-signing-request@v2
with:
api-token: ${{secrets.SIGNPATH_API_TOKEN}}
organization-id: ${{secrets.SIGNPATH_ORGANIZATION_ID}}
project-slug: 'bootstrap'
signing-policy-slug: ${{env.SIGNPATH_POLICY_SLUG}}
artifact-configuration-slug: 'launchers'
github-artifact-id: ${{steps.upload-unsigned-launchers.outputs.artifact-id}}
parameters: |
version: ${{ toJSON(format('{0}.0', env.LAUNCHER_VERSION)) }}
wait-for-completion: true
output-artifact-directory: ${{github.workspace}}/signed-launchers
# Leaves time for an approver to respond, within GitHub's 6 hour job limit
wait-for-completion-timeout-in-seconds: 14400

# Don't take the signing request's success on trust: check that every
# launcher that went in came back with a valid signature before anything is
# published.
- name: (Windows) Verify launcher signatures
if: steps.sign-launchers.outcome == 'success'
shell: pwsh
if: runner.os == 'Windows' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' && github.repository == 'Mudlet/bootstrap'
run: |
$token = (az account get-access-token --resource https://codesigning.azure.net | ConvertFrom-Json).accessToken
"::add-mask::$token"
"AZURE_ACCESS_TOKEN=$token" | Add-Content -Path $env:GITHUB_ENV
$staged = Get-ChildItem -Path "$env:GITHUB_WORKSPACE\signing-launchers" -Filter 'MudletInstaller-*.exe'
if ($staged.Count -eq 0) {
Write-Output "::error::No launchers were staged for signing."
exit 1
}
$failed = 0
foreach ($launcher in $staged) {
$signedPath = Join-Path "$env:GITHUB_WORKSPACE\signed-launchers" $launcher.Name
if (-not (Test-Path -LiteralPath $signedPath)) {
Write-Output "::error::SignPath returned no $($launcher.Name)."
$failed++
continue
}
$signature = Get-AuthenticodeSignature -LiteralPath $signedPath
if ($signature.Status -ne 'Valid') {
Write-Output "::error::$($launcher.Name) signature status is $($signature.Status): $($signature.StatusMessage)"
$failed++
continue
}
Write-Output "$($launcher.Name): signed by $($signature.SignerCertificate.Subject)"
}
if ($failed -gt 0) {
Write-Output "::error::$failed of $($staged.Count) launchers are not validly signed."
exit 1
}
Write-Output "All $($staged.Count) launchers are validly signed."

- name: (Windows) Deploy
if: runner.os == 'Windows'
shell: msys2 {0}
env:
AZURE_ACCESS_TOKEN: ${{ env.AZURE_ACCESS_TOKEN }}
run: $GITHUB_WORKSPACE/CI/deploy-win.sh

- name: (macOS) Prep for Artifact Upload
Expand Down Expand Up @@ -276,9 +387,12 @@ jobs:
- name: Checkout Source (for GameList.txt)
uses: actions/checkout@v6

# Only the packaged launchers: the Windows job's unsigned-launchers
# artifact must never be picked up and published.
- name: Download all platform artifacts
uses: actions/download-artifact@v7
with:
pattern: MudletInstaller-*
path: ./platform-artifacts

- name: Organize launchers by game
Expand Down
23 changes: 23 additions & 0 deletions .signpath/artifact-configuration-launchers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- MIRROR ONLY. SignPath applies the configuration stored in its web app
against the 'launchers' slug of the bootstrap project; nothing in CI uploads
this file. Editing it here changes nothing until the portal matches. -->
<!-- GitHub Actions packages artifacts as ZIP files, so zip-file is the root element -->
<artifact-configuration xmlns="http://signpath.io/artifact-configuration/v1">
<parameters>
<!-- X.Y.Z.0, set by the workflow from the release tag -->
<parameter name="version" required="true" />
</parameters>
<zip-file>
<!-- One launcher per game in GameList.txt, all built from the same source
and gathered into a single artifact by CI/prepare-signing-win.sh, so
the whole list is covered by one signing request. A wildcard matches
exactly one file unless max-matches says otherwise.
SignPath Foundation requires the product name and version to be
enforced; MudletInstaller.rc.in sets them. -->
<pe-file path="MudletInstaller-*.exe" max-matches="unbounded"
product-name="MudletInstaller" product-version="${version}">
<authenticode-sign/>
</pe-file>
</zip-file>
</artifact-configuration>
12 changes: 12 additions & 0 deletions .signpath/policies/bootstrap/release-signing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SignPath Policy for Release Signing
# This policy is used with the production certificate for official releases
#
# Policy enforcements:
# - Artifacts must be built by GitHub Actions workflows
# - Build must originate from the Mudlet/bootstrap repository
# - Only GitHub-hosted runners are allowed (for open source verification)

github-policies:
runners:
allowed_groups:
- 'GitHub Actions'
12 changes: 12 additions & 0 deletions .signpath/policies/bootstrap/test-signing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SignPath Policy for Test Signing
# This policy is used with the self-signed test certificate during setup verification
#
# Policy enforcements:
# - Artifacts must be built by GitHub Actions workflows
# - Build must originate from the Mudlet/bootstrap repository
# - Only GitHub-hosted runners are allowed (for open source verification)

github-policies:
runners:
allowed_groups:
- 'GitHub Actions'
1 change: 1 addition & 0 deletions CI/build-win.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ EOF
-DCMAKE_PREFIX_PATH="$(cygpath -w $Qt6_PREFIX)" \
-DQt6LinguistTools_DIR="${QT_LINGUIST_DIR}" \
-DCMAKE_IGNORE_PATH="${MSYSTEM_PREFIX}/lib/cmake/Qt6" \
-DLAUNCHER_VERSION="${LAUNCHER_VERSION:-0.0.0}" \
..

if [ $? -ne 0 ]; then
Expand Down
59 changes: 32 additions & 27 deletions CI/deploy-win.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
###########################################################################

# Version: 2.0.0 Rework to build on an MSYS2 MINGW64 Github workflow
# Version: 3.0.0 Windows signing moved from Azure Trusted Signing to
# SignPath. jsign ran here and signed each launcher in place;
# SignPath instead signs an artifact the workflow uploads
# between prepare-signing-win.sh and this script, so all
# that is left to do here is pick the signed launchers back
# up before publishing them.
# 2.0.0 Rework to build on an MSYS2 MINGW64 Github workflow

# Exit codes:
# 0 - Everything is fine. 8-)
Expand All @@ -28,6 +34,8 @@
# 3 - Not used
# 4 - nuget error
# 5 - squirrel error
# 7 - Signing was enabled but a launcher's signed copy is missing or could
# not be put in place to publish

if [ "${MSYSTEM}" != "CLANG64" ]; then
echo "Please run this script from a CLANG64 type bash terminal."
Expand Down Expand Up @@ -58,17 +66,15 @@ else
echo "=== Building for regular build ==="
fi

# Set up Java for code signing if Azure token is available
if [ -n "${AZURE_ACCESS_TOKEN}" ]; then
echo "=== Setting up Java 21 for signing ==="
# Java is installed by default, we just need to select which version to use:
JAVA_HOME="$(cygpath -au "${JAVA_HOME_21_X64}")"
export JAVA_HOME
export PATH="${JAVA_HOME}/bin:${PATH}"
JAVA_JAR_WINPATHFILE="$(cygpath -aw "${GITHUB_WORKSPACE}/CI/jsign-7.0-SNAPSHOT.jar")"
echo "Java setup complete for code signing"
# Where the workflow's SignPath steps ran, the signed launchers are here.
# prepare-signing-win.sh removed this directory before signing, so anything in
# it came back from SignPath.
signedDir="${GITHUB_WORKSPACE_UNIX_PATH}/signed-launchers"

if [ "${SIGNPATH_SIGNING_ENABLED}" = "true" ]; then
echo "=== Publishing SignPath-signed launchers ==="
else
echo "=== Code signing skipped - no Azure token provided ==="
echo "=== Code signing skipped - publishing unsigned launchers ==="
fi

while IFS= read -r line || [[ -n "$line" ]]; do
Expand All @@ -79,22 +85,21 @@ while IFS= read -r line || [[ -n "$line" ]]; do

cd "$PACKAGE_DIR" || exit 1

# Remove specific file types from the directory
rm ./*.cpp ./*.o

mv "$PACKAGE_DIR/MudletInstaller.exe" "MudletInstaller-${gameName}.exe"

# Sign the executable if Azure token is available
if [ -n "${AZURE_ACCESS_TOKEN}" ]; then
echo "=== Signing MudletInstaller-${gameName}.exe ==="
EXECUTABLE_WINPATH="$(cygpath -aw "${PACKAGE_DIR}/MudletInstaller-${gameName}.exe")"
java.exe -jar "${JAVA_JAR_WINPATHFILE}" \
--storetype TRUSTEDSIGNING \
--keystore eus.codesigning.azure.net \
--storepass "${AZURE_ACCESS_TOKEN}" \
--alias Mudlet/Mudlet \
"${EXECUTABLE_WINPATH}"
echo "Signing completed for MudletInstaller-${gameName}.exe"
# The workflow has already checked every signature; this guards against
# publishing the unsigned launcher left in PACKAGE_DIR if the signed copy is
# missing or can't be put in its place.
if [ "${SIGNPATH_SIGNING_ENABLED}" = "true" ]; then
signedLauncher="${signedDir}/MudletInstaller-${gameName}.exe"
if [ ! -f "${signedLauncher}" ]; then
echo "ERROR: signing was enabled but there is no signed"
echo "MudletInstaller-${gameName}.exe in ${signedDir}."
exit 7
fi
if ! cp "${signedLauncher}" "${PACKAGE_DIR}/MudletInstaller-${gameName}.exe"; then
echo "ERROR: could not replace the unsigned MudletInstaller-${gameName}.exe"
echo "with its signed copy."
exit 7
fi
fi

# Move packaged files to the upload directory
Expand Down
Binary file removed CI/jsign-7.0-SNAPSHOT.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion CI/organize-launchers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if [ ! "$(ls -A organized-releases 2>/dev/null)" ]; then

# Look for game launcher files
case "$platform_name" in
*MINGW64*|*Windows*)
*CLANG64*|*MINGW64*|*Windows*)
echo " Looking for Windows executables..."
find "$platform_dir" -name "*.exe" -type f | while read launcher; do
if [ -f "$launcher" ]; then
Expand Down
Loading
Loading