From c429baf9720a6193ff24c13e3f4326a1a7d3c2f9 Mon Sep 17 00:00:00 2001 From: Adam Chrapkowski Date: Wed, 25 Nov 2026 13:37:50 +0100 Subject: [PATCH 1/2] Publish a patch release every 4 weeks The Docker image only picks up base image and Ubuntu security fixes when a release rebuilds it, so a scheduled workflow now creates a patch release every fourth Monday after 2026-11-23, the same weeks as the other SCIP indexers. It releases the newest main commit that passed the required checks, creates the GitHub release with generated notes, and calls the Maven Central and Docker release workflows for the tag, since tags created with GITHUB_TOKEN don't trigger them. The workflow can also be run by hand, optionally with a version. --- .github/workflows/release-cli.yaml | 2 + .github/workflows/release-docker.yaml | 22 +++++-- .github/workflows/release-maven.yaml | 29 ++++++-- .github/workflows/scheduled-release.yaml | 84 ++++++++++++++++++++++++ CONTRIBUTING.md | 15 +++++ bin/create-release.sh | 77 ++++++++++++++++++++++ 6 files changed, 218 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/scheduled-release.yaml create mode 100755 bin/create-release.sh diff --git a/.github/workflows/release-cli.yaml b/.github/workflows/release-cli.yaml index 2c8b56998..a2b358c17 100644 --- a/.github/workflows/release-cli.yaml +++ b/.github/workflows/release-cli.yaml @@ -18,6 +18,8 @@ jobs: shell: nix develop --command bash -e {0} steps: - uses: actions/checkout@v7 + with: + ref: ${{ inputs.tag }} - uses: DeterminateSystems/nix-installer-action@v23 with: diff --git a/.github/workflows/release-docker.yaml b/.github/workflows/release-docker.yaml index 2882975e0..4ced24eeb 100644 --- a/.github/workflows/release-docker.yaml +++ b/.github/workflows/release-docker.yaml @@ -4,11 +4,21 @@ on: branches: - main tags: ["*"] + # scheduled-release.yaml calls this for the tags it creates. + workflow_call: + inputs: + tag: + required: true + type: string permissions: contents: read packages: write +env: + # The release tag, or empty for snapshots from main. + TAG: ${{ inputs.tag || (github.ref_type == 'tag' && github.ref_name || '') }} + jobs: publish: strategy: @@ -22,6 +32,7 @@ jobs: steps: - uses: actions/checkout@v7 with: + ref: ${{ inputs.tag || github.ref }} fetch-depth: 0 - uses: docker/setup-buildx-action@v4 @@ -40,14 +51,15 @@ jobs: set -euo pipefail image="ghcr.io/scip-code/scip-java" - if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then - version="${GITHUB_REF_NAME#v}" + if [[ -n "${TAG}" ]]; then + version="${TAG#v}" tag="${image}:${version}-${{ matrix.arch }}" else tag="${image}:latest-snapshot-${{ matrix.arch }}" fi echo "tag=${tag}" >> "$GITHUB_OUTPUT" + echo "revision=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - name: Build and push Docker image uses: docker/build-push-action@v7 @@ -58,7 +70,7 @@ jobs: tags: ${{ steps.tag.outputs.tag }} labels: | org.opencontainers.image.source=https://github.com/scip-code/scip-java - org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.revision=${{ steps.tag.outputs.revision }} publish-manifest: needs: publish @@ -79,8 +91,8 @@ jobs: set -euo pipefail image="ghcr.io/scip-code/scip-java" - if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then - version="${GITHUB_REF_NAME#v}" + if [[ -n "${TAG}" ]]; then + version="${TAG#v}" docker buildx imagetools create \ --tag "${image}:latest" \ --tag "${image}:${version}" \ diff --git a/.github/workflows/release-maven.yaml b/.github/workflows/release-maven.yaml index 8ce6e5c7e..c12b46497 100644 --- a/.github/workflows/release-maven.yaml +++ b/.github/workflows/release-maven.yaml @@ -3,6 +3,16 @@ on: push: branches: [main] tags: ["*"] + # scheduled-release.yaml calls this for the tags it creates. + workflow_call: + inputs: + tag: + required: true + type: string + +env: + # The release tag, or empty for snapshots from main. + TAG: ${{ inputs.tag || (github.ref_type == 'tag' && github.ref_name || '') }} jobs: publish: @@ -10,21 +20,28 @@ jobs: steps: - uses: actions/checkout@v7 with: + ref: ${{ inputs.tag || github.ref }} fetch-depth: 0 - uses: DeterminateSystems/nix-installer-action@v23 with: summarize: false - uses: DeterminateSystems/magic-nix-cache-action@v15 - name: Publish snapshot ${{ github.ref }} - if: ${{ !startsWith(github.ref, 'refs/tags/') }} + if: env.TAG == '' run: nix develop --command gradle --no-daemon publishToMavenCentral env: ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_PASSWORD }} ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_USERNAME }} - - name: Publish release ${{ github.ref }} - if: ${{ startsWith(github.ref, 'refs/tags/') }} + - name: Publish release ${{ env.TAG }} + if: env.TAG != '' run: | - version="${GITHUB_REF_NAME#v}" + version="${TAG#v}" + # Maven Central rejects a version it already has, so a rerun after + # a successful upload skips it and lets release-cli continue. + if nix develop --command cs resolve --intransitive "org.scip-code:scip-java:$version" >/dev/null 2>&1; then + echo "org.scip-code:scip-java:$version is already on Maven Central; skipping the upload" + exit 0 + fi nix develop --command gradle --no-daemon \ "-PreleaseVersion=$version" publishAndReleaseToMavenCentral env: @@ -33,10 +50,10 @@ jobs: ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} release-cli: - if: ${{ startsWith(github.ref, 'refs/tags/') }} + if: inputs.tag != '' || github.ref_type == 'tag' needs: publish permissions: contents: write uses: ./.github/workflows/release-cli.yaml with: - tag: ${{ github.ref_name }} + tag: ${{ inputs.tag || github.ref_name }} diff --git a/.github/workflows/scheduled-release.yaml b/.github/workflows/scheduled-release.yaml new file mode 100644 index 000000000..ba561b6fd --- /dev/null +++ b/.github/workflows/scheduled-release.yaml @@ -0,0 +1,84 @@ +name: Scheduled release + +# Publishes a patch release every 4 weeks on Monday, even without code changes, +# so the Docker image is rebuilt with the latest base image and Ubuntu updates. +# If publishing fails, use "Re-run failed jobs" so steps that already +# published, such as the Maven Central upload, don't run again. +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. 12:00 UTC leaves + # time for Renovate's Monday morning updates to merge and pass CI on main. + schedule: + - cron: "0 12 * * 1" + workflow_dispatch: + inputs: + version: + description: Version to release, such as 0.15.0. Defaults to the next patch version. + type: string + +env: + # Shared by the SCIP indexers so they release in the same week. + RELEASE_MONDAY: "2026-11-23" + +permissions: {} + +concurrency: + group: ${{ github.workflow }} + +jobs: + release: + runs-on: ubuntu-latest + permissions: + actions: read + checks: read + contents: write + outputs: + tag: ${{ steps.release.outputs.tag }} + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Create release + id: release + env: + GH_TOKEN: ${{ github.token }} + NEW_VERSION: ${{ inputs.version }} + run: | + set -euo pipefail + if [ "$GITHUB_REF" != "refs/heads/main" ]; then + echo "error: releases are published from main, not $GITHUB_REF" >&2 + exit 1 + fi + if [ "$GITHUB_EVENT_NAME" = "schedule" ]; then + # Use the run's creation time, so a rerun on a later day still releases. + CREATED="$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" --jq .created_at)" + DAYS=$(( ($(date -u -d "$CREATED" +%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 + bin/create-release.sh + + # Tags created with GITHUB_TOKEN don't trigger the release workflows' push + # events, so call them for the tag here. + maven: + needs: release + if: needs.release.outputs.tag != '' + permissions: + contents: write + uses: ./.github/workflows/release-maven.yaml + with: + tag: ${{ needs.release.outputs.tag }} + secrets: inherit + + docker: + needs: release + if: needs.release.outputs.tag != '' + permissions: + contents: read + packages: write + uses: ./.github/workflows/release-docker.yaml + with: + tag: ${{ needs.release.outputs.tag }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1d61d7200..a40fe3fe6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -95,3 +95,18 @@ Platform support. The snapshot suite is a JUnit `@TestFactory` that emits one dynamic test per generated document, comparing it against the committed goldens under `scip-snapshots/expected`. Build-tool tests (`scip-java/src/test`) are written in Kotlin. + +## Releasing + +Every 4 weeks on Monday, the [scheduled release](.github/workflows/scheduled-release.yaml) +workflow publishes a patch release, even without code changes, so the Docker +image picks up base image and Ubuntu security updates. It releases the newest +`main` commit that passed the required checks. To release at another time or +with another version, run the workflow from the Actions tab and optionally give +it a version such as `0.15.0`. + +The workflow creates the GitHub release and tag with generated release notes, +then runs the Maven Central and Docker release workflows for the tag. If +publishing fails, use "Re-run failed jobs" on that run, so steps that already +published don't run again. Creating a release from the GitHub UI still works +too, since its tag triggers those workflows directly. diff --git a/bin/create-release.sh b/bin/create-release.sh new file mode 100755 index 000000000..ba1274aa1 --- /dev/null +++ b/bin/create-release.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +# Creates the next scip-java GitHub release, and with it the tag, on the newest +# main commit whose required checks passed. Prints tag=vM.N.P to $GITHUB_OUTPUT +# so .github/workflows/scheduled-release.yaml can publish it. +# +# Usage: [NEW_VERSION=M.N.P] [DRY_RUN=1] bin/create-release.sh +# NEW_VERSION defaults to the next patch version after the latest release. +set -euo pipefail + +REPO="${GITHUB_REPOSITORY:-scip-code/scip-java}" +# The required status checks of main's branch protection. +REQUIRED_CHECKS=("CI pass" "Nix pass" "Repository indexing pass") +# Links the release to the workflow run that creates it. +RUN_URL="${GITHUB_SERVER_URL:-https://github.com}/$REPO/actions/runs/${GITHUB_RUN_ID:-local}" + +# A rerun of a workflow run publishes the release that its first attempt +# created, instead of releasing again. +if [ "${GITHUB_RUN_ATTEMPT:-1}" -gt 1 ]; then + TAG="$(gh api "repos/$REPO/releases?per_page=20" \ + --jq "[.[] | select((.body // \"\") | contains(\"($RUN_URL)\"))][0].tag_name // empty")" + if [ -n "$TAG" ]; then + echo "An earlier attempt of this run created $TAG; publishing it again" + echo "tag=$TAG" >>"${GITHUB_OUTPUT:-/dev/null}" + exit 0 + fi +fi + +git fetch --quiet --tags origin main + +LAST_TAG="$(git tag --list 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1)" +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" >&2 + exit 1 +fi +if [ "$NEW_VERSION" = "${LAST_TAG#v}" ] || + [ "$(printf '%s\n%s\n' "${LAST_TAG#v}" "$NEW_VERSION" | sort -V | tail -n 1)" != "$NEW_VERSION" ]; then + echo "error: NEW_VERSION=$NEW_VERSION must be newer than the latest release $LAST_TAG" >&2 + exit 1 +fi + +# Skip commits whose checks failed or are still running, such as a Renovate +# merge from this morning, instead of releasing them or failing the release. +# Never go back past the latest release, which would publish older code. +SHA="" +for commit in $(git rev-list --first-parent --max-count=20 "$LAST_TAG^..origin/main"); do + passed=true + for check in "${REQUIRED_CHECKS[@]}"; do + conclusion="$(gh api -X GET "repos/$REPO/commits/$commit/check-runs" -f check_name="$check" \ + --jq '.check_runs[0].conclusion // ""')" + if [ "$conclusion" != "success" ]; then + echo "Skipping $commit: $check is ${conclusion:-pending or missing}" + passed=false + break + fi + done + if $passed; then + SHA="$commit" + break + fi +done +if [ -z "$SHA" ]; then + echo "error: no recent main commit since $LAST_TAG passed ${REQUIRED_CHECKS[*]}" >&2 + exit 1 +fi + +TAG="v$NEW_VERSION" +if [ -n "${DRY_RUN:-}" ]; then + echo "Would release $TAG on $SHA (latest release: $LAST_TAG)" + exit 0 +fi +gh release create "$TAG" --repo "$REPO" --target "$SHA" --title "$TAG" --generate-notes \ + --notes "Published by the [scheduled release workflow]($RUN_URL)." +echo "tag=$TAG" >>"${GITHUB_OUTPUT:-/dev/null}" +echo "Released $TAG on $SHA" From 18106c0c71da69bda12bd5304a32cccc246f75e0 Mon Sep 17 00:00:00 2001 From: Adam Chrapkowski Date: Wed, 25 Nov 2026 13:37:50 +0100 Subject: [PATCH 2/2] Run Renovate weekly and merge non-major updates by default Renovate opened PRs whenever updates appeared and merged every update, including major ones, once checks passed. It now runs on Monday mornings in Europe/Warsaw, merges only non-major updates on its own, and groups GitHub Actions, Bazel, Kotlin, and Docker image updates into one PR each. Kotlin feature releases need review because the Analysis API pin follows them by hand. --- .github/renovate.json | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index 8214c829c..3f2e185e5 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -3,8 +3,11 @@ "extends": [ "config:recommended" ], - "automerge": true, "semanticCommits": "disabled", + "timezone": "Europe/Warsaw", + "schedule": [ + "before 9am on monday" + ], "customManagers": [ { "customType": "regex", @@ -15,6 +18,11 @@ } ], "packageRules": [ + { + "description": "Merge non-major updates once the required checks pass; major updates need review.", + "matchUpdateTypes": ["minor", "patch", "digest", "pin", "pinDigest"], + "automerge": true + }, { "matchManagers": ["custom.regex"], "automerge": false @@ -24,6 +32,20 @@ "matchPackageNames": ["coursier/coursier"], "extractVersion": "^v(?\\d+\\.\\d+\\.\\d+)$" }, + { + "matchManagers": ["github-actions"], + "matchDepTypes": ["action"], + "groupName": "GitHub Actions" + }, + { + "matchManagers": ["bazelisk", "bazel-module"], + "groupName": "Bazel" + }, + { + "description": "Update the Docker image's base image and build tools together.", + "matchFileNames": ["Dockerfile", "bin/docker-setup.sh"], + "groupName": "Docker image" + }, { "matchDatasources": ["gradle-version"], "matchPackageNames": ["gradle", "gradle/gradle"], @@ -37,12 +59,22 @@ "automerge": false }, { - "description": "Keep the shared Kotlin toolchain version on stable releases, not IntelliJ-specific builds from the Analysis API repository.", + "description": "Keep the shared Kotlin toolchain version on stable releases, not IntelliJ-specific builds from the Analysis API repository, and update the libraries and Gradle plugin that share it in one PR.", + "matchPackageNames": [ + "org.jetbrains.kotlin:*", + "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin" + ], + "allowedVersions": "/^\\d+\\.\\d+\\.\\d+$/", + "groupName": "Kotlin" + }, + { + "description": "Kotlin feature releases need review, since the Analysis API pin below moves with the toolchain by hand.", "matchPackageNames": [ "org.jetbrains.kotlin:*", "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin" ], - "allowedVersions": "/^\\d+\\.\\d+\\.\\d+$/" + "matchUpdateTypes": ["minor"], + "automerge": false }, { "description": "The Analysis API engine pin is managed manually: it lives in the JetBrains intellij-dependencies repository, uses IDE-aligned version schemes, and must move in lockstep with the `kotlin` toolchain version.",