Skip to content
Merged
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
42 changes: 38 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Release: tag main's HEAD with the next version and publish a GitHub release.
#
# A maintainer runs it by hand: Actions -> Release -> Run workflow -> pick the bump.
# It never runs on push, on a schedule or on a PR.
# It runs on its own twice a week (Monday and Thursday, 14:00 UTC) as a patch release,
# and only when something was merged since the last tag; otherwise it does nothing.
# A maintainer can also run it by hand any time (Actions -> Release -> Run workflow ->
# pick the bump), e.g. for an urgent fix or a minor release. It never runs on push or on a PR.
#
# patch v0.4.1 -> v0.4.2 fixes, new providers on an existing format plugin
# minor v0.4.1 -> v0.5.0 new format plugins, new exported API, anything a user should read about
Expand All @@ -19,6 +21,8 @@
name: Release

on:
schedule:
- cron: "0 14 * * 1,4" # Mon + Thu 14:00 UTC; scheduled runs are always a patch release

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking, but worth deciding on: scheduled runs always make a patch, while the header (line 9) says new format plugins and new exported API should be a minor. If a PR like that is merged on Tuesday and nobody runs the workflow by hand before Thursday 14:00 UTC, it ships as v0.x.(y+1). That tag can't be moved afterwards (line 18).

