From 74c3d72230be76b1d26ea4a03f10562011d94e2d Mon Sep 17 00:00:00 2001 From: Adam Chrapkowski Date: Wed, 25 Nov 2026 13:43:38 +0100 Subject: [PATCH 1/2] Open a release PR every 4 weeks and tag releases on merge scip-python ships as a Docker image, so it needs regular rebuilds to pick up Alpine security fixes even when the code doesn't change. A scheduled workflow now opens a patch release PR every 4 weeks on Monday (in the same weeks as scip-clang) with the version bump and a CHANGELOG entry listing the commits since the last tag. Merging any version bump to `scip` now tags the release and starts scip-release.yml, replacing the manual tag push. Tags pushed by a workflow don't trigger other workflows, so the tag workflow dispatches the release; npm trusted publishing accepts that, since the publishing workflow is still scip-release.yml. Dockerfile.autoindex also runs `apk upgrade`, which currently picks up OpenSSL, zlib, krb5 and libffi updates the pinned base image lacks. GitHub holds CI on PRs opened by GitHub Actions, so the release PR needs someone to select "Approve workflows to run" before it can merge. The Docker image build now also runs for package.json and lockfile changes, so release PRs build the image before they tag. A release whose Docker push fails can be published again by rerunning the tag workflow: scip-release.yml skips npm when the registry already has the version. Because a rerun can now reach the Docker push, scip-release.yml also fails when the tag doesn't match package.json and only moves `latest` and `autoindex` for the newest tag, and the tag workflow rejects versions that aren't M.N.P or aren't newer than the latest tag. When no release PR is open, a leftover release branch is replaced instead of failing the push. dev/bump_version.sh is replaced by dev/prepare_release.sh; it pushed straight to the protected branch and force-pushed tags. --- .github/workflows/scheduled-release.yml | 69 +++++++++++++++++++++++++ .github/workflows/scip-docker.yml | 3 ++ .github/workflows/scip-release.yml | 41 +++++++++++++-- .github/workflows/tag-release.yml | 52 +++++++++++++++++++ Dockerfile.autoindex | 3 +- dev/bump_version.sh | 30 ----------- dev/prepare_release.sh | 46 +++++++++++++++++ packages/pyright-scip/CONTRIBUTING.md | 20 +++++-- 8 files changed, 225 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/scheduled-release.yml create mode 100644 .github/workflows/tag-release.yml delete mode 100755 dev/bump_version.sh create mode 100755 dev/prepare_release.sh diff --git a/.github/workflows/scheduled-release.yml b/.github/workflows/scheduled-release.yml new file mode 100644 index 000000000..22ba1cf4a --- /dev/null +++ b/.github/workflows/scheduled-release.yml @@ -0,0 +1,69 @@ +name: scheduled-release + +# Opens a patch release PR every 4 weeks on Monday, even without code changes, +# so the Docker image is rebuilt with the latest Alpine package updates. +# Merging the PR publishes the release (see tag-release.yml). +on: + # Cron can't express "every 4 weeks", so this runs every Monday + # and skips weeks that aren't a multiple of 4 after RELEASE_MONDAY. + schedule: + - cron: '0 9 * * 1' + workflow_dispatch: + +env: + RELEASE_MONDAY: '2026-11-23' + +permissions: + contents: write + pull-requests: write + +jobs: + open-release-pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + # Release from scip even when dispatched from another branch. + ref: scip + fetch-depth: 0 + + - name: Open release PR + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + if [ "$GITHUB_EVENT_NAME" = "schedule" ]; then + DAYS=$(( ($(date -u +%s) - $(date -u -d "$RELEASE_MONDAY" +%s)) / 86400 )) + if (( DAYS % 28 != 0 )); then + echo "Not a release week ($DAYS days after $RELEASE_MONDAY)" + exit 0 + fi + fi + + ./dev/prepare_release.sh + VERSION="$(jq -r .version packages/pyright-scip/package.json)" + BRANCH="release/v$VERSION" + + # A separate assignment, so a failed lookup stops the job under set -e. + OPEN_PR="$(gh pr list --head "$BRANCH" --state open --json number --jq '.[].number')" + if [ -n "$OPEN_PR" ]; then + echo "::warning::PR #$OPEN_PR for $BRANCH is already open; merge or close it first." + exit 0 + fi + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout -b "$BRANCH" + git commit -am "release/v$VERSION" + # With no open PR, a leftover branch (from a run that failed after pushing, + # or a PR closed without deleting it) is stale, so replace it. + git push --force origin "$BRANCH" + + gh pr create --base scip --head "$BRANCH" --title "release/v$VERSION" --body "$(cat <>"$GITHUB_OUTPUT" - name: Build and push id: docker_build_autoindex uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 @@ -33,7 +67,4 @@ jobs: context: . file: Dockerfile.autoindex push: true - tags: | - sourcegraph/scip-python:autoindex - sourcegraph/scip-python:latest - sourcegraph/scip-python:${{ github.ref_name }} + tags: ${{ steps.docker_tags.outputs.tags }} diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml new file mode 100644 index 000000000..a7d97431a --- /dev/null +++ b/.github/workflows/tag-release.yml @@ -0,0 +1,52 @@ +name: tag-release + +# Tags a release when a version bump in package.json lands on scip. +on: + push: + branches: + - scip + paths: + - 'packages/pyright-scip/package.json' + +permissions: + contents: write + actions: write + +jobs: + tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + + - name: Tag release + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + TAG="v$(jq -r .version packages/pyright-scip/package.json)" + if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then + # A rerun of this workflow finds its own tag; publish again. + # Other package.json changes, such as dependency bumps, find an older tag. + if [ "$(git rev-parse "$TAG^{commit}")" != "$GITHUB_SHA" ]; then + echo "$TAG already exists on an earlier commit; nothing to release" + exit 0 + fi + else + # Catch hand-edited versions, such as v0.6.9 or an older release. + LATEST="$(git tag --list 'v[0-9]*' | sort -V | tail -n 1)" + if ! [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || + [ "$(printf '%s\n%s\n' "$LATEST" "$TAG" | sort -V | tail -n 1)" != "$TAG" ]; then + echo "$TAG is not of the form vM.N.P or isn't newer than $LATEST" + exit 1 + fi + git tag "$TAG" "$GITHUB_SHA" + git push origin "$TAG" + fi + + # Tags pushed with GITHUB_TOKEN don't trigger workflows, so start the + # release for the tag explicitly. Don't call scip-release.yml as a + # reusable workflow instead: npm trusted publishing would then check + # this workflow's file name and reject the publish. + gh workflow run scip-release.yml --ref "$TAG" diff --git a/Dockerfile.autoindex b/Dockerfile.autoindex index b79ed53fe..69bbb2312 100644 --- a/Dockerfile.autoindex +++ b/Dockerfile.autoindex @@ -1,8 +1,9 @@ FROM nikolaik/python-nodejs:python3.11-nodejs24-alpine@sha256:f5f3688c6a25b348ed196cc159bf7fa0538454a7d8775560bc4052d57c971645 +# Upgrade the base image's packages too, so every rebuild picks up Alpine security updates. # ca-certificates 20261020-r0 distrusts the compromised eMudhra intermediates; # the base image ships an older version. -RUN apk add --no-cache --upgrade git bash curl 'ca-certificates>=20261020-r0' 'ca-certificates-bundle>=20261020-r0' +RUN apk upgrade --no-cache && apk add --no-cache --upgrade git bash curl 'ca-certificates>=20261020-r0' 'ca-certificates-bundle>=20261020-r0' # Install scip-python from this checkout (run `npm pack` in packages/pyright-scip # first), not from npm: npm holds new versions for malware scanning, so a # release build would otherwise install the previous version. diff --git a/dev/bump_version.sh b/dev/bump_version.sh deleted file mode 100755 index ebf6ebe7a..000000000 --- a/dev/bump_version.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/bash - -set -e - -if ! git diff --quiet; then - echo "=======================================" - echo " Please clean up your dirty repo" - echo "=======================================" - exit 1 -fi - -read -p "set version to > " -r VERSION - -if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]$ ]]; then - echo "valid version: $VERSION" -else - echo "Invalid semver specifier. Expected 'v0.0.0'" - exit 1 -fi - -# shellcheck disable=SC2001 -# Use sed, cause it's OK -PACKAGE_VERSION=$(echo "$VERSION" | sed 's/^v//') -eval "cd packages/pyright-scip/ && yarn version --no-git-tag-version --new-version $PACKAGE_VERSION" - -git commit -am "bump version: $VERSION" -git push - -git tag -fa "$VERSION" -m "$VERSION" -git push -f origin "$VERSION" diff --git a/dev/prepare_release.sh b/dev/prepare_release.sh new file mode 100755 index 000000000..0dbdb8f89 --- /dev/null +++ b/dev/prepare_release.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Bumps the scip-python version and adds an editable CHANGELOG entry +# listing the commits since the latest release tag. +# +# Inputs: +# NEW_VERSION (optional) should be a string M.N.P. Defaults to the +# next patch version after the latest release tag. + +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/../packages/pyright-scip" + +LAST_TAG="$(git describe --tags --abbrev=0 --match 'v[0-9]*')" +IFS=. read -r MAJOR MINOR PATCH <<<"${LAST_TAG#v}" +NEW_VERSION="${NEW_VERSION:-$MAJOR.$MINOR.$((PATCH + 1))}" + +if ! [[ "$NEW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "error: NEW_VERSION=$NEW_VERSION is not of the form M.N.P" + exit 1 +fi +if [ "$(printf '%s\n%s\n' "${LAST_TAG#v}" "$NEW_VERSION" | sort -V | tail -n 1)" != "$NEW_VERSION" ] || + [ "$NEW_VERSION" = "${LAST_TAG#v}" ]; then + echo "error: NEW_VERSION=$NEW_VERSION must be newer than the latest release $LAST_TAG" + exit 1 +fi + +# Update package.json and package-lock.json before the CHANGELOG: npm version fails +# when they already have NEW_VERSION, as on a second run, so no duplicate entry is added. +npm version "$NEW_VERSION" --no-git-tag-version --ignore-scripts >/dev/null + +# Renovate updates are covered by the Docker image line. +CHANGES="$(git log --format='- %s' "$LAST_TAG..HEAD" | grep -v '^- chore(deps)' || true)" +ENTRY="$(printf '## v%s\n\n- Rebuilds the Docker image with the latest Alpine package updates.\n%s' "$NEW_VERSION" "$CHANGES")" + +# ENVIRON, unlike awk -v, keeps backslashes in commit subjects as they are. +ENTRY="$ENTRY" awk ' + !inserted && /^## v/ { + print ENVIRON["ENTRY"] "\n" + inserted = 1 + } + { print } +' CHANGELOG.md >CHANGELOG.md.new +mv CHANGELOG.md.new CHANGELOG.md + +echo "Prepared release v$NEW_VERSION" diff --git a/packages/pyright-scip/CONTRIBUTING.md b/packages/pyright-scip/CONTRIBUTING.md index 0f3c7c59e..880d59d29 100644 --- a/packages/pyright-scip/CONTRIBUTING.md +++ b/packages/pyright-scip/CONTRIBUTING.md @@ -113,9 +113,23 @@ When modifying code in the `pyright-internal` package: ## Publishing releases -1. Create a PR with the following changes: +A [scheduled workflow](/.github/workflows/scheduled-release.yml) +opens a patch release PR every 4 weeks on Monday, even without code changes, +so the Docker image picks up the latest Alpine package updates. +It can also be run on demand from the +[GitHub Actions UI](https://github.com/sourcegraph/scip-python/actions/workflows/scheduled-release.yml). +GitHub doesn't run CI on that PR until you select +**Approve workflows to run** on it. + +1. Create a PR with the following changes (the scheduled PR already has both): - Change the version in [package.json](./package.json) to `M.N.P`. - Add release notes to [CHANGELOG.md](./CHANGELOG.md) -2. After merging the PR, add a tag `vM.N.P` to the latest - commit on the `scip` branch and push that tag. + + To prepare one by hand, run `NEW_VERSION="M.N.P" ./dev/prepare_release.sh` + from the repository root (without `NEW_VERSION`, it bumps the patch version) + and edit the CHANGELOG entry. +2. Once the PR is merged to `scip`, the [tag workflow](/.github/workflows/tag-release.yml) + pushes the `vM.N.P` tag and starts the + [release workflow](/.github/workflows/scip-release.yml), + which publishes the npm package and the Docker images. From 92d3f560872128d2f4d27362bf47131f04123056 Mon Sep 17 00:00:00 2001 From: Adam Chrapkowski Date: Wed, 25 Nov 2026 13:43:38 +0100 Subject: [PATCH 2/2] Auto-merge passing non-major Renovate updates Renovate PRs wait for a manual merge even when CI passes, so they pile up. Minor, patch and digest updates now merge on their own once every check passes, so only major updates and failing PRs need attention; an explicit major rule also overrides the shared preset, which auto-merges some npm updates of any type. GitHub Actions updates and the tool versions they install (mise, the release Node version) are grouped into one PR, and Renovate runs on Monday mornings to match the weekly cycle. Vulnerability fixes still bypass the schedule. The Dependabot config goes away: its only entry was a weekly Docker version update that duplicates Renovate's base image updates (and it looked for a root Dockerfile, which doesn't exist). Dependabot security alerts and updates are repository settings, so they are not affected. Renovate merges these PRs itself instead of using GitHub auto-merge, because GitHub would only wait for the required snapshot tests, while Renovate also waits for the Docker image build, prettier and Semgrep. That covers checkout, mise, cache, the Docker build actions and the base image build, but not running the built image, CodeQL (its triggers target `main`, not `scip`), or the release-only setup-node, docker/login-action and Node version in scip-release.yml. A bad update to those would first show up in the weekly CodeQL run or on release day. --- .github/dependabot.yml | 6 ------ .github/renovate.json | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) delete mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 84c87d635..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "docker" - directory: "/" - schedule: - interval: "weekly" diff --git a/.github/renovate.json b/.github/renovate.json index ccdb38ae5..1e474c7c8 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -10,5 +10,27 @@ ], "extends": [ "local>sourcegraph/renovate-config" + ], + "timezone": "Europe/Warsaw", + "schedule": [ + "before 9am on monday" + ], + "packageRules": [ + { + "description": "Merge non-major updates once all checks pass; major updates need review. Renovate merges them itself: GitHub auto-merge would only wait for the required snapshot tests, not the Docker image build.", + "matchUpdateTypes": ["minor", "patch", "digest", "pin", "pinDigest"], + "automerge": true, + "platformAutomerge": false + }, + { + "description": "The shared preset auto-merges some npm updates of every type; keep major updates for review.", + "matchUpdateTypes": ["major"], + "automerge": false + }, + { + "description": "Update GitHub Actions and the tool versions they install in one PR.", + "matchManagers": ["github-actions"], + "groupName": "GitHub Actions" + } ] }