Skip to content
Open
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
24 changes: 21 additions & 3 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended", "helpers:pinGitHubActionDigests"],
"automerge": true,
"timezone": "Europe/Warsaw",
"schedule": ["before 9am on monday"],
"nix": {
"enabled": true
},
"lockFileMaintenance": {
"description": "Brings nixpkgs fixes into the image before the scheduled release.",
"enabled": true,
"schedule": ["* 0-3 * * 1"],
"automerge": false
"automerge": true
},
"customManagers": [
{
Expand All @@ -32,7 +34,19 @@
],
"packageRules": [
{
"description": "The release-hashes workflow adds the new hashes in a second commit; wait for CI on it.",
"description": "Merge non-major updates once CI passes; major updates need review.",
"matchUpdateTypes": ["minor", "patch", "digest", "pin", "pinDigest"],
"automerge": true
},
{
"description": "A NixOS release upgrade, such as nixos-26.05 to nixos-26.11, changes every package in the image.",
"matchManagers": ["nix"],
"matchDepNames": ["nixpkgs"],
"matchUpdateTypes": ["major", "minor"],
"automerge": false
},
{
"description": "pyrefly updates change the index, which CI only checks for size and a few files. The release-hashes workflow adds the new hashes in a second commit; wait for CI on it.",
"matchManagers": ["custom.regex"],
"matchFileNames": ["flake.nix"],
"automerge": false
Expand All @@ -41,6 +55,10 @@
"matchManagers": ["custom.regex"],
"matchFileNames": [".github/workflows/ci.yaml"],
"schedule": ["* * 1 */3 *"]
},
{
"matchManagers": ["github-actions"],
"groupName": "GitHub Actions"
}
]
}
8 changes: 7 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ jobs:
- run: nix flake check

docker:
runs-on: ubuntu-latest
# Renovate merges flake.lock updates on its own, and release.yml
# publishes both architectures, so test both.
strategy:
fail-fast: false
matrix:
runner: [ubuntu-latest, ubuntu-24.04-arm]
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
description: "Version to release (e.g. 1.2.3, without v prefix)"
required: true
type: string
# scheduled-release.yml calls this every 4 weeks.
workflow_call:
inputs:
version:
required: true
type: string

jobs:
tag:
Expand All @@ -30,9 +36,12 @@ jobs:
- name: Create and push tag
env:
NEW_VERSION: ${{ inputs.version }}
# A rerun after a later job failed finds its own tag.
run: |
git tag "v$NEW_VERSION"
git push origin "v$NEW_VERSION"
if [ "$(git rev-parse -q --verify "refs/tags/v$NEW_VERSION^{commit}" || true)" != "$GITHUB_SHA" ]; then
git tag "v$NEW_VERSION"
git push origin "v$NEW_VERSION"
fi

create-release:
needs: tag
Expand All @@ -47,7 +56,8 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: v${{ inputs.version }}
run: |
gh release create "$TAG" --title "scip-pyrefly $TAG" --generate-notes --draft --verify-tag
gh release view "$TAG" >/dev/null 2>&1 ||
gh release create "$TAG" --title "scip-pyrefly $TAG" --generate-notes --draft --verify-tag

docker:
needs: create-release
Expand Down
108 changes: 108 additions & 0 deletions .github/workflows/scheduled-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: scheduled-release

# Releases the next patch version every 4 weeks, so the Docker image picks up
# the nixpkgs fixes that Renovate's weekly lock file maintenance brings in.
on:
# Cron can't express "every 4 weeks", so this runs every Monday and skips
# weeks that aren't a multiple of 4 weeks after RELEASE_MONDAY.
schedule:
- cron: "0 9 * * 1"
# Releases the next patch version now.
workflow_dispatch:

env:
# The other SCIP indexers use the same date, so they release in the same week.
RELEASE_MONDAY: "2026-11-23"

# A queued run waits for a running one and then finds main already tagged.
concurrency: scheduled-release

jobs:
version:
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0

- id: version
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail

# release.yml tags the commit this workflow runs on.
if [ "$GITHUB_REF" != refs/heads/main ]; then
echo "::error::Run this workflow on main, not $GITHUB_REF."
exit 1
fi

# Any day of the release week counts, so reruns after Monday still release.
if [ "$GITHUB_EVENT_NAME" = schedule ]; then
days=$(( ($(date -u +%s) - $(date -u -d "$RELEASE_MONDAY" +%s)) / 86400 ))
if (( days < 0 || (days / 7) % 4 != 0 )); then
echo "Not a release week ($days days after $RELEASE_MONDAY)."
exit 0
fi
fi

last="$(git tag -l 'v*' --sort=-v:refname | head -n 1)"
if ! [[ "$last" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
echo "::error::The latest tag '$last' is not vM.N.P."
exit 1
fi

# release.yml pushes the tag first and publishes the release last, so
# a tag alone does not mean the images were pushed.
published=false
if [ "$(gh release view "$last" --json isDraft --jq .isDraft || true)" = false ]; then
published=true
fi

if [ "$(git rev-parse "$last^{commit}")" = "$GITHUB_SHA" ]; then
# The Nix build is reproducible, so the same commit gives the same image.
if $published; then
echo "::notice::main is already released as $last; nothing to release."
exit 0
fi
version="${last#v}"
echo "::warning::Finishing $last, whose release is missing or still a draft."
elif ! $published; then
echo "::error::$last, on an earlier commit, has no published release. Finish it with: gh workflow run release.yml --ref $last -f version=${last#v}"
exit 1
else
version="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.$((BASH_REMATCH[3] + 1))"
if git diff --quiet "$last" "$GITHUB_SHA" -- flake.lock; then
echo "::warning::flake.lock has not changed since $last, so v$version gets no nixpkgs fixes. Check the Dependency Dashboard for a lock file maintenance PR that did not merge."
fi
fi

# main has no branch protection, so check CI on the commit itself.
run="$(gh run list --workflow ci.yaml --commit "$GITHUB_SHA" --limit 1 --json databaseId --jq '.[0].databaseId // empty')"
if [ -z "$run" ]; then
echo "::error::ci did not run on $GITHUB_SHA."
exit 1
fi
if ! gh run watch "$run" --exit-status --interval 30 >/dev/null; then
echo "::error::ci failed on $GITHUB_SHA: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$run. Fix or rerun it, then rerun this workflow."
exit 1
fi

echo "Releasing v$version"
echo "version=$version" >>"$GITHUB_OUTPUT"

release:
needs: version
if: needs.version.outputs.version != ''
permissions:
contents: write
packages: write
uses: ./.github/workflows/release.yml
with:
version: ${{ needs.version.outputs.version }}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ Bump the version and binary hashes in [`flake.nix`](flake.nix) (`nix store prefe

## Cutting releases

Run **Actions → release → Run workflow** on `main` with version `M.N.P`.
The scheduled-release workflow releases the next patch version every 4 weeks (on Mondays from 2026-11-23), so the Docker image picks up the nixpkgs updates that Renovate merges weekly. It skips the release when `main` has not changed since the last one, finishes a release that failed partway, and fails when CI did not pass on `main`.

To release now, run **Actions → scheduled-release → Run workflow** on `main` for the next patch version, or **Actions → release → Run workflow** on `main` with version `M.N.P`.
Loading