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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/dependabot.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
69 changes: 69 additions & 0 deletions .github/workflows/scheduled-release.yml
Original file line number Diff line number Diff line change
@@ -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 <<EOF
Scheduled release, so the Docker image picks up the latest Alpine package updates. Edit the CHANGELOG entry before merging if needed.

GitHub doesn't start CI on PRs opened by GitHub Actions until someone approves it: select **Approve workflows to run** below to run the required checks.

Merging this PR tags v$VERSION, publishes \`@sourcegraph/scip-python\` to npm and pushes the \`sourcegraph/scip-python\` Docker images.
EOF
)"
3 changes: 3 additions & 0 deletions .github/workflows/scip-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
paths:
- '.github/workflows/**'
- 'Dockerfile.autoindex'
# The image installs the packed package, so build it for version and dependency changes too.
- 'packages/pyright-scip/package.json'
- 'packages/pyright-scip/package-lock.json'

jobs:
build-image:
Expand Down
41 changes: 36 additions & 5 deletions .github/workflows/scip-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ on:
push:
tags:
- v*
# tag-release.yml dispatches this workflow for the tags it pushes.
workflow_dispatch:

jobs:
release-image:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -20,20 +23,48 @@ jobs:
- run: npm install
# npm pack builds the package and creates the tarball Dockerfile.autoindex installs.
- run: cd ./packages/pyright-scip/ && npm install && npm pack
- run: cd ./packages/pyright-scip/ && npm publish --access public
- name: Publish to npm
working-directory: packages/pyright-scip
run: |
set -euo pipefail
NAME="$(jq -r .name package.json)"
VERSION="$(jq -r .version package.json)"
if [ "v$VERSION" != "$GITHUB_REF_NAME" ]; then
echo "package.json has version $VERSION, which doesn't match the tag $GITHUB_REF_NAME"
exit 1
fi
# npm versions are immutable, so when a rerun after a failed Docker push
# finds this version published, skip to the Docker steps.
STATUS="$(curl -sS -o /dev/null -w '%{http_code}' "https://registry.npmjs.org/$NAME/$VERSION")"
case "$STATUS" in
200) echo "$NAME@$VERSION is already on npm; skipping npm publish" ;;
404) npm publish --access public ;;
*) echo "Unexpected HTTP $STATUS from the npm registry"; exit 1 ;;
esac
- name: Login to DockerHub
uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker tags
id: docker_tags
run: |
set -euo pipefail
TAGS="sourcegraph/scip-python:$GITHUB_REF_NAME"
# Only the newest release moves the floating tags, so rerunning an
# older release doesn't roll them back.
LATEST="$(git ls-remote --tags --refs origin 'refs/tags/v[0-9]*' | sed 's|.*refs/tags/||' | sort -V | tail -n 1)"
if [ "$GITHUB_REF_NAME" = "$LATEST" ]; then
TAGS+=$'\nsourcegraph/scip-python:latest\nsourcegraph/scip-python:autoindex'
else
echo "$LATEST is newer than $GITHUB_REF_NAME; not moving latest and autoindex"
fi
{ echo 'tags<<EOF'; echo "$TAGS"; echo 'EOF'; } >>"$GITHUB_OUTPUT"
- name: Build and push
id: docker_build_autoindex
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
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 }}
52 changes: 52 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 2 additions & 1 deletion Dockerfile.autoindex
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
30 changes: 0 additions & 30 deletions dev/bump_version.sh

This file was deleted.

46 changes: 46 additions & 0 deletions dev/prepare_release.sh
Original file line number Diff line number Diff line change
@@ -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"
20 changes: 17 additions & 3 deletions packages/pyright-scip/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Loading