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
5 changes: 5 additions & 0 deletions .github/workflows/_desktop-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ jobs:

build-windows:
name: Build and Release Windows
# The EV signing service account (coder-ci) only trusts jobs in this
# environment, which only main and v* tags may use. v* tags are not
# protected in this repository, so callers must only pass a commit on main
# (release.yml's preflight resolves the tag and checks this).
environment: code-signing
Comment thread
deansheather marked this conversation as resolved.
Resolved
runs-on: windows-latest
permissions:
contents: write # Upload release assets
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,10 @@ jobs:
# Windows builds are slow - only run in merge queue and main pushes, not on every PR push
if: ${{ (github.event_name == 'merge_group' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && (needs.changes.outputs.src == 'true' || needs.changes.outputs.config == 'true') }}
runs-on: windows-latest
# Pushes to main sign with the EV key, whose service account (coder-ci)
# only trusts jobs in code-signing. Merge queue builds run the queued PR's
# code, so they get no environment and stay unsigned.
environment: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'code-signing' || '' }}
Comment thread
deansheather marked this conversation as resolved.
Resolved
permissions:
contents: read
id-token: write # GCP workload identity for Windows code signing
Expand Down
39 changes: 35 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ jobs:
preflight:
name: Validate release target
runs-on: ubuntu-latest
outputs:
# The commit every build job checks out: the release tag's commit, which
# must be on main. desktop-builds signs in the code-signing environment,
# which is granted from the dispatch ref (main), and v* tags are not
# protected, so it must not build a commit that never reached main.
ref: ${{ steps.target.outputs.ref }}
steps:
- name: Ensure release tag context
id: target
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_TAG: ${{ inputs.tag }}
GH_TOKEN: ${{ github.token }}
run: |
if [ -z "$RELEASE_TAG" ]; then
echo "::error::RELEASE_TAG is empty. Ensure this workflow runs on a release event or refs/tags/* ref."
Expand All @@ -39,7 +47,30 @@ jobs:
fi
fi

echo "Publishing tag $RELEASE_TAG"
if [ -n "$INPUT_TAG" ]; then
if [[ ! "$INPUT_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then
echo "::error::tag input must be a release tag like v1.2.3, got '$INPUT_TAG'"
exit 1
fi
tag_ref="refs/tags/$INPUT_TAG"
else
tag_ref="$GITHUB_REF"
fi

# Pin the build to the tag's commit, so moving the tag mid-run has
# no effect, and require that commit to be on main.
if ! sha=$(gh api "repos/$GITHUB_REPOSITORY/commits/$tag_ref" --jq .sha); then
echo "::error::tag ${tag_ref#refs/tags/} does not exist"
exit 1
fi
status=$(gh api "repos/$GITHUB_REPOSITORY/compare/$sha...main" --jq .status)
if [ "$status" != "ahead" ] && [ "$status" != "identical" ]; then
echo "::error::${tag_ref#refs/tags/} points at $sha, which is not on main"
exit 1
fi
echo "ref=$sha" >> "$GITHUB_OUTPUT"

echo "Publishing tag $RELEASE_TAG from $sha (${tag_ref#refs/tags/})"

desktop-builds:
name: Build and Release Desktop Apps
Expand All @@ -49,7 +80,7 @@ jobs:
id-token: write # GCP workload identity for Windows code signing
uses: ./.github/workflows/_desktop-release.yml
with:
ref: ${{ inputs.tag || github.ref }}
ref: ${{ needs.preflight.outputs.ref }}
release_tag: ${{ inputs.tag || github.event.release.tag_name || github.ref_name }}
secrets: inherit # zizmor: ignore[secrets-inherit] -- reusable workflow needs platform signing secrets

Expand All @@ -62,7 +93,7 @@ jobs:
packages: write # Push to GHCR
uses: ./.github/workflows/_docker-release.yml
with:
ref: ${{ inputs.tag || github.ref }}
ref: ${{ needs.preflight.outputs.ref }}
version: ${{ inputs.tag || github.event.release.tag_name || github.ref_name }}
is_latest: true

Expand All @@ -76,7 +107,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: ${{ inputs.tag || github.ref }}
ref: ${{ needs.preflight.outputs.ref }}
fetch-depth: 0 # Required for git describe to find tags
persist-credentials: false

Expand Down
Loading