Two cheap ways to handle it:

  • Add a line to CONTRIBUTING → Releasing: "after merging a minor-worthy PR, run Release with minor before the next scheduled run."
  • Or have the scheduled run skip, with a ::warning::, when git diff --name-only "$latest"..HEAD touches a new plugins/*/ directory. A maintainer then cuts the minor by hand.

workflow_dispatch:
inputs:
bump:
Expand Down Expand Up @@ -64,11 +68,17 @@ jobs:
- name: next version
id: version
env:
BUMP: ${{ inputs.bump }}
BUMP: ${{ inputs.bump || 'patch' }}
EVENT: ${{ github.event_name }}
run: |
head=$(git rev-parse HEAD)
existing=$(git tag --points-at "$head")
if [ -n "$existing" ]; then
if [ "$EVENT" = "schedule" ]; then
echo "Nothing merged since $existing: no release this time."
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "::error::main's HEAD ($head) is already tagged: $existing. Nothing new to release."
exit 1
fi
Expand All @@ -89,57 +99,81 @@ jobs:
echo "::error::$next already exists."
exit 1
fi
# A new format plugin (a new plugins/<format>/ directory) deserves a minor, not a
# patch. A scheduled run can't decide that, so it skips and a maintainer releases by hand.
if [ "$EVENT" = "schedule" ] && [ -n "$latest" ]; then
new_formats=$(comm -13 <(git ls-tree -d --name-only "$latest" plugins/ | sort) <(git ls-tree -d --name-only HEAD plugins/ | sort))
if [ -n "$new_formats" ]; then
echo "::warning::New format plugin(s) since $latest: $new_formats. That's a minor release: run Release by hand with bump=minor."
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
fi

echo "latest=${latest:-none}, bump=$BUMP -> $next at $head"
echo "tag=$next" >> "$GITHUB_OUTPUT"
echo "sha=$head" >> "$GITHUB_OUTPUT"

- name: internal names (hashed), whole tree
if: steps.version.outputs.skip != 'true'
run: python3 scripts/leak_guard.py --all

- name: install gitleaks ${{ env.GITLEAKS_VERSION }}
if: steps.version.outputs.skip != 'true'
run: |
tarball="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
curl -fsSL -o "$RUNNER_TEMP/$tarball" "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/${tarball}"
echo "${GITLEAKS_SHA256} $RUNNER_TEMP/$tarball" | sha256sum -c -
tar -xzf "$RUNNER_TEMP/$tarball" -C "$RUNNER_TEMP" gitleaks

- name: gitleaks, whole history
if: steps.version.outputs.skip != 'true'
run: '"$RUNNER_TEMP/gitleaks" git --no-banner --redact --verbose .'

- uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
if: steps.version.outputs.skip != 'true'
with:
go-version-file: go.mod
cache-dependency-path: go.sum

- name: go build
if: steps.version.outputs.skip != 'true'
run: go build ./...

- name: go vet
if: steps.version.outputs.skip != 'true'
run: go vet ./...

- name: gofmt
if: steps.version.outputs.skip != 'true'
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "::error::not gofmt-formatted:"; echo "$unformatted"; exit 1
fi

- name: go test
if: steps.version.outputs.skip != 'true'
run: go test -race -count=1 ./...

# Only reached when every check above passed.
- name: create and push the annotated tag
if: steps.version.outputs.skip != 'true'
env:
TAG: ${{ steps.version.outputs.tag }}
SHA: ${{ steps.version.outputs.sha }}
ACTOR: ${{ github.actor }}
EVENT_NAME: ${{ github.event_name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" "$SHA" -m "$TAG" -m "Released by @$ACTOR with the Release workflow."
by="scheduled"
[ "$EVENT_NAME" = "workflow_dispatch" ] && by="run by @$ACTOR"
git tag -a "$TAG" "$SHA" -m "$TAG" -m "Released by the Release workflow ($by)."
git push origin "refs/tags/$TAG"

- name: publish the GitHub release
if: steps.version.outputs.skip != 'true'
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ The [change-event contract](https://github.com/patch-it-dev/patch-it/tree/main/d

## Releases

Agents never tag or release. A maintainer runs the **Release** workflow (see [CONTRIBUTING.md](CONTRIBUTING.md#releasing)). Never delete or move a tag.
Agents never tag or release. The **Release** workflow tags a patch release on its own every Monday and Thursday when something new was merged, and a maintainer can run it by hand (see [CONTRIBUTING.md](CONTRIBUTING.md#releasing)). Never delete or move a tag.
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ That adds `Signed-off-by: Your Name <you@example.com>`, matching the commit's au
| `CI_dco` | Every commit in the PR is signed off by its author |
| `CI_leak_guard` | gitleaks over the PR's commits, and a check for known internal names (stored as hashes only). Also runs weekly over the whole repo |
| `Claude Code Review` | Claude reviews the PR against the rules above, once (PRs from this repo's branches; forks: a maintainer comments `@claude review`). Advisory, not a required check |
| `Release` | Not a check: a maintainer runs it by hand to tag a release (see [Releasing](#releasing)) |
| `Release` | Not a check: tags a release on its own twice a week, or when a maintainer runs it (see [Releasing](#releasing)) |

## Releasing

Releases are tags on `main` (`v0.x.y`), made only by the **Release** workflow, which a maintainer runs by hand. Nothing is tagged on push, and agents never tag or release.
Releases are tags on `main` (`v0.x.y`), made only by the **Release** workflow. Nothing is tagged on push, and agents never tag or release.

**Automatic, twice a week:** every Monday and Thursday at 14:00 UTC the workflow makes a **patch** release, but only if something was merged since the last tag; otherwise it does nothing. If the merges add a **new format plugin** (a new `plugins/<format>/` directory), the scheduled run skips with a warning instead: run it by hand with **minor**. So a merged plugin reaches patch-it's hosted ingestion service within a few days.

**By hand, any time** (an urgent fix, or a **minor** release):

1. Merge the PRs that should go out.
2. **Actions → Release → Run workflow** (branch `main`), pick the bump:
Expand Down
2 changes: 1 addition & 1 deletion plugins/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
package all

import (
_ "github.com/patch-it-dev/patch-it-plugins/plugins/catalog"
_ "github.com/patch-it-dev/patch-it-plugins/plugins/apichangelog"
_ "github.com/patch-it-dev/patch-it-plugins/plugins/catalog"
_ "github.com/patch-it-dev/patch-it-plugins/plugins/changelog"
_ "github.com/patch-it-dev/patch-it-plugins/plugins/feed"
_ "github.com/patch-it-dev/patch-it-plugins/plugins/migrationguide"
Expand Down
Loading