name: Release # Builds a release from a commit on main, waits for a second person, then tags and publishes it. # # prepare Works out the version and the commit to build: the merge commit of an update/ PR, # or the commit given to a dispatch on main. # package-* Build the packages from that commit and attest each file's provenance. Nothing here # can create a tag or a release. # approve Waits in the release-approval environment for a member of # code-server-release-team other than the person who started the run. Then, as the # coder-release-publisher App (its key is in Cloud KMS, and only this job of main's # copy of this file may sign with it), it creates the tag and publishes the release # with the attested files. Releases are immutable once published. # # Publishing the release starts publish.yaml (npm, Docker Hub, GHCR, AUR), which checks that the # release came from here before it publishes anything. on: workflow_dispatch: inputs: version: description: "Version to release, e.g. 4.106.0 or 4.106.0-rc.1 (the major version is always 4)" type: string required: true commit: description: "Full SHA of the commit on main to release" type: string required: true prerelease: description: "Publish as a pre-release (npm, Docker and the AUR are not updated)" type: boolean default: false pull_request_target: types: - closed branches: - main permissions: {} # Releases never cancel each other. concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: false jobs: prepare: name: Prepare runs-on: ubuntu-24.04 if: >- (github.event_name == 'workflow_dispatch') || (github.event_name == 'pull_request_target' && github.event.pull_request.merged == true && startsWith(github.head_ref, 'update/')) permissions: contents: read outputs: version: ${{ steps.prepare.outputs.version }} commit: ${{ steps.prepare.outputs.commit }} prerelease: ${{ steps.prepare.outputs.prerelease }} steps: - name: Work out the version and the commit id: prepare env: GH_TOKEN: ${{ github.token }} EVENT: ${{ github.event_name }} INPUT_VERSION: ${{ inputs.version }} INPUT_COMMIT: ${{ inputs.commit }} INPUT_PRERELEASE: ${{ inputs.prerelease }} HEAD_REF: ${{ github.head_ref }} MERGE_COMMIT: ${{ github.event.pull_request.merge_commit_sha }} run: | set -euo pipefail fail() { echo "::error::$*"; exit 1; } # The tag is created by main's copy of this file only (the release-approval environment # and Cloud KMS both require it), so a dispatch from any other ref is refused here. [[ "$GITHUB_REF" == "refs/heads/main" ]] || fail "Run this workflow on main, not $GITHUB_REF." if [[ "$EVENT" == "pull_request_target" ]]; then # The merge commit of the update/ PR, which is on main. version="$HEAD_REF" commit="$MERGE_COMMIT" prerelease=false else version="$INPUT_VERSION" commit="$INPUT_COMMIT" prerelease="$INPUT_PRERELEASE" fi # update/1.106.0 or v4.106.0 becomes 4.106.0: code-server keeps VS Code's minor and patch. version=${version#update/} version=${version#v} version=4${version:1} [[ "$version" =~ ^4\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]] || fail "Version must look like 4.106.0 or 4.106.0-rc.1, got '$version'." [[ "$commit" =~ ^[0-9a-f]{40}$ ]] || fail "Commit must be a full 40-character SHA, got '$commit'." # The commit must be on main: main is identical to it or ahead of it. status="$(gh api "repos/$GITHUB_REPOSITORY/compare/$commit...main" --jq .status)" [[ "$status" == "identical" || "$status" == "ahead" ]] || fail "$commit is not on main." { echo "version=$version" echo "commit=$commit" echo "prerelease=$prerelease" } >> "$GITHUB_OUTPUT" echo "Releasing v$version from $commit (pre-release: $prerelease)." package-linux: name: ${{ format('linux-{0}', matrix.vscode_arch) }} runs-on: ubuntu-22.04 needs: prepare permissions: contents: read id-token: write # To sign the provenance attestations. attestations: write strategy: matrix: include: - npm_arch: x64 vscode_arch: x64 package_arch: amd64 - npm_arch: arm64 vscode_arch: arm64 package_arch: arm64 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ELECTRON_SKIP_BINARY_DOWNLOAD: 1 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 VERSION: ${{ needs.prepare.outputs.version }} # Set release package name. ARCH: ${{ matrix.package_arch }} # Cross-compile target. VSCODE_ARCH: ${{ matrix.vscode_arch }} npm_config_arch: ${{ matrix.npm_arch }} # Ensure native modules are built from source to avoid prebuilds and use # the correct version of glibc. Although we use pnpm, this npm flag # appears to still work for argon2, and VS Code has its own configuration # for building from source. npm_config_build_from_source: true # Gulp target name. # TODO: Pull from VSCODE_ARCH instead. VSCODE_TARGET: ${{ format('linux-{0}', matrix.vscode_arch) }} steps: - run: sudo apt update && sudo apt install -y libkrb5-dev - uses: awalsh128/cache-apt-pkgs-action@553a35bb8ebd9fcabcb1c9451aa4c98e1b4ca8a9 # latest with: packages: quilt version: 1.0 - name: Install nfpm run: | mkdir -p ~/.local/bin curl -sSfL https://github.com/goreleaser/nfpm/releases/download/v2.3.1/nfpm_2.3.1_`uname -s`_`uname -m`.tar.gz | tar -C ~/.local/bin -zxv nfpm echo "$HOME/.local/bin" >> $GITHUB_PATH - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 with: # The commit prepare checked is on main, never a PR head. ref: ${{ needs.prepare.outputs.commit }} submodules: true persist-credentials: false # A merged update/ PR starts a release through pull_request_target. allow-unsafe-pr-checkout: true - run: quilt push -a - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6 with: node-version-file: .node-version cache: pnpm cache-dependency-path: | pnpm-lock.yaml test/pnpm-lock.yaml - name: Build run: | cd lib/vscode/build pnpm install --frozen-lockfile cd .. source ./build/azure-pipelines/linux/setup-env.sh # Run preinstall script before root dependencies are installed # so that v8 headers are patched correctly for native modules. pnpm run preinstall cd ../.. pnpm install --frozen-lockfile pnpm run build pnpm run build:vscode # Platform-agnostic NPM package. - run: pnpm run release if: ${{ matrix.vscode_arch == 'x64' }} # Into release-packages with the platform packages, so the artifact is one flat directory. - run: mkdir -p release-packages && tar -czf release-packages/package.tar.gz release if: ${{ matrix.vscode_arch == 'x64' }} # Platform-specific release. - run: KEEP_MODULES=1 pnpm run release - run: pnpm run package # The approve job and publish.yaml check every file against these. - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 with: subject-path: release-packages/* - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: ${{ format('release-linux-{0}', matrix.vscode_arch) }} path: release-packages/* if-no-files-found: error package-macos: name: ${{ matrix.vscode_target }} runs-on: ${{ matrix.os }} needs: prepare permissions: contents: read id-token: write # To sign the provenance attestations. attestations: write strategy: matrix: include: - os: macos-15-intel vscode_target: darwin-x64 - os: macos-latest vscode_target: darwin-arm64 env: VSCODE_TARGET: ${{ matrix.vscode_target }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ needs.prepare.outputs.version }} # Ensure native modules are built from source to avoid prebuilds. # Although we use pnpm, this npm flag appears to still work for argon2, # and VS Code has its own configuration for building from source. npm_config_build_from_source: true steps: # The version of node-gyp we use depends on distutils but it was removed # in Python 3.12. It seems to be fixed in the latest node-gyp so when we # next update Node we can probably remove this. For now, install # setuptools since it contains distutils. - run: brew install python-setuptools quilt - name: Install nfpm run: | mkdir -p ~/.local/bin curl -sSfL https://github.com/goreleaser/nfpm/releases/download/v2.3.1/nfpm_2.3.1_`uname -s`_`uname -m`.tar.gz | tar -C ~/.local/bin -zxv nfpm echo "$HOME/.local/bin" >> $GITHUB_PATH - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 with: # The commit prepare checked is on main, never a PR head. ref: ${{ needs.prepare.outputs.commit }} submodules: true persist-credentials: false # A merged update/ PR starts a release through pull_request_target. allow-unsafe-pr-checkout: true - run: quilt push -a - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6 with: node-version-file: .node-version cache: pnpm cache-dependency-path: | pnpm-lock.yaml test/pnpm-lock.yaml - run: pnpm install --frozen-lockfile - run: pnpm run build - run: pnpm run build:vscode - run: KEEP_MODULES=1 pnpm run release - run: pnpm run test:native - run: pnpm run package # The approve job and publish.yaml check every file against these. - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 with: subject-path: release-packages/* - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: ${{ format('release-{0}', matrix.vscode_target) }} path: release-packages/* if-no-files-found: error package-windows: name: win32-x64 runs-on: windows-2022 needs: prepare permissions: contents: read id-token: write # To sign the provenance attestations. attestations: write defaults: run: shell: bash env: VSCODE_TARGET: win32-x64 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ needs.prepare.outputs.version }} # Ensure native modules are built from source to avoid prebuilds. # Although we use pnpm, this npm flag appears to still work for argon2, # and VS Code has its own configuration for building from source. npm_config_build_from_source: true OS: windows steps: # Git rewrites line endings on windows by default, which turns every # shell script the build is made of into one bash cannot read, and # every name in patches/series into one with a stray return. - name: Keep line endings as they are in the repository run: git config --global core.autocrlf false - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 with: # The commit prepare checked is on main, never a PR head. ref: ${{ needs.prepare.outputs.commit }} submodules: true persist-credentials: false # A merged update/ PR starts a release through pull_request_target. allow-unsafe-pr-checkout: true # quilt has no windows build. The patches are ordinary -p1 diffs # against the repository root, so git applies them in series order. - name: Apply patches run: | while read -r patch; do case "$patch" in '' | '#'*) continue ;; esac echo "applying $patch" git apply --whitespace=nowarn "patches/$patch" done < patches/series - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6 - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6 with: node-version-file: .node-version cache: pnpm cache-dependency-path: | pnpm-lock.yaml test/pnpm-lock.yaml # pnpm hands every script it runs to cmd, which cannot run the shell # scripts this repository is built out of. Point it at the same bash # the steps here use rather than at a path, which moves between # images. - name: Let pnpm run shell scripts run: echo "pnpm_config_script_shell=$(cygpath -w "$(command -v bash)")" >> $GITHUB_ENV # The build merges json by handing jq a process substitution, which # bash presents as a file under /dev/fd. The jq on this image is a # windows program and cannot open those, so it reads the second input # as nothing and the merge fails. Both the product and the package # merge go through here. - name: Let jq read what bash hands it run: | mkdir -p "$RUNNER_TEMP/shim" cat > "$RUNNER_TEMP/shim/jq" <<'SHIM' #!/usr/bin/env bash set -euo pipefail args=() for arg in "$@"; do case $arg in /dev/fd/* | /proc/*/fd/*) copy=$(mktemp) cat "$arg" > "$copy" args+=("$copy") ;; *) args+=("$arg") ;; esac done exec jq.exe "${args[@]}" SHIM chmod +x "$RUNNER_TEMP/shim/jq" echo "$RUNNER_TEMP/shim" >> $GITHUB_PATH # Stamping version details into the native binaries clears any # signature they arrived with and asks signtool whether there is one. # That only reads and removes, so it wants no certificate and signs # nothing. It just has to be findable, and the sdk carrying it is not # on the path. - name: Put signtool on the path run: | sdk=$(ls -d "/c/Program Files (x86)/Windows Kits/10/bin"/*/x64 | sort -V | tail -1) test -x "$sdk/signtool.exe" cygpath -w "$sdk" >> $GITHUB_PATH # build-release.sh copies the tree with rsync, which neither windows # nor the git bash on this image has. MSYS2 is already here, just not # on the path. - name: Install rsync shell: cmd run: C:\msys64\usr\bin\pacman -Sy --noconfirm --needed rsync # Only rsync crosses over. Putting msys2's /usr/bin in front instead # breaks the release step: pnpm on the path is a shell script whose # shebang reads /usr/bin/env bash, so with msys2 first it is msys2's # bash that runs it, and crossing into a second msys runtime does not # carry the environment. pnpm then sees no script-shell and falls back # to cmd, which cannot run ./ci/build/build-release.sh, and # KEEP_MODULES is dropped on the way. A forwarder avoids the whole # class: rsync is a native exe that loads its runtime from beside # itself, and nothing else on the path moves. - name: Reach rsync without moving the path run: | cat > "$RUNNER_TEMP/shim/rsync" <<'SHIM' #!/usr/bin/env bash exec /c/msys64/usr/bin/rsync.exe "$@" SHIM chmod +x "$RUNNER_TEMP/shim/rsync" - run: pnpm install --frozen-lockfile - run: pnpm run build - run: pnpm run build:vscode - run: KEEP_MODULES=1 pnpm run release # Of the two tars on this image it is git bash's GNU one that can # rename the tree's top directory as it archives; the windows bsdtar # is built without substitution support. Asserted rather than # assumed, since the two are interchangeable everywhere except here. - name: Package run: | case "$(tar --version | head -1)" in *GNU*) ;; *) echo "expected GNU tar for --transform, got $(tar --version | head -1)" >&2; exit 1 ;; esac pnpm run package # The approve job and publish.yaml check every file against these. - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 with: subject-path: release-packages/* - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: release-win32-x64 path: release-packages/* if-no-files-found: error approve: name: Approve, tag and publish the release needs: [prepare, package-linux, package-macos, package-windows] runs-on: ubuntu-24.04 # A member of code-server-release-team other than the person who started the run approves # here. Only this job of main's copy of this file, in this environment, may sign as # coder-release-publisher, the only actor the "Release tags (App only)" ruleset lets create # tags. environment: release-approval permissions: contents: read id-token: write # Cloud KMS signs the App's JWT. attestations: read env: VERSION: ${{ needs.prepare.outputs.version }} COMMIT: ${{ needs.prepare.outputs.commit }} PRERELEASE: ${{ needs.prepare.outputs.prerelease }} steps: # For the tags, the history of main and the changelog. Nothing from the tree runs here. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 with: fetch-depth: 0 fetch-tags: true persist-credentials: false # A merged update/ PR starts a release through pull_request_target. This checks out # main, not the PR head. allow-unsafe-pr-checkout: true # Here and not in prepare, because the tags can change while the run waits for approval. - name: Check the tag id: check run: | set -euo pipefail fail() { echo "::error::$*"; exit 1; } tag="v$VERSION" git merge-base --is-ancestor "$COMMIT" origin/main || fail "$COMMIT is not on main." # A re-run finds the tag the first attempt created. if existing="$(git rev-parse --verify --quiet "refs/tags/$tag^{commit}")"; then [[ "$existing" == "$COMMIT" ]] || fail "Tag $tag already exists at $existing, not at $COMMIT." echo "Tag $tag already exists at $COMMIT." echo "create_tag=false" >> "$GITHUB_OUTPUT" else # Versions only go up, and a release never comes from before the last one. latest="$(git tag --list 'v*' --sort=-version:refname | grep -E -m 1 '^v[0-9]+\.[0-9]+\.[0-9]+$' || true)" if [[ -n "$latest" ]]; then printf '%s\n' "${latest#v}" "${VERSION%%-*}" | sort -V -C || fail "$tag is not newer than $latest, the latest release." [[ "${VERSION%%-*}" != "${latest#v}" ]] || fail "$latest is already released." git merge-base --is-ancestor "$latest" "$COMMIT" || fail "$COMMIT is older than the commit released as $latest." fi echo "create_tag=true" >> "$GITHUB_OUTPUT" fi # The release notes are the changelog's Unreleased section at the released commit. mkdir -p "$RUNNER_TEMP/notes" git show "$COMMIT:CHANGELOG.md" | sed "/^## Unreleased/,/^## / ! d" | head -n -2 | tail -n +3 > "$RUNNER_TEMP/notes/release-notes.md" - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: pattern: release-* path: release-files merge-multiple: true # Every file must have been built and attested by this workflow, from main. - name: Verify the files env: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail shopt -s nullglob files=(release-files/*) [[ ${#files[@]} -gt 0 ]] || { echo "::error::No release files were built."; exit 1; } for f in "${files[@]}"; do gh attestation verify "$f" \ --repo "$GITHUB_REPOSITORY" \ --signer-workflow "$GITHUB_REPOSITORY/.github/workflows/release.yaml" \ --source-ref refs/heads/main \ --deny-self-hosted-runners done sha256sum "${files[@]}" | tee "$RUNNER_TEMP/notes/SHA256SUMS" - name: Generate release App token id: app_token uses: coder/github-app-token-action@00eaec58ee1bfea9c8b48655b7ab7470b07739e5 # main 2026-11-17 with: client-id: ${{ secrets.CODER_RELEASE_PUBLISHER_APP_ID }} kms-key: ${{ secrets.CODER_RELEASE_PUBLISHER_APP_KMS_KEY }} workload-identity-provider: ${{ secrets.APP_KEYS_WORKLOAD_ID_PROVIDER }} owner: coder repositories: code-server permissions: | contents: write workflows: write # An annotated tag, through the API: nothing is pushed from this job's checkout. - name: Create the tag if: ${{ steps.check.outputs.create_tag == 'true' }} env: GH_TOKEN: ${{ steps.app_token.outputs.token }} run: | set -euo pipefail tag="v$VERSION" tag_object="$(gh api "repos/$GITHUB_REPOSITORY/git/tags" \ -f tag="$tag" -f message="Release $tag" -f object="$COMMIT" -f type=commit \ --jq .sha)" gh api "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/tags/$tag" -f sha="$tag_object" >/dev/null echo "Created tag $tag at $COMMIT." # gh uploads the files to a new release and publishes it in the same command. The repository # has immutable releases, so the files and the tag are fixed from then on. Publishing a # (non-pre-)release starts publish.yaml. - name: Publish the release env: GH_TOKEN: ${{ steps.app_token.outputs.token }} run: | set -euo pipefail tag="v$VERSION" if gh release view "$tag" --repo "$GITHUB_REPOSITORY" --json isDraft --jq .isDraft 2>/dev/null | grep -qx false; then echo "Release $tag is already published." exit 0 fi # A draft for this tag is left over from an attempt that stopped before publishing. Only # this job's own drafts are replaced; anything else needs a person to look at it. gh api "repos/$GITHUB_REPOSITORY/releases" --paginate \ --jq ".[] | select(.draft and .tag_name == \"$tag\") | \"\(.id) \(.author.login)\"" | while read -r id author; do [[ "$author" == "coder-release-publisher[bot]" ]] || { echo "::error::Draft release $id for $tag was made by $author. Delete it, then re-run."; exit 1; } gh api -X DELETE "repos/$GITHUB_REPOSITORY/releases/$id" echo "Deleted the unfinished draft $id for $tag." done args=(--repo "$GITHUB_REPOSITORY" --verify-tag --title "$tag" --notes-file "$RUNNER_TEMP/notes/release-notes.md") if [[ "$PRERELEASE" == "true" ]]; then args+=(--prerelease) fi gh release create "$tag" "${args[@]}" release-files/* echo "Published https://github.com/$GITHUB_REPOSITORY/releases/tag/$tag"