Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8372712d8 | ||
|
|
c098c93ae9 | ||
|
|
f3f6b5dfb4 | ||
|
|
050936c6fd | ||
|
|
22e4c96192 | ||
|
|
1fbb05339c | ||
|
|
55d4259f4a | ||
|
|
98a030bcc2 | ||
|
|
7c1a20465a |
No files matched your search
@@ -0,0 +1,27 @@
|
|||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: build and test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 20
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
cache: false
|
||||||
|
|
||||||
|
- name: Run checks
|
||||||
|
run: ./scripts/check.sh
|
||||||
|
|
||||||
|
- name: Check dependency freshness
|
||||||
|
run: ./scripts/check-deps.sh
|
||||||
@@ -6,6 +6,11 @@ A language-agnostic, changesets-style versioning and changelog tool. Works with
|
|||||||
|
|
||||||
`stamp` is inspired by the [Changesets](https://github.com/changesets/changesets) workflow, but without the Node.js dependency. It works by having contributors add small **stamp files** (`.stamp/*.md`) alongside their code changes. When it's time to release, `stamp` consumes those files, bumps versions, updates changelogs, creates git tags, and publishes releases to GitHub or Gitea.
|
`stamp` is inspired by the [Changesets](https://github.com/changesets/changesets) workflow, but without the Node.js dependency. It works by having contributors add small **stamp files** (`.stamp/*.md`) alongside their code changes. When it's time to release, `stamp` consumes those files, bumps versions, updates changelogs, creates git tags, and publishes releases to GitHub or Gitea.
|
||||||
|
|
||||||
|
There are two supported release workflows:
|
||||||
|
|
||||||
|
- **Direct release** — run `stamp version` and `stamp publish` locally or in CI on the base branch.
|
||||||
|
- **Release PR** — run `stamp release-pr` in CI to open a pull request that contains the version bumps. Merging the PR triggers the actual publish step.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Via [Mise](https://mise.jdx.dev/):
|
Via [Mise](https://mise.jdx.dev/):
|
||||||
@@ -13,19 +18,19 @@ Via [Mise](https://mise.jdx.dev/):
|
|||||||
```toml
|
```toml
|
||||||
# mise.toml
|
# mise.toml
|
||||||
[tools]
|
[tools]
|
||||||
"go:github.com/thokra/stamp/cmd/stamp" = "latest"
|
"go:git.thokra.dev/thokra/stamp/cmd/stamp" = "latest"
|
||||||
```
|
```
|
||||||
|
|
||||||
Or with `go install`:
|
Or with `go install`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
go install github.com/thokra/stamp/cmd/stamp@latest
|
go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
Or build from source:
|
Or build from source:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/thokra/stamp
|
git clone https://git.thokra.dev/thokra/stamp
|
||||||
cd stamp
|
cd stamp
|
||||||
go build -o bin/stamp ./cmd/stamp
|
go build -o bin/stamp ./cmd/stamp
|
||||||
```
|
```
|
||||||
@@ -130,6 +135,27 @@ Requires `STAMP_REPO=owner/repo` to be set. Detects GitHub vs Gitea automaticall
|
|||||||
|
|
||||||
Tag format: `<name>@v<version>` (e.g. `my-app@v1.3.0`).
|
Tag format: `<name>@v<version>` (e.g. `my-app@v1.3.0`).
|
||||||
|
|
||||||
|
### `stamp release-pr`
|
||||||
|
|
||||||
|
Creates or updates a **release pull request** — a PR that contains all the version bumps and changelog updates that would be applied by `stamp version`. Merging it acts as the explicit release trigger.
|
||||||
|
|
||||||
|
The command:
|
||||||
|
|
||||||
|
1. Reads all pending stamp files. If there are none, it exits cleanly with no side effects.
|
||||||
|
2. Fetches `origin` and resets a well-known branch (default: `stamp/release`) from the tip of the base branch, so the branch is always a clean, fast-forwardable head.
|
||||||
|
3. Applies all version bumps and changelog updates to that branch (identical logic to `stamp version --no-commit`), then commits and force-pushes it.
|
||||||
|
4. Opens a new PR — or updates the existing one — targeting the base branch. The PR is identified across runs by a hidden marker in the body, so only one stamp release PR exists at a time.
|
||||||
|
|
||||||
|
Once the PR is merged, run `stamp publish` to tag and release.
|
||||||
|
|
||||||
|
| Flag | Description |
|
||||||
|
|------|-------------|
|
||||||
|
| `--branch` | Release branch name (default: `stamp/release`) |
|
||||||
|
| `--base` | Base branch the PR targets (default: from `stamp.toml`, fallback: `main`) |
|
||||||
|
| `--repo` | Repository slug `owner/repo` (defaults to `STAMP_REPO` or `GITHUB_REPOSITORY`) |
|
||||||
|
| `--snapshot <id>` | Pre-release identifier (e.g. `alpha`, `rc`) |
|
||||||
|
| `--dry-run` / `-n` | Print what would be done without pushing or opening a PR |
|
||||||
|
|
||||||
### `stamp comment`
|
### `stamp comment`
|
||||||
|
|
||||||
Posts or updates a PR comment summarising pending stamps. Useful in CI to remind contributors to add stamp files or to show reviewers what versions will change.
|
Posts or updates a PR comment summarising pending stamps. Useful in CI to remind contributors to add stamp files or to show reviewers what versions will change.
|
||||||
@@ -142,6 +168,18 @@ Posts or updates a PR comment summarising pending stamps. Useful in CI to remind
|
|||||||
| `--pr` | Pull request number (required) |
|
| `--pr` | Pull request number (required) |
|
||||||
| `--repo` | Repository slug `owner/repo` (defaults to `STAMP_REPO` or `GITHUB_REPOSITORY`) |
|
| `--repo` | Repository slug `owner/repo` (defaults to `STAMP_REPO` or `GITHUB_REPOSITORY`) |
|
||||||
|
|
||||||
|
### `stamp preview`
|
||||||
|
|
||||||
|
Manages **pre-release mode** for a project. While a project is in pre-release mode, every `stamp version` (and `stamp release-pr`) run produces pre-release versions (e.g. `1.3.0-beta.0`, `1.3.0-beta.1`) instead of normal ones. Exiting preview mode causes the next run to produce a regular release.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Enter pre-release mode — all future version bumps will be pre-releases
|
||||||
|
stamp preview enter my-app beta
|
||||||
|
|
||||||
|
# Leave pre-release mode — the next version bump will be a normal release
|
||||||
|
stamp preview exit my-app
|
||||||
|
```
|
||||||
|
|
||||||
## Stamp File Format
|
## Stamp File Format
|
||||||
|
|
||||||
Stamp files live in `.stamp/` alongside `stamp.toml`, and use Markdown with YAML or TOML frontmatter.
|
Stamp files live in `.stamp/` alongside `stamp.toml`, and use Markdown with YAML or TOML frontmatter.
|
||||||
@@ -195,6 +233,7 @@ name = "my-app"
|
|||||||
path = "apps/my-app" # Path relative to repo root
|
path = "apps/my-app" # Path relative to repo root
|
||||||
version = "1.2.3" # Current version — updated by `stamp version`
|
version = "1.2.3" # Current version — updated by `stamp version`
|
||||||
changelog = "CHANGELOG.md" # Relative to path (default: CHANGELOG.md)
|
changelog = "CHANGELOG.md" # Relative to path (default: CHANGELOG.md)
|
||||||
|
pre_tag = "" # Set by `stamp preview enter`; leave blank for normal releases
|
||||||
|
|
||||||
[projects.publish]
|
[projects.publish]
|
||||||
tags = true
|
tags = true
|
||||||
@@ -209,14 +248,19 @@ changelog = "CHANGELOG.md" # Relative to path (default: CHANGELOG.md)
|
|||||||
|
|
||||||
| Variable | Purpose |
|
| Variable | Purpose |
|
||||||
|----------|---------|
|
|----------|---------|
|
||||||
| `STAMP_REPO` | Repository slug `owner/repo` — required for `publish` and `comment` |
|
| `STAMP_REPO` | Repository slug `owner/repo` — required for `publish`, `comment`, and `release-pr` |
|
||||||
| `GITHUB_TOKEN` | GitHub token for releases and PR comments — automatically provided by the GitHub Actions runner; no manual setup needed |
|
| `GITHUB_TOKEN` | GitHub token for releases and PR comments — automatically provided by the GitHub Actions runner; no manual setup needed |
|
||||||
| `GITEA_TOKEN` | Gitea access token — **must be created manually** (Gitea Actions does not inject one automatically); create a token in your Gitea account settings and store it as a repository secret |
|
| `GITEA_TOKEN` | Auto-injected by Gitea Actions — has limited scopes and **cannot create PRs or post comments**; do not use this for stamp |
|
||||||
|
| `STAMP_GITEA_TOKEN` | PAT you create manually with `repository` (read/write) and `issue` (read/write) scopes; used by stamp for all Gitea API calls. Store it as a repository secret. The name `GITEA_TOKEN` is reserved by Gitea Actions, which is why a different name is required. |
|
||||||
| `GITEA_BASE_URL` | Gitea instance URL (e.g. `https://gitea.example.com`) — also enables Gitea mode |
|
| `GITEA_BASE_URL` | Gitea instance URL (e.g. `https://gitea.example.com`) — also enables Gitea mode |
|
||||||
|
|
||||||
## CI Integration
|
## CI Integration
|
||||||
|
|
||||||
### GitHub Actions — PR check
|
### Workflow: PR check (`stamp comment`)
|
||||||
|
|
||||||
|
Posts a comment on every pull request showing which projects will be bumped and to what version. Warns if no stamp file was added.
|
||||||
|
|
||||||
|
**GitHub Actions**
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# .github/workflows/stamp-check.yml
|
# .github/workflows/stamp-check.yml
|
||||||
@@ -232,7 +276,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install stamp
|
- name: Install stamp
|
||||||
run: go install github.com/thokra/stamp/cmd/stamp@latest
|
run: go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
|
|
||||||
- name: Comment on PR
|
- name: Comment on PR
|
||||||
run: stamp comment --pr=${{ github.event.pull_request.number }}
|
run: stamp comment --pr=${{ github.event.pull_request.number }}
|
||||||
@@ -241,7 +285,7 @@ jobs:
|
|||||||
STAMP_REPO: ${{ github.repository }}
|
STAMP_REPO: ${{ github.repository }}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Gitea Actions — PR check
|
**Gitea Actions**
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# .gitea/workflows/stamp-check.yml
|
# .gitea/workflows/stamp-check.yml
|
||||||
@@ -257,16 +301,213 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install stamp
|
- name: Install stamp
|
||||||
run: go install github.com/thokra/stamp/cmd/stamp@latest
|
run: go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
|
|
||||||
- name: Comment on PR
|
- name: Comment on PR
|
||||||
run: stamp comment --pr=${{ gitea.event.pull_request.number }}
|
run: stamp comment --pr=${{ gitea.event.pull_request.number }}
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
STAMP_GITEA_TOKEN: ${{ secrets.STAMP_GITEA_TOKEN }}
|
||||||
GITEA_BASE_URL: ${{ gitea.server_url }}
|
GITEA_BASE_URL: ${{ gitea.server_url }}
|
||||||
STAMP_REPO: ${{ gitea.repository }}
|
STAMP_REPO: ${{ gitea.repository }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Workflow: Release PR (`stamp release-pr` + `stamp publish`)
|
||||||
|
|
||||||
|
This is the recommended automation workflow. Whenever a PR with stamp files is merged to the base branch, CI opens (or updates) a release PR. Merging the release PR triggers the actual publish.
|
||||||
|
|
||||||
|
```
|
||||||
|
feature branch ──► merge to main ──► stamp release-pr ──► release PR
|
||||||
|
│
|
||||||
|
merge to main
|
||||||
|
│
|
||||||
|
stamp publish ──► tags + releases
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 1 — Open or update the release PR on every push to `main`**
|
||||||
|
|
||||||
|
*GitHub Actions*
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .github/workflows/stamp-release-pr.yml
|
||||||
|
name: release PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
# A full clone is needed so stamp can fetch and reset the release branch.
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
- name: Install stamp
|
||||||
|
run: go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
|
|
||||||
|
- name: Create or update release PR
|
||||||
|
run: stamp release-pr --base=main
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
STAMP_REPO: ${{ github.repository }}
|
||||||
|
```
|
||||||
|
|
||||||
|
*Gitea Actions*
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .gitea/workflows/stamp-release-pr.yml
|
||||||
|
name: release PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.STAMP_GITEA_TOKEN }}
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "stamp-bot"
|
||||||
|
git config user.email "stamp-bot@users.noreply.gitea.com"
|
||||||
|
|
||||||
|
- name: Install stamp
|
||||||
|
run: go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
|
|
||||||
|
- name: Create or update release PR
|
||||||
|
run: stamp release-pr --base=main
|
||||||
|
env:
|
||||||
|
STAMP_GITEA_TOKEN: ${{ secrets.STAMP_GITEA_TOKEN }}
|
||||||
|
GITEA_BASE_URL: ${{ gitea.server_url }}
|
||||||
|
STAMP_REPO: ${{ gitea.repository }}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 2 — Publish after the release PR is merged**
|
||||||
|
|
||||||
|
*GitHub Actions*
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .github/workflows/stamp-publish.yml
|
||||||
|
name: publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
- name: Install stamp
|
||||||
|
run: go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
|
|
||||||
|
- name: Publish releases
|
||||||
|
run: stamp publish
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
STAMP_REPO: ${{ github.repository }}
|
||||||
|
```
|
||||||
|
|
||||||
|
*Gitea Actions*
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .gitea/workflows/stamp-publish.yml
|
||||||
|
name: publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.STAMP_GITEA_TOKEN }}
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "stamp-bot"
|
||||||
|
git config user.email "stamp-bot@users.noreply.gitea.com"
|
||||||
|
|
||||||
|
- name: Install stamp
|
||||||
|
run: go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
|
|
||||||
|
- name: Publish releases
|
||||||
|
run: stamp publish
|
||||||
|
env:
|
||||||
|
STAMP_GITEA_TOKEN: ${{ secrets.STAMP_GITEA_TOKEN }}
|
||||||
|
GITEA_BASE_URL: ${{ gitea.server_url }}
|
||||||
|
STAMP_REPO: ${{ gitea.repository }}
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Tip:** Both jobs run on every push to `main`. `stamp release-pr` is a no-op once there are no more pending stamp files (i.e. after the release PR has been merged and `stamp publish` has consumed them). `stamp publish` is a no-op if there are no new tags to create. The two jobs are safe to run in parallel or in sequence.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Workflow: Direct release (no PR)
|
||||||
|
|
||||||
|
If you prefer to version and publish in a single step without a release PR, run both commands directly on the base branch:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .github/workflows/stamp-release.yml
|
||||||
|
name: release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
- name: Install stamp
|
||||||
|
run: go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
|
|
||||||
|
- name: Version and publish
|
||||||
|
run: |
|
||||||
|
stamp version
|
||||||
|
git push
|
||||||
|
stamp publish
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
STAMP_REPO: ${{ github.repository }}
|
||||||
|
```
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
This project uses [Mise](https://mise.jdx.dev/) to manage the Go toolchain and common tasks.
|
This project uses [Mise](https://mise.jdx.dev/) to manage the Go toolchain and common tasks.
|
||||||
@@ -283,6 +524,12 @@ mise run lint
|
|||||||
|
|
||||||
# Install locally
|
# Install locally
|
||||||
mise run install
|
mise run install
|
||||||
|
|
||||||
|
# Run the same checks CI runs (format, vet, build, tests)
|
||||||
|
mise run check
|
||||||
|
|
||||||
|
# Check that every dependency in go.mod is the newest release
|
||||||
|
mise run deps
|
||||||
```
|
```
|
||||||
|
|
||||||
## Project Structure
|
## Project Structure
|
||||||
@@ -293,11 +540,13 @@ stamp/
|
|||||||
├── internal/
|
├── internal/
|
||||||
│ ├── changeset/ # Stamp file parsing, writing, and slug generation
|
│ ├── changeset/ # Stamp file parsing, writing, and slug generation
|
||||||
│ ├── changelog/ # CHANGELOG.md generation and appending
|
│ ├── changelog/ # CHANGELOG.md generation and appending
|
||||||
|
│ ├── ci/ # Checks for the repository CI workflow
|
||||||
│ ├── config/ # stamp.toml loading, validation, and saving
|
│ ├── config/ # stamp.toml loading, validation, and saving
|
||||||
│ ├── git/ # Git operations (tag, commit, push)
|
│ ├── git/ # Git operations (tag, commit, push, branch management)
|
||||||
│ ├── gitea/ # Gitea API client (releases, PR comments)
|
│ ├── gitea/ # Gitea API client (releases, PR comments, release PRs)
|
||||||
│ ├── github/ # GitHub API client (releases, PR comments)
|
│ ├── github/ # GitHub API client (releases, PR comments, release PRs)
|
||||||
│ ├── publish/ # Orchestrates tagging and release publishing
|
│ ├── publish/ # Orchestrates tagging and release publishing
|
||||||
|
│ ├── releasepr/ # Orchestrates release PR creation and updates
|
||||||
│ └── semver/ # Semantic version bumping logic
|
│ └── semver/ # Semantic version bumping logic
|
||||||
├── examples/
|
├── examples/
|
||||||
│ └── stamp.toml # Annotated configuration example
|
│ └── stamp.toml # Annotated configuration example
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
|
"git.thokra.dev/thokra/stamp/internal/config"
|
||||||
|
"git.thokra.dev/thokra/stamp/internal/releasepr"
|
||||||
|
)
|
||||||
|
|
||||||
|
func releasePRCmd() *cli.Command {
|
||||||
|
return &cli.Command{
|
||||||
|
Name: "release-pr",
|
||||||
|
Usage: "create or update a release pull request with pending version bumps",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "release branch name (default: stamp/release)",
|
||||||
|
Value: releasepr.DefaultReleaseBranch,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "base",
|
||||||
|
Usage: "base branch the PR targets (default: from stamp.toml, fallback: main)",
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "repo",
|
||||||
|
Usage: "repository slug owner/repo (defaults to STAMP_REPO env var)",
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "snapshot",
|
||||||
|
Usage: "pre-release identifier (e.g. alpha, beta, rc) for snapshot releases",
|
||||||
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "dry-run",
|
||||||
|
Aliases: []string{"n"},
|
||||||
|
Usage: "print what would be done without pushing or opening a PR",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||||
|
repoRoot, err := findRepoRoot(".")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg, err := config.Load(repoRoot)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
repoSlug := cmd.String("repo")
|
||||||
|
if repoSlug == "" {
|
||||||
|
repoSlug = os.Getenv("STAMP_REPO")
|
||||||
|
}
|
||||||
|
if repoSlug == "" {
|
||||||
|
repoSlug = os.Getenv("GITHUB_REPOSITORY")
|
||||||
|
}
|
||||||
|
if repoSlug == "" {
|
||||||
|
return fmt.Errorf("--repo or STAMP_REPO / GITHUB_REPOSITORY env var must be set")
|
||||||
|
}
|
||||||
|
|
||||||
|
baseBranch := cmd.String("base")
|
||||||
|
if baseBranch == "" {
|
||||||
|
baseBranch = cfg.BaseBranch()
|
||||||
|
}
|
||||||
|
|
||||||
|
return releasepr.Run(ctx, releasepr.Options{
|
||||||
|
RepoRoot: repoRoot,
|
||||||
|
RepoSlug: repoSlug,
|
||||||
|
BaseBranch: baseBranch,
|
||||||
|
ReleaseBranch: cmd.String("branch"),
|
||||||
|
SnapshotID: cmd.String("snapshot"),
|
||||||
|
DryRun: cmd.Bool("dry-run"),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,22 +75,7 @@ func versionCmd() *cli.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if preID != "" {
|
if preID != "" {
|
||||||
// If the project is already on a pre-release version, just
|
highest = semver.PreReleaseBump(project.Version, highest)
|
||||||
// increment it. Otherwise promote the highest regular bump
|
|
||||||
// to its pre-release equivalent so we don't skip a version.
|
|
||||||
v, _ := semver.CurrentVersion(project.Version)
|
|
||||||
if v != nil && v.Prerelease() != "" {
|
|
||||||
highest = changeset.BumpPreRelease
|
|
||||||
} else {
|
|
||||||
switch highest {
|
|
||||||
case changeset.BumpMajor:
|
|
||||||
highest = changeset.BumpPreMajor
|
|
||||||
case changeset.BumpMinor:
|
|
||||||
highest = changeset.BumpPreMinor
|
|
||||||
default: // patch or anything lower
|
|
||||||
highest = changeset.BumpPrePatch
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextVer, err := semver.Bump(project.Version, highest, preID)
|
nextVer, err := semver.Bump(project.Version, highest, preID)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ func main() {
|
|||||||
publishCmd(),
|
publishCmd(),
|
||||||
commentCmd(),
|
commentCmd(),
|
||||||
previewCmd(),
|
previewCmd(),
|
||||||
|
releasePRCmd(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+381
-91
@@ -3,87 +3,124 @@
|
|||||||
`stamp` is a language-agnostic, changesets-style versioning and changelog tool.
|
`stamp` is a language-agnostic, changesets-style versioning and changelog tool.
|
||||||
It works with any project type and supports monorepos.
|
It works with any project type and supports monorepos.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Concepts
|
## Concepts
|
||||||
|
|
||||||
| Term | Description |
|
| Term | Meaning |
|
||||||
|------|-------------|
|
|------|---------|
|
||||||
| **Stamp file** | A `.stamp/*.md` file describing a change and which projects it affects |
|
| **Stamp file** | A `.stamp/*.md` file describing a change and which projects it affects. Committed alongside the code change that caused it. |
|
||||||
| **Bump type** | How to increment a version: `major`, `minor`, `patch`, or pre-release variants |
|
| **Bump type** | How to increment a version: `major`, `minor`, `patch`, or a pre-release variant. |
|
||||||
| `stamp version` | Consumes stamp files → bumps versions → updates changelogs |
|
| **Pending stamps** | Stamp files that have been committed but not yet consumed by a version run. |
|
||||||
| `stamp publish` | Creates git tags, releases, and uploads artifacts |
|
| `stamp version` | Consumes pending stamp files → bumps versions in `stamp.toml` → prepends entries to `CHANGELOG.md` files → commits the result. |
|
||||||
|
| `stamp release-pr` | Same versioning logic as `stamp version`, but commits the changes onto a dedicated branch and opens (or updates) a pull request. The actual release happens when that PR is merged. |
|
||||||
|
| `stamp publish` | Creates git tags and publishes releases (with optional artifact uploads) to GitHub or Gitea. |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Setup
|
## Continuous Integration
|
||||||
|
|
||||||
### 1. Install stamp
|
Every pull request and every push to `main` runs the `ci` workflow in
|
||||||
|
[`.gitea/workflows/ci.yml`](../.gitea/workflows/ci.yml). It has a single `check`
|
||||||
|
job with two steps:
|
||||||
|
|
||||||
Via [Mise](https://mise.jdx.dev/):
|
1. [`scripts/check.sh`](../scripts/check.sh) first validates the workflow and
|
||||||
|
the dependency-policy scripts themselves, then fails if any Go file is not
|
||||||
|
`gofmt`-formatted, and finally runs `go mod verify`, `go vet ./...`,
|
||||||
|
`go build ./...`, and `go test -cover ./...`.
|
||||||
|
2. [`scripts/check-deps.sh`](../scripts/check-deps.sh) fails when a module
|
||||||
|
pinned in `go.mod` has a newer release. It asks the module proxy for the
|
||||||
|
newest release of every pinned module. When the proxy is disabled it uses
|
||||||
|
the dependency facts prepared by the execution profile (the file named by
|
||||||
|
`MAINTAINER_DEPENDENCY_FACTS`), which record the newest release observed on
|
||||||
|
`proxy.golang.org` and when. If neither source is available the script
|
||||||
|
exits with status 2 instead of assuming the pins are current; the local
|
||||||
|
module cache is never used as evidence of what the newest release is.
|
||||||
|
|
||||||
```toml
|
The job fails when any check fails, so a pull request cannot land with broken
|
||||||
# mise.toml
|
code or tests, or with stale dependencies.
|
||||||
[tools]
|
|
||||||
"go:git.thokra.dev/thokra/stamp/cmd/stamp" = "latest"
|
|
||||||
```
|
|
||||||
|
|
||||||
Or build from source:
|
Run the same checks locally with:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
./scripts/check.sh
|
||||||
|
./scripts/check-deps.sh # or: mise run deps
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Create .stamp/stamp.toml
|
[`internal/ci/workflow_test.go`](../internal/ci/workflow_test.go) parses the
|
||||||
|
workflow and fails `go test ./...` if it stops running on pull requests or
|
||||||
Inside the `.stamp/` directory at the root of your repository:
|
stops invoking those scripts; [`scripts/test-ci-workflow.sh`](../scripts/test-ci-workflow.sh)
|
||||||
|
and [`scripts/test-check-deps.sh`](../scripts/test-check-deps.sh) cover the same
|
||||||
```toml
|
behaviour without needing a Go module download.
|
||||||
[[projects]]
|
|
||||||
name = "my-app"
|
|
||||||
path = "."
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[projects.publish]
|
|
||||||
tags = true
|
|
||||||
releases = true
|
|
||||||
artifacts = ["dist/my-app-*"]
|
|
||||||
```
|
|
||||||
|
|
||||||
Because `stamp.toml` lives inside `.stamp/`, git will track the directory without needing a `.gitignore` file in it.
|
|
||||||
|
|
||||||
See [`examples/stamp.toml`](../examples/stamp.toml) for a fully annotated example.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Day-to-day Workflow
|
## Two Release Workflows
|
||||||
|
|
||||||
### Adding a stamp to your PR
|
### Direct release
|
||||||
|
|
||||||
When making a change that should be released, add a stamp file:
|
Run `stamp version` and `stamp publish` directly on the base branch. Good for small projects, CLIs, or repos where a human is doing releases manually.
|
||||||
|
|
||||||
|
```
|
||||||
|
feature branch ──► merge to main ──► stamp version ──► git push ──► stamp publish
|
||||||
|
```
|
||||||
|
|
||||||
|
### Release PR (recommended for automation)
|
||||||
|
|
||||||
|
`stamp release-pr` runs in CI whenever a change is merged to the base branch. It opens a pull request that contains all the version bumps and changelog updates. Merging that PR is the explicit, reviewable release trigger. A second CI job runs `stamp publish` after the merge.
|
||||||
|
|
||||||
|
```
|
||||||
|
feature branch ──► merge to main ──► stamp release-pr ──► release PR
|
||||||
|
│
|
||||||
|
merge to main
|
||||||
|
│
|
||||||
|
stamp publish ──► tags + releases
|
||||||
|
```
|
||||||
|
|
||||||
|
The two CI jobs (create PR and publish) both run on every push to `main`. They are each no-ops when there is nothing for them to do — `stamp release-pr` exits silently if there are no pending stamp files, and `stamp publish` skips any tag that already exists.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Day-to-day: Adding a Stamp File
|
||||||
|
|
||||||
|
When making a code change that should result in a release, add a stamp file alongside it:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Interactive
|
# Interactive wizard
|
||||||
stamp add
|
stamp add
|
||||||
|
|
||||||
# Non-interactive (useful in scripts or with AI agents)
|
# Non-interactive — good for scripts and AI agents
|
||||||
stamp add --project=my-app --bump=minor --message="Added X feature" --no-interactive
|
stamp add --project=my-app --bump=minor --message="Add X feature" --no-interactive
|
||||||
```
|
```
|
||||||
|
|
||||||
This creates a `.stamp/<random-slug>.md` file, e.g.:
|
This creates a file like `.stamp/brave-river.md`:
|
||||||
|
|
||||||
```markdown
|
```
|
||||||
---
|
---
|
||||||
bumps:
|
bumps:
|
||||||
my-app: minor
|
my-app: minor
|
||||||
---
|
---
|
||||||
|
|
||||||
Added X feature
|
Add X feature
|
||||||
```
|
```
|
||||||
|
|
||||||
> Stamp files live alongside `stamp.toml` in the `.stamp/` directory.
|
Commit and push the stamp file together with your code. Your CI PR-check job (see below) will update its comment automatically.
|
||||||
|
|
||||||
Commit and push the stamp file alongside your code changes.
|
### Bump type reference
|
||||||
|
|
||||||
### Checking pending stamps
|
| Type | What it does | Example |
|
||||||
|
|------|-------------|---------|
|
||||||
|
| `major` | Breaking change | `1.2.3` → `2.0.0` |
|
||||||
|
| `minor` | New feature | `1.2.3` → `1.3.0` |
|
||||||
|
| `patch` | Bug fix | `1.2.3` → `1.2.4` |
|
||||||
|
| `premajor` | Pre-release major | `1.2.3` → `2.0.0-beta.0` |
|
||||||
|
| `preminor` | Pre-release minor | `1.2.3` → `1.3.0-beta.0` |
|
||||||
|
| `prepatch` | Pre-release patch | `1.2.3` → `1.2.4-beta.0` |
|
||||||
|
| `prerelease` | Increment pre-release counter | `1.2.4-rc.0` → `1.2.4-rc.1` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Checking Pending Stamps
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
stamp status
|
stamp status
|
||||||
@@ -95,36 +132,232 @@ stamp status
|
|||||||
PROJECT CURRENT NEXT BUMP STAMPS
|
PROJECT CURRENT NEXT BUMP STAMPS
|
||||||
------- ------- ---- ---- ------
|
------- ------- ---- ---- ------
|
||||||
my-app 1.2.3 1.3.0 minor 2
|
my-app 1.2.3 1.3.0 minor 2
|
||||||
my-lib 0.1.0 0.1.0 — 0
|
my-lib 0.4.1 0.4.1 — 0
|
||||||
```
|
|
||||||
|
|
||||||
### Releasing
|
|
||||||
|
|
||||||
On your release branch (e.g. after merging PRs):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# 1. Bump versions and update changelogs
|
|
||||||
stamp version
|
|
||||||
|
|
||||||
# 2. Publish tags, releases, and artifacts
|
|
||||||
STAMP_REPO=owner/repo stamp publish
|
|
||||||
```
|
|
||||||
|
|
||||||
For a pre-release snapshot:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
stamp version --snapshot=alpha
|
|
||||||
stamp publish
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## PR Commenting (CI)
|
## Workflow A: Direct Release
|
||||||
|
|
||||||
Use `stamp comment` in your CI pipeline to automatically comment on PRs:
|
Use this when you release manually or from CI without a release PR.
|
||||||
|
|
||||||
- ⚠️ **No stamp file?** → warns the author and explains how to add one
|
```sh
|
||||||
- ✅ **Stamps found?** → shows a table of affected projects and next versions
|
# 1. Bump versions, update changelogs, and commit
|
||||||
|
stamp version
|
||||||
|
|
||||||
|
# 2. Push the version commit and tags
|
||||||
|
git push
|
||||||
|
|
||||||
|
# 3. Create GitHub / Gitea releases and upload artifacts
|
||||||
|
STAMP_REPO=owner/repo stamp publish
|
||||||
|
```
|
||||||
|
|
||||||
|
For a pre-release snapshot (does not require `stamp preview`):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
stamp version --snapshot=rc
|
||||||
|
git push
|
||||||
|
stamp publish
|
||||||
|
```
|
||||||
|
|
||||||
|
`--snapshot` overrides the bump type for every affected project so that it produces a pre-release version with the given identifier. It is independent of `stamp preview` mode.
|
||||||
|
|
||||||
|
### Skipping the git commit
|
||||||
|
|
||||||
|
If you want to inspect or further modify the files before committing:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
stamp version --no-commit
|
||||||
|
# review the diff, make additional edits…
|
||||||
|
git add -A && git commit -m "chore: version packages"
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Workflow B: Release PR
|
||||||
|
|
||||||
|
Use this for fully automated, reviewable releases in CI.
|
||||||
|
|
||||||
|
### How it works — step by step
|
||||||
|
|
||||||
|
1. **Check for pending stamps.** If none exist, `stamp release-pr` exits immediately with no side effects. This makes it safe to run on every push.
|
||||||
|
|
||||||
|
2. **Fetch origin** and reset the release branch (default: `stamp/release`) from the tip of `origin/<base>`. The branch is always recreated cleanly, so it is always fast-forwardable and never diverges from the base branch.
|
||||||
|
|
||||||
|
3. **Apply version changes** — bump versions in `stamp.toml`, prepend changelog entries, delete consumed stamp files. This is identical to what `stamp version --no-commit` does.
|
||||||
|
|
||||||
|
4. **Commit and force-push** the release branch to `origin`.
|
||||||
|
|
||||||
|
5. **Upsert the pull request.** A hidden marker (`<!-- stamp-release-pr -->`) is embedded in the PR body. On the first run a new PR is opened; on subsequent runs the existing PR's title and body are updated to reflect any newly merged stamp files. Only one stamp release PR is ever open at a time.
|
||||||
|
|
||||||
|
The PR body contains a version table:
|
||||||
|
|
||||||
|
```
|
||||||
|
## 📦 Pending releases
|
||||||
|
|
||||||
|
| Project | Current | Next | Bump |
|
||||||
|
|---------|---------|-------|-------|
|
||||||
|
| my-app | 1.2.3 | 1.3.0 | minor |
|
||||||
|
| my-lib | 0.4.1 | 0.4.2 | patch |
|
||||||
|
```
|
||||||
|
|
||||||
|
6. **Merge the PR.** Merging triggers the publish job (see below) which creates git tags and GitHub/Gitea releases.
|
||||||
|
|
||||||
|
### CI setup — GitHub Actions
|
||||||
|
|
||||||
|
**Job 1: open / update the release PR** — runs on every push to `main`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .github/workflows/stamp-release-pr.yml
|
||||||
|
name: release PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
# Full clone so stamp can fetch and reset the release branch.
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
- name: Install stamp
|
||||||
|
run: go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
|
|
||||||
|
- name: Create or update release PR
|
||||||
|
run: stamp release-pr --base=main
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
STAMP_REPO: ${{ github.repository }}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Job 2: publish after the release PR is merged** — also runs on every push to `main`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .github/workflows/stamp-publish.yml
|
||||||
|
name: publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
- name: Install stamp
|
||||||
|
run: go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
|
|
||||||
|
- name: Publish releases
|
||||||
|
run: stamp publish
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
STAMP_REPO: ${{ github.repository }}
|
||||||
|
```
|
||||||
|
|
||||||
|
> Both jobs run on every push to `main`. They are each idempotent and safe to run concurrently: `stamp release-pr` is a no-op when there are no pending stamps; `stamp publish` skips tags that already exist.
|
||||||
|
|
||||||
|
### CI setup — Gitea Actions
|
||||||
|
|
||||||
|
**Job 1: open / update the release PR**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .gitea/workflows/stamp-release-pr.yml
|
||||||
|
name: release PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.STAMP_GITEA_TOKEN }}
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "stamp-bot"
|
||||||
|
git config user.email "stamp-bot@users.noreply.gitea.com"
|
||||||
|
|
||||||
|
- name: Install stamp
|
||||||
|
run: go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
|
|
||||||
|
- name: Create or update release PR
|
||||||
|
run: stamp release-pr --base=main
|
||||||
|
env:
|
||||||
|
STAMP_GITEA_TOKEN: ${{ secrets.STAMP_GITEA_TOKEN }}
|
||||||
|
GITEA_BASE_URL: ${{ gitea.server_url }}
|
||||||
|
STAMP_REPO: ${{ gitea.repository }}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Job 2: publish after the release PR is merged**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .gitea/workflows/stamp-publish.yml
|
||||||
|
name: publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.STAMP_GITEA_TOKEN }}
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "stamp-bot"
|
||||||
|
git config user.email "stamp-bot@users.noreply.gitea.com"
|
||||||
|
|
||||||
|
- name: Install stamp
|
||||||
|
run: go install git.thokra.dev/thokra/stamp/cmd/stamp@latest
|
||||||
|
|
||||||
|
- name: Publish releases
|
||||||
|
run: stamp publish
|
||||||
|
env:
|
||||||
|
STAMP_GITEA_TOKEN: ${{ secrets.STAMP_GITEA_TOKEN }}
|
||||||
|
GITEA_BASE_URL: ${{ gitea.server_url }}
|
||||||
|
STAMP_REPO: ${{ gitea.repository }}
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note on `STAMP_GITEA_TOKEN`:** Gitea Actions auto-injects a `GITEA_TOKEN` for each run, but that token has limited scopes and cannot create PRs or post comments. Because `GITEA_TOKEN` is a reserved name you cannot override it with a secret of the same name. Instead, create a PAT in your Gitea account settings with **`repository` (read/write)** and **`issue` (read/write)** scopes, then store it as a repository secret named `STAMP_GITEA_TOKEN`. stamp reads `STAMP_GITEA_TOKEN` first and falls back to `GITEA_TOKEN`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## PR Commenting (stamp comment)
|
||||||
|
|
||||||
|
Use `stamp comment` in CI to post a summary comment on every pull request. It keeps reviewers and contributors informed about what will be released.
|
||||||
|
|
||||||
|
- **No stamp file** → the comment warns the author and shows how to add one.
|
||||||
|
- **Stamps found** → the comment shows a table of affected projects and their projected next versions.
|
||||||
|
|
||||||
|
The comment is created on first run and updated in place on subsequent runs (identified by a hidden marker in the body).
|
||||||
|
|
||||||
### GitHub Actions
|
### GitHub Actions
|
||||||
|
|
||||||
@@ -172,27 +405,65 @@ jobs:
|
|||||||
- name: Comment on PR
|
- name: Comment on PR
|
||||||
run: stamp comment --pr=${{ gitea.event.pull_request.number }}
|
run: stamp comment --pr=${{ gitea.event.pull_request.number }}
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
STAMP_GITEA_TOKEN: ${{ secrets.STAMP_GITEA_TOKEN }}
|
||||||
GITEA_BASE_URL: ${{ gitea.server_url }}
|
GITEA_BASE_URL: ${{ gitea.server_url }}
|
||||||
STAMP_REPO: ${{ gitea.repository }}
|
STAMP_REPO: ${{ gitea.repository }}
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Stamp File Format
|
## Pre-release Mode (stamp preview)
|
||||||
|
|
||||||
Stamp files live in `.stamp/` alongside `stamp.toml`, and use Markdown with either YAML or TOML frontmatter.
|
`stamp preview` lets you put an individual project into **pre-release mode**. While in this mode, every `stamp version` or `stamp release-pr` run produces pre-release versions instead of normal ones, regardless of the bump types in the stamp files.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Enter pre-release mode — all future versions for my-app will be pre-releases
|
||||||
|
stamp preview enter my-app beta
|
||||||
|
# → next stamp version will produce e.g. 1.3.0-beta.0
|
||||||
|
|
||||||
|
# If a pre-release version already exists, subsequent runs increment the counter
|
||||||
|
# → 1.3.0-beta.0 → 1.3.0-beta.1 → 1.3.0-beta.2 …
|
||||||
|
|
||||||
|
# Exit pre-release mode — the next stamp version will produce a normal release
|
||||||
|
stamp preview exit my-app
|
||||||
|
# → next stamp version will produce e.g. 1.3.0
|
||||||
|
```
|
||||||
|
|
||||||
|
`stamp preview enter` sets the `pre_tag` field on the project in `stamp.toml` and commits nothing — it is a local config change you commit yourself. `stamp preview exit` clears the field.
|
||||||
|
|
||||||
|
### Typical pre-release workflow
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# 1. Enter beta mode
|
||||||
|
stamp preview enter my-app beta
|
||||||
|
git add .stamp/stamp.toml && git commit -m "chore: enter beta mode for my-app"
|
||||||
|
|
||||||
|
# 2. Normal development — add stamp files as usual, merge PRs
|
||||||
|
# stamp release-pr will produce beta versions automatically
|
||||||
|
|
||||||
|
# 3. When ready to release, exit beta mode
|
||||||
|
stamp preview exit my-app
|
||||||
|
git add .stamp/stamp.toml && git commit -m "chore: exit beta mode for my-app"
|
||||||
|
|
||||||
|
# 4. The next release-pr or stamp version will produce the full release (e.g. 1.3.0)
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Stamp File Format Reference
|
||||||
|
|
||||||
|
Stamp files live in `.stamp/` alongside `stamp.toml`, and use Markdown with YAML or TOML frontmatter.
|
||||||
|
|
||||||
### YAML frontmatter (default)
|
### YAML frontmatter (default)
|
||||||
|
|
||||||
```markdown
|
```
|
||||||
---
|
---
|
||||||
bumps:
|
bumps:
|
||||||
my-app: minor
|
my-app: minor
|
||||||
my-lib: patch
|
my-lib: patch
|
||||||
---
|
---
|
||||||
|
|
||||||
Short description of the change used as the changelog entry.
|
Short description used as the changelog entry.
|
||||||
|
|
||||||
- Optional bullet points
|
- Optional bullet points
|
||||||
- for more detail
|
- for more detail
|
||||||
@@ -200,7 +471,7 @@ Short description of the change used as the changelog entry.
|
|||||||
|
|
||||||
### TOML frontmatter
|
### TOML frontmatter
|
||||||
|
|
||||||
```markdown
|
```
|
||||||
+++
|
+++
|
||||||
[bumps]
|
[bumps]
|
||||||
my-app = "minor"
|
my-app = "minor"
|
||||||
@@ -209,17 +480,35 @@ my-app = "minor"
|
|||||||
Short description.
|
Short description.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Valid bump types
|
A stamp file can affect multiple projects in a single file (as shown above). Each project gets its own changelog entry with the description from the file.
|
||||||
|
|
||||||
| Type | Description |
|
---
|
||||||
|------|-------------|
|
|
||||||
| `major` | Breaking change (1.x.x → 2.0.0) |
|
## Configuration Reference
|
||||||
| `minor` | New feature (1.2.x → 1.3.0) |
|
|
||||||
| `patch` | Bug fix (1.2.3 → 1.2.4) |
|
```toml
|
||||||
| `premajor` | Pre-release major (→ 2.0.0-alpha.0) |
|
# .stamp/stamp.toml
|
||||||
| `preminor` | Pre-release minor (→ 1.3.0-beta.0) |
|
|
||||||
| `prepatch` | Pre-release patch (→ 1.2.4-rc.0) |
|
[config]
|
||||||
| `prerelease` | Increment pre-release (1.2.4-rc.0 → 1.2.4-rc.1) |
|
base_branch = "main" # Base branch targeted by release PRs (default: main)
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "my-app"
|
||||||
|
path = "apps/my-app" # Relative to repository root
|
||||||
|
version = "1.2.3" # Current version — managed by stamp, do not edit manually
|
||||||
|
changelog = "CHANGELOG.md" # Relative to `path` (default: CHANGELOG.md)
|
||||||
|
pre_tag = "" # Set by `stamp preview enter`; blank means normal releases
|
||||||
|
|
||||||
|
[projects.publish]
|
||||||
|
tags = true # Create an annotated git tag on publish
|
||||||
|
releases = true # Create a GitHub / Gitea release on publish
|
||||||
|
artifacts = [ # Glob patterns for files to upload to the release
|
||||||
|
"apps/my-app/dist/my-app-linux-amd64",
|
||||||
|
"apps/my-app/dist/my-app-darwin-arm64",
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Tag format: `<name>@v<version>` for monorepos (e.g. `my-app@v1.3.0`), or `v<version>` for single-project repositories where `name` is empty.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -227,7 +516,8 @@ Short description.
|
|||||||
|
|
||||||
| Variable | Purpose |
|
| Variable | Purpose |
|
||||||
|----------|---------|
|
|----------|---------|
|
||||||
| `STAMP_REPO` | Repository slug `owner/repo` used by publish and comment |
|
| `STAMP_REPO` | Repository slug `owner/repo` — required for `publish`, `comment`, and `release-pr` |
|
||||||
| `GITHUB_TOKEN` | GitHub token for releases and PR comments — automatically provided by the GitHub Actions runner; no manual setup needed |
|
| `GITHUB_TOKEN` | GitHub token — automatically injected by GitHub Actions; no setup needed |
|
||||||
| `GITEA_TOKEN` | Gitea access token — **must be created manually**; create a token in your Gitea account settings and store it as a repository secret |
|
| `GITEA_TOKEN` | Auto-injected by Gitea Actions with limited scopes — **do not use this for stamp** |
|
||||||
| `GITEA_BASE_URL` | Gitea instance URL (e.g. `https://gitea.example.com`) — also used to detect Gitea mode |
|
| `STAMP_GITEA_TOKEN` | PAT you create manually with `repository` (read/write) and `issue` (read/write) scopes. The name `GITEA_TOKEN` is reserved by Gitea Actions, so a different name is required. |
|
||||||
|
| `GITEA_BASE_URL` | Gitea instance URL (e.g. `https://gitea.example.com`) — presence of this variable also activates Gitea mode |
|
||||||
@@ -1,48 +1,53 @@
|
|||||||
module git.thokra.dev/thokra/stamp
|
module git.thokra.dev/thokra/stamp
|
||||||
|
|
||||||
go 1.26.1
|
go 1.27.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
code.gitea.io/sdk/gitea v0.23.2
|
code.gitea.io/sdk/gitea v0.25.1
|
||||||
github.com/BurntSushi/toml v1.6.0
|
github.com/BurntSushi/toml v1.6.0
|
||||||
github.com/Masterminds/semver/v3 v3.4.0
|
github.com/Masterminds/semver/v3 v3.5.0
|
||||||
|
github.com/charmbracelet/huh v1.0.0
|
||||||
github.com/google/go-github/v70 v70.0.0
|
github.com/google/go-github/v70 v70.0.0
|
||||||
github.com/urfave/cli/v3 v3.7.0
|
github.com/urfave/cli/v3 v3.14.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/42wim/httpsig v1.2.3 // indirect
|
github.com/42wim/httpsig v1.3.0 // indirect
|
||||||
github.com/atotto/clipboard v0.1.4 // indirect
|
github.com/atotto/clipboard v0.1.4 // indirect
|
||||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||||
|
github.com/bits-and-blooms/bitset v1.27.0 // indirect
|
||||||
github.com/catppuccin/go v0.3.0 // indirect
|
github.com/catppuccin/go v0.3.0 // indirect
|
||||||
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 // indirect
|
github.com/charmbracelet/bubbles v1.0.0 // indirect
|
||||||
github.com/charmbracelet/bubbletea v1.3.6 // indirect
|
github.com/charmbracelet/bubbletea v1.3.10 // indirect
|
||||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
|
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
||||||
github.com/charmbracelet/huh v1.0.0 // indirect
|
|
||||||
github.com/charmbracelet/lipgloss v1.1.0 // indirect
|
github.com/charmbracelet/lipgloss v1.1.0 // indirect
|
||||||
github.com/charmbracelet/x/ansi v0.9.3 // indirect
|
github.com/charmbracelet/x/ansi v0.11.9 // indirect
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
|
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
|
||||||
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
|
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
|
||||||
github.com/charmbracelet/x/term v0.2.1 // indirect
|
github.com/charmbracelet/x/term v0.2.2 // indirect
|
||||||
|
github.com/clipperhouse/displaywidth v0.11.0 // indirect
|
||||||
|
github.com/clipperhouse/stringish v0.1.1 // indirect
|
||||||
|
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
||||||
github.com/davidmz/go-pageant v1.0.2 // indirect
|
github.com/davidmz/go-pageant v1.0.2 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.1.0 // indirect
|
||||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
||||||
github.com/go-fed/httpsig v1.1.0 // indirect
|
github.com/go-fed/httpsig v1.1.0 // indirect
|
||||||
github.com/google/go-querystring v1.1.0 // indirect
|
go.yaml.in/yaml/v3 v3.0.5 // indirect
|
||||||
github.com/hashicorp/go-version v1.7.0 // indirect
|
github.com/google/go-querystring v1.2.0 // indirect
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
github.com/hashicorp/go-version v1.9.0 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/lucasb-eyer/go-colorful v1.4.1 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.24 // indirect
|
||||||
github.com/mattn/go-localereader v0.0.1 // indirect
|
github.com/mattn/go-localereader v0.0.1 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
github.com/mattn/go-runewidth v0.0.31 // indirect
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
||||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
||||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||||
github.com/muesli/termenv v0.16.0 // indirect
|
github.com/muesli/termenv v0.16.0 // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
github.com/xo/terminfo v1.2.0 // indirect
|
||||||
golang.org/x/crypto v0.39.0 // indirect
|
golang.org/x/crypto v0.58.0 // indirect
|
||||||
golang.org/x/sync v0.15.0 // indirect
|
golang.org/x/sync v0.24.0 // indirect
|
||||||
golang.org/x/sys v0.33.0 // indirect
|
golang.org/x/sys v0.49.0 // indirect
|
||||||
golang.org/x/text v0.26.0 // indirect
|
golang.org/x/text v0.43.0 // indirect
|
||||||
)
|
)
|
||||||
@@ -1,62 +1,124 @@
|
|||||||
code.gitea.io/sdk/gitea v0.23.2 h1:iJB1FDmLegwfwjX8gotBDHdPSbk/ZR8V9VmEJaVsJYg=
|
code.gitea.io/sdk/gitea v0.23.2 h1:iJB1FDmLegwfwjX8gotBDHdPSbk/ZR8V9VmEJaVsJYg=
|
||||||
code.gitea.io/sdk/gitea v0.23.2/go.mod h1:yyF5+GhljqvA30sRDreoyHILruNiy4ASufugzYg0VHM=
|
code.gitea.io/sdk/gitea v0.23.2/go.mod h1:yyF5+GhljqvA30sRDreoyHILruNiy4ASufugzYg0VHM=
|
||||||
|
code.gitea.io/sdk/gitea v0.25.1 h1:yywxWwoV+SdjHtbC6unBiXojWdZOtoHuGhEazEXeWuE=
|
||||||
|
code.gitea.io/sdk/gitea v0.25.1/go.mod h1:uDFWYBU8dgZsgOHwe6C/6olxvf8FHguNB3wW1i83fgg=
|
||||||
github.com/42wim/httpsig v1.2.3 h1:xb0YyWhkYj57SPtfSttIobJUPJZB9as1nsfo7KWVcEs=
|
github.com/42wim/httpsig v1.2.3 h1:xb0YyWhkYj57SPtfSttIobJUPJZB9as1nsfo7KWVcEs=
|
||||||
github.com/42wim/httpsig v1.2.3/go.mod h1:nZq9OlYKDrUBhptd77IHx4/sZZD+IxTBADvAPI9G/EM=
|
github.com/42wim/httpsig v1.2.3/go.mod h1:nZq9OlYKDrUBhptd77IHx4/sZZD+IxTBADvAPI9G/EM=
|
||||||
|
github.com/42wim/httpsig v1.3.0 h1:HK2bieeZ99X9IvOoc1ST6yrhLek0f4MqlEGES2JCP3g=
|
||||||
|
github.com/42wim/httpsig v1.3.0/go.mod h1:lgC3Yrvp4lxi1odEF1ge3kQBu/VM+SRcZQu5YwiR3dU=
|
||||||
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
||||||
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||||
|
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
|
||||||
|
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
|
||||||
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
|
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
|
||||||
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||||
|
github.com/Masterminds/semver/v3 v3.5.0 h1:kQceYJfbupGfZOKZQg0kou0DgAKhzDg2NZPAwZ/2OOE=
|
||||||
|
github.com/Masterminds/semver/v3 v3.5.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||||
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
|
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
|
||||||
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
|
||||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||||
|
github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o=
|
||||||
|
github.com/aymanbagabas/go-udiff v0.4.1/go.mod h1:0L9PGwj20lrtmEMeyw4WKJ/TMyDtvAoK9bf2u/mNo3w=
|
||||||
|
github.com/bits-and-blooms/bitset v1.27.0 h1:0s3FwmJRlxOqUsmQK+a8/HcPMgPu8jM7KrE/y/X7d+8=
|
||||||
|
github.com/bits-and-blooms/bitset v1.27.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||||
github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY=
|
github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY=
|
||||||
github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
|
github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
|
||||||
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 h1:JFgG/xnwFfbezlUnFMJy0nusZvytYysV4SCS2cYbvws=
|
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 h1:JFgG/xnwFfbezlUnFMJy0nusZvytYysV4SCS2cYbvws=
|
||||||
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7/go.mod h1:ISC1gtLcVilLOf23wvTfoQuYbW2q0JevFxPfUzZ9Ybw=
|
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7/go.mod h1:ISC1gtLcVilLOf23wvTfoQuYbW2q0JevFxPfUzZ9Ybw=
|
||||||
|
github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5fXonfvc=
|
||||||
|
github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E=
|
||||||
|
github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=
|
||||||
|
github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
|
||||||
github.com/charmbracelet/bubbletea v1.3.6 h1:VkHIxPJQeDt0aFJIsVxw8BQdh/F/L2KKZGsK6et5taU=
|
github.com/charmbracelet/bubbletea v1.3.6 h1:VkHIxPJQeDt0aFJIsVxw8BQdh/F/L2KKZGsK6et5taU=
|
||||||
github.com/charmbracelet/bubbletea v1.3.6/go.mod h1:oQD9VCRQFF8KplacJLo28/jofOI2ToOfGYeFgBBxHOc=
|
github.com/charmbracelet/bubbletea v1.3.6/go.mod h1:oQD9VCRQFF8KplacJLo28/jofOI2ToOfGYeFgBBxHOc=
|
||||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
|
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
|
||||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
|
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
|
||||||
|
github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q=
|
||||||
|
github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q=
|
||||||
|
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
|
||||||
|
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
|
||||||
github.com/charmbracelet/huh v1.0.0 h1:wOnedH8G4qzJbmhftTqrpppyqHakl/zbbNdXIWJyIxw=
|
github.com/charmbracelet/huh v1.0.0 h1:wOnedH8G4qzJbmhftTqrpppyqHakl/zbbNdXIWJyIxw=
|
||||||
github.com/charmbracelet/huh v1.0.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4=
|
github.com/charmbracelet/huh v1.0.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4=
|
||||||
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
|
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
|
||||||
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
|
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
|
||||||
|
github.com/charmbracelet/x/ansi v0.11.9 h1:kIrqLBxtTVbLyyHO2Evoi93EjQo1mylWmpNEsfPxXAM=
|
||||||
|
github.com/charmbracelet/x/ansi v0.11.9/go.mod h1:DG/hpOnaI2QJ/KMMqLL2h0KVhluuJLazf8973P+Vy5w=
|
||||||
github.com/charmbracelet/x/ansi v0.9.3 h1:BXt5DHS/MKF+LjuK4huWrC6NCvHtexww7dMayh6GXd0=
|
github.com/charmbracelet/x/ansi v0.9.3 h1:BXt5DHS/MKF+LjuK4huWrC6NCvHtexww7dMayh6GXd0=
|
||||||
github.com/charmbracelet/x/ansi v0.9.3/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
|
github.com/charmbracelet/x/ansi v0.9.3/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k=
|
github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k=
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
|
github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
|
||||||
|
github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
|
||||||
|
github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=
|
||||||
|
github.com/charmbracelet/x/conpty v0.2.0 h1:eKtA2hm34qNfgJCDp/M6Dc0gLy7e07YEK4qAdNGOvVY=
|
||||||
|
github.com/charmbracelet/x/conpty v0.2.0/go.mod h1:fexgUnVrZgw8scD49f6VSi0Ggj9GWYIrpedRthAwW/8=
|
||||||
|
github.com/charmbracelet/x/errors v0.0.0-20261025003702-835ad0048169 h1:lmV1ffak03cvDgvVSP1wAWD8Y745Npt8nN2f2vBjJYk=
|
||||||
|
github.com/charmbracelet/x/errors v0.0.0-20261025003702-835ad0048169/go.mod h1:O2BTD/aMVQDmrvqroIO3fB6zXUuU07ZpVt21QTmZjRg=
|
||||||
|
github.com/charmbracelet/x/exp/golden v0.1.0 h1:qgUxGaHX4I8Fg077vD+54+qFmDWrgO19lTCQLblHWko=
|
||||||
|
github.com/charmbracelet/x/exp/golden v0.1.0/go.mod h1:6fMpcW6iwN/kX+xJ52eqVWsDiBTe0UJD24JLoHFe+P0=
|
||||||
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4=
|
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4=
|
||||||
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ=
|
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ=
|
||||||
|
github.com/charmbracelet/x/exp/strings v0.1.0 h1:i69S2XI7uG1u4NLGeJPSYU++Nmjvpo9nwd6aoEm7gkA=
|
||||||
|
github.com/charmbracelet/x/exp/strings v0.1.0/go.mod h1:/ehtMPNh9K4odGFkqYJKpIYyePhdp1hLBRvyY4bWkH8=
|
||||||
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
|
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
|
||||||
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
|
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
|
||||||
|
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
|
||||||
|
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
|
||||||
|
github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
|
||||||
|
github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
|
||||||
|
github.com/charmbracelet/x/xpty v0.1.4 h1:4jaW7u+8AHQMxesiVc+zUMsspu7GyDwtJO+gy/tFtW4=
|
||||||
|
github.com/charmbracelet/x/xpty v0.1.4/go.mod h1:7t8P7BpPiolHJ1pLzz7/4ujDbD+sUxI9yA3CBOLOIcU=
|
||||||
|
github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=
|
||||||
|
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
|
||||||
|
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
|
||||||
|
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
|
||||||
|
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
||||||
|
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
||||||
|
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
|
||||||
|
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454WvHn0=
|
github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454WvHn0=
|
||||||
github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE=
|
github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
|
github.com/dustin/go-humanize v1.1.0 h1:dbKTrvD0klcbBV/h4AWJdMuZogJACoMlvWIWZ5b2xWg=
|
||||||
|
github.com/dustin/go-humanize v1.1.0/go.mod h1:hc1CvRkJMsgxqjmjMQF3QNRAZBwY8AXBAzKYoSX9sFI=
|
||||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
|
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
|
||||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
|
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
|
||||||
github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI=
|
github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI=
|
||||||
github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
|
github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/google/go-github/v70 v70.0.0 h1:/tqCp5KPrcvqCc7vIvYyFYTiCGrYvaWoYMGHSQbo55o=
|
github.com/google/go-github/v70 v70.0.0 h1:/tqCp5KPrcvqCc7vIvYyFYTiCGrYvaWoYMGHSQbo55o=
|
||||||
github.com/google/go-github/v70 v70.0.0/go.mod h1:xBUZgo8MI3lUL/hwxl3hlceJW1U8MVnXP3zUyI+rhQY=
|
github.com/google/go-github/v70 v70.0.0/go.mod h1:xBUZgo8MI3lUL/hwxl3hlceJW1U8MVnXP3zUyI+rhQY=
|
||||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||||
|
github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0=
|
||||||
|
github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU=
|
||||||
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
|
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
|
||||||
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||||
|
github.com/hashicorp/go-version v1.9.0 h1:CeOIz6k+LoN3qX9Z0tyQrPtiB1DFYRPfCIBtaXPSCnA=
|
||||||
|
github.com/hashicorp/go-version v1.9.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||||
|
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||||
|
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
|
github.com/lucasb-eyer/go-colorful v1.4.1 h1:1EO+WB73+EH8EVbzlrG3KLAfEypQWVHIBqlTf+2hNss=
|
||||||
|
github.com/lucasb-eyer/go-colorful v1.4.1/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
||||||
|
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||||
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
||||||
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
||||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
|
github.com/mattn/go-runewidth v0.0.31 h1:1oCV4ReTlosDBc6rYRw5cL8S/4y8iv5oRl4SJ5IBgwo=
|
||||||
|
github.com/mattn/go-runewidth v0.0.31/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8=
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
|
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
|
||||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
|
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
|
||||||
@@ -70,38 +132,70 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
|
github.com/sahilm/fuzzy v0.1.3 h1:juByESSS32nVD81vr6tHmKmA/8zde7gE+x5CLxrzXPU=
|
||||||
|
github.com/sahilm/fuzzy v0.1.3/go.mod h1:au6//VbVSqu6DFrkL2CfjlJ5iURpNCPeE+1GwY3XsT8=
|
||||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
|
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
|
||||||
|
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
|
||||||
|
github.com/urfave/cli/v3 v3.14.0 h1:a8414NQlHJs0c/iBsulKLzlES0n/lEAskbL2LKpU4/s=
|
||||||
|
github.com/urfave/cli/v3 v3.14.0/go.mod h1:vXn6HxPNccJSzQr2QvwVncOKrgYGIHU0HY5h8B2nQj4=
|
||||||
github.com/urfave/cli/v3 v3.7.0 h1:AGSnbUyjtLiM+WJUb4dzXKldl/gL+F8OwmRDtVr6g2U=
|
github.com/urfave/cli/v3 v3.7.0 h1:AGSnbUyjtLiM+WJUb4dzXKldl/gL+F8OwmRDtVr6g2U=
|
||||||
github.com/urfave/cli/v3 v3.7.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
|
github.com/urfave/cli/v3 v3.7.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
||||||
|
github.com/xo/terminfo v1.2.0 h1:d0ZTOCpuGE0lwSAOs0zcJjwz3jWQyqcRt9XbGJpCOl4=
|
||||||
|
github.com/xo/terminfo v1.2.0/go.mod h1:lGzkSo8Fe7IRh/w+Gqz7n5mDog4FVXCj3gy/DYTBqio=
|
||||||
|
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
|
||||||
|
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||||
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
|
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
|
||||||
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
|
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
|
||||||
|
golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54=
|
||||||
|
golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w=
|
||||||
|
golang.org/x/exp v0.0.0-20261014143641-f0251eb4aa3e h1:HgI6W1OolKK6tcV74is+rl9SMT0njsHlp0TbQiGXI/A=
|
||||||
|
golang.org/x/exp v0.0.0-20261014143641-f0251eb4aa3e/go.mod h1:DBoxwWhjaW8DJJw/YeM4zpeOKMC1FMXSblsYy+1mFSw=
|
||||||
|
golang.org/x/mod v0.42.0 h1:ICeL3t2L30ljSPHHxDnR4fqVcBt/zR2zJAb9juavmQg=
|
||||||
|
golang.org/x/mod v0.42.0/go.mod h1:u5fzIrRInkL8MaO1cbRkUHT64v303YIT5KEqpNr7jRs=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY=
|
||||||
|
golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
||||||
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
|
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
|
||||||
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||||
|
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
|
||||||
|
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
|
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
|
||||||
|
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg=
|
golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg=
|
||||||
golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
|
golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/term v0.47.0 h1:cpyOwQkr2Nzxe2p6KnrTG7Ei2wtzjsuSjhpXXepZ/BM=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/term v0.47.0/go.mod h1:efAfAuG6RKABvg1ArGebRkvX6LXul14SM67o2e4mUCY=
|
||||||
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
||||||
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
|
||||||
|
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs=
|
||||||
|
golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY=
|
||||||
|
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
// Package ci tests the repository's Gitea Actions configuration.
|
||||||
|
package ci
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// workflowPath is the workflow that gates every pull request.
|
||||||
|
const workflowPath = "../../.gitea/workflows/ci.yml"
|
||||||
|
|
||||||
|
func TestPullRequestWorkflow(t *testing.T) {
|
||||||
|
data, err := os.ReadFile(filepath.FromSlash(workflowPath))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("read %s: %v", workflowPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var doc yaml.Node
|
||||||
|
if err := yaml.Unmarshal(data, &doc); err != nil {
|
||||||
|
t.Fatalf("parse %s: %v", workflowPath, err)
|
||||||
|
}
|
||||||
|
if len(doc.Content) != 1 || doc.Content[0].Kind != yaml.MappingNode {
|
||||||
|
t.Fatalf("%s must be a single YAML mapping", workflowPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow := mapping(doc.Content[0])
|
||||||
|
on := workflow["on"]
|
||||||
|
if on == nil {
|
||||||
|
t.Fatal("workflow has no on: trigger")
|
||||||
|
}
|
||||||
|
if mapping(on)["pull_request"] == nil {
|
||||||
|
t.Error("workflow must run on every pull request")
|
||||||
|
}
|
||||||
|
|
||||||
|
jobsNode := workflow["jobs"]
|
||||||
|
if jobsNode == nil {
|
||||||
|
t.Fatal("workflow has no jobs")
|
||||||
|
}
|
||||||
|
jobs := mapping(jobsNode)
|
||||||
|
if len(jobs) != 1 {
|
||||||
|
t.Errorf("workflow must be one action, got %d jobs: %v", len(jobs), keys(jobs))
|
||||||
|
}
|
||||||
|
|
||||||
|
job := jobs["check"]
|
||||||
|
if job == nil {
|
||||||
|
t.Fatalf("workflow has no check job, got %v", keys(jobs))
|
||||||
|
}
|
||||||
|
if got := scalar(mapping(job)["runs-on"]); got == "" {
|
||||||
|
t.Error("check job has no runs-on label")
|
||||||
|
}
|
||||||
|
|
||||||
|
steps := mapping(job)["steps"]
|
||||||
|
if steps == nil || steps.Kind != yaml.SequenceNode {
|
||||||
|
t.Fatal("check job has no steps")
|
||||||
|
}
|
||||||
|
|
||||||
|
runs := map[string]bool{}
|
||||||
|
for _, step := range steps.Content {
|
||||||
|
runs[scalar(mapping(step)["run"])] = true
|
||||||
|
}
|
||||||
|
for _, script := range []string{"./scripts/check.sh", "./scripts/check-deps.sh"} {
|
||||||
|
if !runs[script] {
|
||||||
|
t.Errorf("check job does not run %s", script)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mapping returns the mapping nodes of n keyed by their scalar key.
|
||||||
|
func mapping(n *yaml.Node) map[string]*yaml.Node {
|
||||||
|
out := map[string]*yaml.Node{}
|
||||||
|
if n == nil || n.Kind != yaml.MappingNode {
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
for i := 0; i < len(n.Content)-1; i += 2 {
|
||||||
|
out[n.Content[i].Value] = n.Content[i+1]
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// scalar returns the value of a scalar node, or the empty string.
|
||||||
|
func scalar(n *yaml.Node) string {
|
||||||
|
if n == nil || n.Kind != yaml.ScalarNode {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return n.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
// keys returns the sorted keys of m for error messages.
|
||||||
|
func keys(m map[string]*yaml.Node) []string {
|
||||||
|
out := make([]string, 0, len(m))
|
||||||
|
for k := range m {
|
||||||
|
out = append(out, k)
|
||||||
|
}
|
||||||
|
sort.Strings(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCheckScriptsAreExecutable(t *testing.T) {
|
||||||
|
for _, script := range []string{"../../scripts/check.sh", "../../scripts/check-deps.sh"} {
|
||||||
|
info, err := os.Stat(filepath.FromSlash(script))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("stat %s: %v", script, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if info.Mode()&0o111 == 0 {
|
||||||
|
t.Errorf("%s is not executable; the ci workflow runs it directly", script)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,3 +82,36 @@ func TagExists(dir, tag string) (bool, error) {
|
|||||||
}
|
}
|
||||||
return strings.TrimSpace(out) == tag, nil
|
return strings.TrimSpace(out) == tag, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BranchExists returns true if the given local branch exists.
|
||||||
|
func BranchExists(dir, branch string) (bool, error) {
|
||||||
|
out, err := Run(dir, "branch", "--list", branch)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(out) != "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckoutBranch checks out an existing branch.
|
||||||
|
func CheckoutBranch(dir, branch string) error {
|
||||||
|
_, err := Run(dir, "checkout", branch)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckoutNewBranch creates and checks out a new branch from the given base.
|
||||||
|
func CheckoutNewBranch(dir, branch, base string) error {
|
||||||
|
_, err := Run(dir, "checkout", "-B", branch, base)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// PushBranch force-pushes a branch to origin.
|
||||||
|
func PushBranch(dir, branch string) error {
|
||||||
|
_, err := Run(dir, "push", "--force-with-lease", "origin", branch)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// FetchOrigin fetches from origin.
|
||||||
|
func FetchOrigin(dir string) error {
|
||||||
|
_, err := Run(dir, "fetch", "origin")
|
||||||
|
return err
|
||||||
|
}
|
||||||
+79
-3
@@ -8,6 +8,19 @@ import (
|
|||||||
giteaSDK "code.gitea.io/sdk/gitea"
|
giteaSDK "code.gitea.io/sdk/gitea"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// isPRsDisabledError returns true when the Gitea server rejects a PR operation
|
||||||
|
// because the Pull Requests unit is disabled on the repository.
|
||||||
|
func isPRsDisabledError(err error) bool {
|
||||||
|
if err == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
msg := err.Error()
|
||||||
|
return strings.Contains(msg, "Can't read pulls") ||
|
||||||
|
strings.Contains(msg, "UnitTypeCode")
|
||||||
|
}
|
||||||
|
|
||||||
|
const prMarker = "<!-- stamp-release-pr -->"
|
||||||
|
|
||||||
// Client wraps the Gitea API.
|
// Client wraps the Gitea API.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
client *giteaSDK.Client
|
client *giteaSDK.Client
|
||||||
@@ -17,12 +30,18 @@ type Client struct {
|
|||||||
|
|
||||||
const commentMarker = "<!-- stamp-pr-comment -->"
|
const commentMarker = "<!-- stamp-pr-comment -->"
|
||||||
|
|
||||||
// NewClient creates a Gitea client from GITEA_TOKEN and GITEA_BASE_URL environment variables.
|
// NewClient creates a Gitea client from GITEA_BASE_URL and a token environment variable.
|
||||||
|
// The token is read from STAMP_GITEA_TOKEN first, falling back to GITEA_TOKEN.
|
||||||
|
// STAMP_GITEA_TOKEN should be used in CI to avoid the reserved GITEA_TOKEN name that
|
||||||
|
// Gitea Actions injects automatically (with limited scopes).
|
||||||
// The repoSlug must be in "owner/repo" format.
|
// The repoSlug must be in "owner/repo" format.
|
||||||
func NewClient(repoSlug string) (*Client, error) {
|
func NewClient(repoSlug string) (*Client, error) {
|
||||||
token := os.Getenv("GITEA_TOKEN")
|
token := os.Getenv("STAMP_GITEA_TOKEN")
|
||||||
if token == "" {
|
if token == "" {
|
||||||
return nil, fmt.Errorf("GITEA_TOKEN environment variable is not set")
|
token = os.Getenv("GITEA_TOKEN")
|
||||||
|
}
|
||||||
|
if token == "" {
|
||||||
|
return nil, fmt.Errorf("neither STAMP_GITEA_TOKEN nor GITEA_TOKEN environment variable is set")
|
||||||
}
|
}
|
||||||
baseURL := os.Getenv("GITEA_BASE_URL")
|
baseURL := os.Getenv("GITEA_BASE_URL")
|
||||||
if baseURL == "" {
|
if baseURL == "" {
|
||||||
@@ -74,6 +93,63 @@ func (c *Client) UploadAsset(releaseID int64, filePath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpsertPR creates or updates a stamp release PR on the given base branch.
|
||||||
|
// It identifies the existing PR by scanning open PRs for the hidden marker in the body.
|
||||||
|
func (c *Client) UpsertPR(head, base, title, body string) (int64, string, error) {
|
||||||
|
markedBody := prMarker + "\n" + body
|
||||||
|
|
||||||
|
// Search open PRs for an existing stamp release PR (Gitea SDK does not support
|
||||||
|
// filtering by head branch, so we filter client-side).
|
||||||
|
prs, _, err := c.client.ListRepoPullRequests(c.owner, c.repo, giteaSDK.ListPullRequestsOptions{
|
||||||
|
State: giteaSDK.StateOpen,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
if isPRsDisabledError(err) {
|
||||||
|
return 0, "", fmt.Errorf(
|
||||||
|
"pull requests are disabled on %s/%s — enable them under Settings → General → Features → Pull Requests",
|
||||||
|
c.owner, c.repo,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return 0, "", fmt.Errorf("listing pull requests: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pr := range prs {
|
||||||
|
if pr.Head != nil && pr.Head.Name != head {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.Contains(pr.Body, prMarker) {
|
||||||
|
// Update existing PR.
|
||||||
|
updated, _, err := c.client.EditPullRequest(c.owner, c.repo, pr.Index,
|
||||||
|
giteaSDK.EditPullRequestOption{
|
||||||
|
Title: title,
|
||||||
|
Body: &markedBody,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return 0, "", fmt.Errorf("updating pull request #%d: %w", pr.Index, err)
|
||||||
|
}
|
||||||
|
return updated.Index, updated.HTMLURL, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new PR.
|
||||||
|
pr, _, err := c.client.CreatePullRequest(c.owner, c.repo, giteaSDK.CreatePullRequestOption{
|
||||||
|
Head: head,
|
||||||
|
Base: base,
|
||||||
|
Title: title,
|
||||||
|
Body: markedBody,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
if isPRsDisabledError(err) {
|
||||||
|
return 0, "", fmt.Errorf(
|
||||||
|
"pull requests are disabled on %s/%s — enable them under Settings → General → Features → Pull Requests",
|
||||||
|
c.owner, c.repo,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return 0, "", fmt.Errorf("creating pull request: %w", err)
|
||||||
|
}
|
||||||
|
return pr.Index, pr.HTMLURL, nil
|
||||||
|
}
|
||||||
|
|
||||||
// UpsertPRComment posts or updates a stamped PR comment.
|
// UpsertPRComment posts or updates a stamped PR comment.
|
||||||
func (c *Client) UpsertPRComment(prNumber int, body string) error {
|
func (c *Client) UpsertPRComment(prNumber int, body string) error {
|
||||||
markedBody := commentMarker + "\n" + body
|
markedBody := commentMarker + "\n" + body
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package gitea
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsPRsDisabledError(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
err error
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{name: "nil error", err: nil, want: false},
|
||||||
|
{name: "pulls unit disabled", err: errors.New(`Get "https://gitea.example.com/api/v1/repos/o/r/pulls": Can't read pulls`), want: true},
|
||||||
|
{name: "code unit disabled", err: errors.New("repository unit UnitTypeCode is disabled"), want: true},
|
||||||
|
{name: "unrelated error", err: errors.New("connection refused"), want: false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := isPRsDisabledError(tt.err); got != tt.want {
|
||||||
|
t.Fatalf("isPRsDisabledError(%v) = %v, want %v", tt.err, got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// newVersionServer starts a stub Gitea API server that only answers the
|
||||||
|
// version probe performed by the SDK client constructor.
|
||||||
|
func newVersionServer(t *testing.T) *httptest.Server {
|
||||||
|
t.Helper()
|
||||||
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.URL.Path != "/api/v1/version" {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
_, _ = w.Write([]byte(`{"version":"1.22.0"}`))
|
||||||
|
}))
|
||||||
|
t.Cleanup(srv.Close)
|
||||||
|
return srv
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewClientRequiresToken(t *testing.T) {
|
||||||
|
t.Setenv("STAMP_GITEA_TOKEN", "")
|
||||||
|
t.Setenv("GITEA_TOKEN", "")
|
||||||
|
t.Setenv("GITEA_BASE_URL", "https://gitea.example.com")
|
||||||
|
|
||||||
|
_, err := NewClient("owner/repo")
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("expected an error when no token is configured")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), "STAMP_GITEA_TOKEN") {
|
||||||
|
t.Fatalf("expected error to mention STAMP_GITEA_TOKEN, got %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewClientPrefersStampToken(t *testing.T) {
|
||||||
|
srv := newVersionServer(t)
|
||||||
|
t.Setenv("STAMP_GITEA_TOKEN", "stamp-token")
|
||||||
|
t.Setenv("GITEA_TOKEN", "fallback-token")
|
||||||
|
t.Setenv("GITEA_BASE_URL", srv.URL)
|
||||||
|
|
||||||
|
c, err := NewClient("owner/repo")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("NewClient returned error: %v", err)
|
||||||
|
}
|
||||||
|
if c == nil || c.owner != "owner" || c.repo != "repo" {
|
||||||
|
t.Fatalf("unexpected client: %+v", c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewClientFallsBackToGiteaToken(t *testing.T) {
|
||||||
|
srv := newVersionServer(t)
|
||||||
|
t.Setenv("STAMP_GITEA_TOKEN", "")
|
||||||
|
t.Setenv("GITEA_TOKEN", "fallback-token")
|
||||||
|
t.Setenv("GITEA_BASE_URL", srv.URL)
|
||||||
|
|
||||||
|
if _, err := NewClient("owner/repo"); err != nil {
|
||||||
|
t.Fatalf("NewClient returned error: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewClientRejectsInvalidSlug(t *testing.T) {
|
||||||
|
t.Setenv("STAMP_GITEA_TOKEN", "stamp-token")
|
||||||
|
t.Setenv("GITEA_TOKEN", "")
|
||||||
|
t.Setenv("GITEA_BASE_URL", "https://gitea.example.com")
|
||||||
|
|
||||||
|
_, err := NewClient("not-a-slug")
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("expected an error for a slug without owner/repo")
|
||||||
|
}
|
||||||
|
if !strings.Contains(err.Error(), "invalid repo slug") {
|
||||||
|
t.Fatalf("expected an invalid slug error, got %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -94,3 +94,49 @@ func (c *Client) UpsertPRComment(ctx context.Context, prNumber int, body string)
|
|||||||
&gh.IssueComment{Body: gh.Ptr(markedBody)})
|
&gh.IssueComment{Body: gh.Ptr(markedBody)})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const prMarker = "<!-- stamp-release-pr -->"
|
||||||
|
|
||||||
|
// UpsertPR creates or updates a release PR from head into base.
|
||||||
|
// It identifies a previously-created PR by the hidden marker in the body.
|
||||||
|
// Returns the PR number and the URL.
|
||||||
|
func (c *Client) UpsertPR(ctx context.Context, head, base, title, body string) (int, string, error) {
|
||||||
|
markedBody := prMarker + "\n" + body
|
||||||
|
|
||||||
|
// Search open PRs from this head branch.
|
||||||
|
prs, _, err := c.client.PullRequests.List(ctx, c.owner, c.repo, &gh.PullRequestListOptions{
|
||||||
|
State: "open",
|
||||||
|
Head: c.owner + ":" + head,
|
||||||
|
Base: base,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return 0, "", fmt.Errorf("listing pull requests: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pr := range prs {
|
||||||
|
if strings.Contains(pr.GetBody(), prMarker) {
|
||||||
|
// Update existing PR.
|
||||||
|
updated, _, err := c.client.PullRequests.Edit(ctx, c.owner, c.repo, pr.GetNumber(),
|
||||||
|
&gh.PullRequest{
|
||||||
|
Title: gh.Ptr(title),
|
||||||
|
Body: gh.Ptr(markedBody),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return 0, "", fmt.Errorf("updating pull request: %w", err)
|
||||||
|
}
|
||||||
|
return updated.GetNumber(), updated.GetHTMLURL(), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new PR.
|
||||||
|
pr, _, err := c.client.PullRequests.Create(ctx, c.owner, c.repo, &gh.NewPullRequest{
|
||||||
|
Title: gh.Ptr(title),
|
||||||
|
Head: gh.Ptr(head),
|
||||||
|
Base: gh.Ptr(base),
|
||||||
|
Body: gh.Ptr(markedBody),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return 0, "", fmt.Errorf("creating pull request: %w", err)
|
||||||
|
}
|
||||||
|
return pr.GetNumber(), pr.GetHTMLURL(), nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,278 @@
|
|||||||
|
package releasepr
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.thokra.dev/thokra/stamp/internal/changelog"
|
||||||
|
"git.thokra.dev/thokra/stamp/internal/changeset"
|
||||||
|
"git.thokra.dev/thokra/stamp/internal/config"
|
||||||
|
"git.thokra.dev/thokra/stamp/internal/git"
|
||||||
|
giteaClient "git.thokra.dev/thokra/stamp/internal/gitea"
|
||||||
|
ghClient "git.thokra.dev/thokra/stamp/internal/github"
|
||||||
|
"git.thokra.dev/thokra/stamp/internal/semver"
|
||||||
|
)
|
||||||
|
|
||||||
|
const DefaultReleaseBranch = "stamp/release"
|
||||||
|
|
||||||
|
// Options controls release-pr behaviour.
|
||||||
|
type Options struct {
|
||||||
|
// RepoRoot is the absolute path to the repository root.
|
||||||
|
RepoRoot string
|
||||||
|
// RepoSlug is "owner/repo", required for API calls.
|
||||||
|
RepoSlug string
|
||||||
|
// BaseBranch is the branch the PR targets (e.g. "main").
|
||||||
|
BaseBranch string
|
||||||
|
// ReleaseBranch is the branch stamp commits to (default: "stamp/release").
|
||||||
|
ReleaseBranch string
|
||||||
|
// SnapshotID is an optional pre-release identifier forwarded to stamp version logic.
|
||||||
|
SnapshotID string
|
||||||
|
// DryRun prints what would happen without pushing or opening a PR.
|
||||||
|
DryRun bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// BumpSummary holds the computed version change for one project.
|
||||||
|
type BumpSummary struct {
|
||||||
|
Name string
|
||||||
|
Current string
|
||||||
|
Next string
|
||||||
|
Bump string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run is the main entry point for `stamp release-pr`.
|
||||||
|
// It versions all pending stamps, commits to the release branch, pushes, and
|
||||||
|
// opens or updates a pull request against the base branch.
|
||||||
|
func Run(ctx context.Context, opts Options) error {
|
||||||
|
cfg, err := config.Load(opts.RepoRoot)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
stampDir := filepath.Join(opts.RepoRoot, cfg.ChangesetDir())
|
||||||
|
|
||||||
|
changesets, err := changeset.ReadAll(stampDir)
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
return fmt.Errorf("reading stamp files: %w", err)
|
||||||
|
}
|
||||||
|
if len(changesets) == 0 {
|
||||||
|
fmt.Println("No pending stamps found — nothing to do.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute version bumps for the PR body before mutating anything.
|
||||||
|
summaries, err := computeSummaries(cfg, changesets, opts.SnapshotID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if opts.DryRun {
|
||||||
|
fmt.Println("[dry-run] Would create/update release PR with:")
|
||||||
|
for _, s := range summaries {
|
||||||
|
fmt.Printf(" %s: %s → %s (%s)\n", s.Name, s.Current, s.Next, s.Bump)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch so we have an up-to-date origin/<base>.
|
||||||
|
fmt.Println("Fetching from origin...")
|
||||||
|
if err := git.FetchOrigin(opts.RepoRoot); err != nil {
|
||||||
|
return fmt.Errorf("fetching origin: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create or reset the release branch from origin/<base> so it is always a
|
||||||
|
// clean, fast-forwardable branch on top of the latest base.
|
||||||
|
base := "origin/" + opts.BaseBranch
|
||||||
|
fmt.Printf("Resetting %s from %s...\n", opts.ReleaseBranch, base)
|
||||||
|
if err := git.CheckoutNewBranch(opts.RepoRoot, opts.ReleaseBranch, base); err != nil {
|
||||||
|
return fmt.Errorf("checking out release branch: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply version changes (same logic as `stamp version --no-commit`).
|
||||||
|
changedFiles, err := applyVersions(opts.RepoRoot, cfg, changesets, opts.SnapshotID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stage and commit.
|
||||||
|
if err := git.Add(opts.RepoRoot, changedFiles...); err != nil {
|
||||||
|
return fmt.Errorf("staging files: %w", err)
|
||||||
|
}
|
||||||
|
commitMsg := buildCommitMessage(summaries)
|
||||||
|
if err := git.Commit(opts.RepoRoot, commitMsg); err != nil {
|
||||||
|
return fmt.Errorf("committing version bump: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push the release branch.
|
||||||
|
fmt.Printf("Pushing %s...\n", opts.ReleaseBranch)
|
||||||
|
if err := git.PushBranch(opts.RepoRoot, opts.ReleaseBranch); err != nil {
|
||||||
|
return fmt.Errorf("pushing release branch: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open or update the PR.
|
||||||
|
title := buildPRTitle(summaries)
|
||||||
|
body := buildPRBody(summaries)
|
||||||
|
|
||||||
|
prNumber, prURL, err := upsertPR(ctx, opts, title, body)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("✓ Release PR #%d ready: %s\n", prNumber, prURL)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// computeSummaries calculates the next version for every project that has pending stamps.
|
||||||
|
func computeSummaries(cfg *config.Config, changesets []*changeset.Changeset, snapshotID string) ([]BumpSummary, error) {
|
||||||
|
projectBumps := semver.ProjectBumps(changesets)
|
||||||
|
var summaries []BumpSummary
|
||||||
|
|
||||||
|
for _, project := range cfg.Projects {
|
||||||
|
bumps := projectBumps[project.Name]
|
||||||
|
if len(bumps) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
highest := semver.HighestBump(bumps)
|
||||||
|
preID := snapshotID
|
||||||
|
if preID == "" {
|
||||||
|
preID = project.PreTag
|
||||||
|
}
|
||||||
|
if preID != "" {
|
||||||
|
highest = semver.PreReleaseBump(project.Version, highest)
|
||||||
|
}
|
||||||
|
|
||||||
|
next, err := semver.Bump(project.Version, highest, preID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("computing next version for %s: %w", project.Name, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
summaries = append(summaries, BumpSummary{
|
||||||
|
Name: project.Name,
|
||||||
|
Current: project.Version,
|
||||||
|
Next: next,
|
||||||
|
Bump: string(highest),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return summaries, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// applyVersions runs the version-bump logic and returns the list of files that were changed.
|
||||||
|
// It mutates cfg.Projects in place (same as cmd_version.go).
|
||||||
|
func applyVersions(repoRoot string, cfg *config.Config, changesets []*changeset.Changeset, snapshotID string) ([]string, error) {
|
||||||
|
projectBumps := semver.ProjectBumps(changesets)
|
||||||
|
now := time.Now()
|
||||||
|
var changedFiles []string
|
||||||
|
|
||||||
|
for i := range cfg.Projects {
|
||||||
|
project := &cfg.Projects[i]
|
||||||
|
bumps := projectBumps[project.Name]
|
||||||
|
if len(bumps) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
highest := semver.HighestBump(bumps)
|
||||||
|
preID := snapshotID
|
||||||
|
if preID == "" {
|
||||||
|
preID = project.PreTag
|
||||||
|
}
|
||||||
|
if preID != "" {
|
||||||
|
highest = semver.PreReleaseBump(project.Version, highest)
|
||||||
|
}
|
||||||
|
|
||||||
|
nextVer, err := semver.Bump(project.Version, highest, preID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("bumping %s: %w", project.Name, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var body string
|
||||||
|
for _, cs := range changesets {
|
||||||
|
if _, ok := cs.Bumps[project.Name]; ok {
|
||||||
|
if cs.Description != "" {
|
||||||
|
body += "- " + cs.Description + "\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clPath := project.ChangelogPath(repoRoot)
|
||||||
|
if err := changelog.Append(clPath, changelog.Entry{
|
||||||
|
Version: nextVer,
|
||||||
|
Date: now,
|
||||||
|
Description: body,
|
||||||
|
}); err != nil {
|
||||||
|
return nil, fmt.Errorf("updating changelog for %s: %w", project.Name, err)
|
||||||
|
}
|
||||||
|
changedFiles = append(changedFiles, clPath)
|
||||||
|
|
||||||
|
fmt.Printf(" %s: %s → %s\n", project.Name, project.Version, nextVer)
|
||||||
|
project.Version = nextVer
|
||||||
|
}
|
||||||
|
|
||||||
|
// Persist updated versions to stamp.toml.
|
||||||
|
if err := config.Save(repoRoot, cfg); err != nil {
|
||||||
|
return nil, fmt.Errorf("saving stamp.toml: %w", err)
|
||||||
|
}
|
||||||
|
changedFiles = append(changedFiles, config.ConfigPath(repoRoot))
|
||||||
|
|
||||||
|
// Delete consumed stamp files.
|
||||||
|
stampDir := filepath.Join(repoRoot, cfg.ChangesetDir())
|
||||||
|
if err := changeset.DeleteAll(stampDir); err != nil {
|
||||||
|
return nil, fmt.Errorf("deleting stamp files: %w", err)
|
||||||
|
}
|
||||||
|
changedFiles = append(changedFiles, stampDir)
|
||||||
|
|
||||||
|
return changedFiles, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildCommitMessage(summaries []BumpSummary) string {
|
||||||
|
msg := "chore: version packages\n\n"
|
||||||
|
for _, s := range summaries {
|
||||||
|
msg += fmt.Sprintf("- %s: %s → %s\n", s.Name, s.Current, s.Next)
|
||||||
|
}
|
||||||
|
return msg
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildPRTitle(summaries []BumpSummary) string {
|
||||||
|
if len(summaries) == 1 {
|
||||||
|
s := summaries[0]
|
||||||
|
return fmt.Sprintf("chore: release %s v%s", s.Name, s.Next)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("chore: release %d packages", len(summaries))
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildPRBody(summaries []BumpSummary) string {
|
||||||
|
body := "## 📦 Pending releases\n\n"
|
||||||
|
body += "This PR was created by `stamp release-pr`. Merge it to apply the version bumps and trigger publishing.\n\n"
|
||||||
|
body += "| Project | Current | Next | Bump |\n"
|
||||||
|
body += "|---------|---------|------|------|\n"
|
||||||
|
for _, s := range summaries {
|
||||||
|
body += fmt.Sprintf("| %s | %s | %s | `%s` |\n", s.Name, s.Current, s.Next, s.Bump)
|
||||||
|
}
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
|
||||||
|
func upsertPR(ctx context.Context, opts Options, title, body string) (int, string, error) {
|
||||||
|
if isGitea() {
|
||||||
|
client, err := giteaClient.NewClient(opts.RepoSlug)
|
||||||
|
if err != nil {
|
||||||
|
return 0, "", err
|
||||||
|
}
|
||||||
|
num, url, err := client.UpsertPR(opts.ReleaseBranch, opts.BaseBranch, title, body)
|
||||||
|
if err != nil {
|
||||||
|
return 0, "", err
|
||||||
|
}
|
||||||
|
return int(num), url, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
client, err := ghClient.NewClient(opts.RepoSlug)
|
||||||
|
if err != nil {
|
||||||
|
return 0, "", err
|
||||||
|
}
|
||||||
|
return client.UpsertPR(ctx, opts.ReleaseBranch, opts.BaseBranch, title, body)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isGitea() bool {
|
||||||
|
return os.Getenv("GITEA_BASE_URL") != ""
|
||||||
|
}
|
||||||
@@ -9,6 +9,25 @@ import (
|
|||||||
"git.thokra.dev/thokra/stamp/internal/changeset"
|
"git.thokra.dev/thokra/stamp/internal/changeset"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// PreReleaseBump converts a regular bump type to its pre-release equivalent,
|
||||||
|
// taking into account whether the current version is already a pre-release.
|
||||||
|
// If it is, the bump is always BumpPreRelease (just increment the pre number).
|
||||||
|
// Otherwise the highest regular bump is promoted to its pre-release variant.
|
||||||
|
func PreReleaseBump(currentVersion string, highest changeset.BumpType) changeset.BumpType {
|
||||||
|
v, err := goSemver.NewVersion(currentVersion)
|
||||||
|
if err == nil && v.Prerelease() != "" {
|
||||||
|
return changeset.BumpPreRelease
|
||||||
|
}
|
||||||
|
switch highest {
|
||||||
|
case changeset.BumpMajor:
|
||||||
|
return changeset.BumpPreMajor
|
||||||
|
case changeset.BumpMinor:
|
||||||
|
return changeset.BumpPreMinor
|
||||||
|
default:
|
||||||
|
return changeset.BumpPrePatch
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// CurrentVersion parses a version string and returns the semver object.
|
// CurrentVersion parses a version string and returns the semver object.
|
||||||
// It is exported so callers can inspect pre-release state without re-importing the semver library.
|
// It is exported so callers can inspect pre-release state without re-importing the semver library.
|
||||||
func CurrentVersion(version string) (*goSemver.Version, error) {
|
func CurrentVersion(version string) (*goSemver.Version, error) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[tools]
|
[tools]
|
||||||
go = "1.26.1"
|
go = "1.27.1"
|
||||||
|
|
||||||
[tasks.build]
|
[tasks.build]
|
||||||
run = "go build -o bin/stamp ./cmd/stamp"
|
run = "go build -o bin/stamp ./cmd/stamp"
|
||||||
@@ -12,3 +12,11 @@ run = "golangci-lint run"
|
|||||||
|
|
||||||
[tasks.install]
|
[tasks.install]
|
||||||
run = "go install ./cmd/stamp"
|
run = "go install ./cmd/stamp"
|
||||||
|
|
||||||
|
[tasks.check]
|
||||||
|
description = "Run formatting, vet, build, and tests (the same checks CI runs)"
|
||||||
|
run = "./scripts/check.sh"
|
||||||
|
|
||||||
|
[tasks.deps]
|
||||||
|
description = "Check go.mod pins against the newest observed module releases"
|
||||||
|
run = "./scripts/check-deps.sh"
|
||||||
Executable
+172
@@ -0,0 +1,172 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# check-deps.sh fails when a module pinned in go.mod is older than the newest
|
||||||
|
# release we can authoritatively observe.
|
||||||
|
#
|
||||||
|
# Two sources are accepted, in order:
|
||||||
|
#
|
||||||
|
# 1. The module proxy. When GOPROXY is not "off", `go list -m -u` is the
|
||||||
|
# authority: it asks the proxy for the newest release of every pinned
|
||||||
|
# module. This is what CI uses.
|
||||||
|
#
|
||||||
|
# 2. The dependency facts prepared by the execution profile and named by
|
||||||
|
# MAINTAINER_DEPENDENCY_FACTS. The file records, for every module, the
|
||||||
|
# newest version that profile observed on proxy.golang.org and when. It is
|
||||||
|
# evidence rather than a live query, so the script prints its source and
|
||||||
|
# observation time and refuses to use reports it cannot validate as complete.
|
||||||
|
#
|
||||||
|
# The local module cache is never consulted: it only contains versions that
|
||||||
|
# happened to be downloaded, so it cannot establish what the newest release is.
|
||||||
|
# When neither source is available the script exits with status 2 instead of
|
||||||
|
# reporting success.
|
||||||
|
#
|
||||||
|
# Exit status: 0 = every pin is current, 1 = a pin is stale (or unverifiable
|
||||||
|
# for an individual module), 2 = freshness could not be established at all.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
root="${CHECK_DEPS_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
|
||||||
|
cd "$root"
|
||||||
|
|
||||||
|
facts_file="${MAINTAINER_DEPENDENCY_FACTS:-}"
|
||||||
|
|
||||||
|
# requirements prints "<path> <version>" for every module required by go.mod.
|
||||||
|
requirements() {
|
||||||
|
go mod edit -json | awk -F'"' '
|
||||||
|
/^\t"Require": \[/ { in_require = 1 }
|
||||||
|
in_require && /^\t\],?$/ { in_require = 0 }
|
||||||
|
in_require && /"Path":/ { path = $4 }
|
||||||
|
in_require && /"Version":/ { print path, $4 }
|
||||||
|
'
|
||||||
|
}
|
||||||
|
|
||||||
|
# behind reports whether version $1 is older than version $2.
|
||||||
|
behind() {
|
||||||
|
[ "$1" != "$2" ] && [ "$(printf '%s\n%s\n' "$1" "$2" | sort -V | tail -n 1)" = "$2" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
pins="$(requirements)"
|
||||||
|
if [ -z "$pins" ]; then
|
||||||
|
echo 'go.mod requires no modules' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
count="$(printf '%s\n' "$pins" | wc -l | tr -d ' ')"
|
||||||
|
|
||||||
|
if [ "$(go env GOPROXY)" != "off" ]; then
|
||||||
|
mods=()
|
||||||
|
while read -r path version; do
|
||||||
|
mods+=("$path@$version")
|
||||||
|
done <<<"$pins"
|
||||||
|
|
||||||
|
if ! listing="$(go list -m -u -f '{{.Path}} {{.Version}} {{if .Update}}{{.Update.Version}}{{end}}' "${mods[@]}")"; then
|
||||||
|
echo 'could not query the module proxy for newer versions' >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
updates="$(printf '%s\n' "$listing" | awk 'NF == 3')"
|
||||||
|
if [ -n "$updates" ]; then
|
||||||
|
echo 'These modules have newer versions available:' >&2
|
||||||
|
printf '%s\n' "$updates" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "ok: $count go.mod requirements are up to date (module proxy)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Offline: fall back to the dependency facts prepared by the execution profile.
|
||||||
|
# The facts file is refreshed by the execution profile, so a reader can race
|
||||||
|
# with an atomic rewrite; give it a moment before declaring the facts missing.
|
||||||
|
if [ -n "$facts_file" ]; then
|
||||||
|
for _ in 1 2 3 4 5 6 7 8 9 10; do
|
||||||
|
[ -r "$facts_file" ] && break
|
||||||
|
sleep 0.2
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if [ -z "$facts_file" ] || [ ! -r "$facts_file" ]; then
|
||||||
|
echo 'cannot verify dependency freshness: the module proxy is disabled (GOPROXY=off)' \
|
||||||
|
'and MAINTAINER_DEPENDENCY_FACTS does not name a readable dependency-facts file' >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
field() {
|
||||||
|
grep -o "\"$1\"[[:space:]]*:[[:space:]]*\"[^\"]*\"" "$facts_file" | head -n 1 | sed 's/.*:[[:space:]]*"\(.*\)"/\1/'
|
||||||
|
}
|
||||||
|
|
||||||
|
schema="$(grep -o '"schema_version"[[:space:]]*:[[:space:]]*[0-9]*' "$facts_file" | head -n 1 | grep -o '[0-9]*$' || true)"
|
||||||
|
source="$(field source)"
|
||||||
|
freshness="$(field freshness_status)"
|
||||||
|
scope="$(field query_scope)"
|
||||||
|
observed_at="$(field observed_at)"
|
||||||
|
digest="$(field manifest_digest)"
|
||||||
|
|
||||||
|
if [ "$schema" != 1 ]; then
|
||||||
|
echo "cannot verify dependency freshness: unsupported dependency-facts schema (${schema:-missing})" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
if [ "$source" != 'https://proxy.golang.org' ]; then
|
||||||
|
echo "cannot verify dependency freshness: unexpected dependency-facts source '${source}'" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
if [ "$freshness" != 'available' ]; then
|
||||||
|
echo "cannot verify dependency freshness: dependency facts are not marked available ('${freshness}')" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
if [ "$scope" != 'module_path_latest' ]; then
|
||||||
|
echo "cannot verify dependency freshness: dependency facts use query scope '${scope}', want module_path_latest" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
if [ -z "$observed_at" ]; then
|
||||||
|
echo 'cannot verify dependency freshness: dependency facts have no observation time' >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# One record per observed module: name, latest version and item status.
|
||||||
|
records="$(grep -o '{[^{}]*"latest"[^{}]*' "$facts_file" || true)"
|
||||||
|
if [ -z "$records" ]; then
|
||||||
|
echo 'cannot verify dependency freshness: dependency facts contain no module observations' >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
latest_for() {
|
||||||
|
local want="$1" record name latest status
|
||||||
|
while IFS= read -r record; do
|
||||||
|
name="$(printf '%s\n' "$record" | sed -n 's/.*"name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p')"
|
||||||
|
[ "$name" = "$want" ] || continue
|
||||||
|
latest="$(printf '%s\n' "$record" | sed -n 's/.*"latest"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p')"
|
||||||
|
status="$(printf '%s\n' "$record" | sed -n 's/.*"status"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p')"
|
||||||
|
[ "$status" = 'observed' ] || return 1
|
||||||
|
printf '%s\n' "$latest"
|
||||||
|
return 0
|
||||||
|
done <<<"$records"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
stale=''
|
||||||
|
unverified=''
|
||||||
|
while read -r path version; do
|
||||||
|
if ! latest="$(latest_for "$path")"; then
|
||||||
|
unverified+=" $path $version (not covered by the dependency facts)"$'\n'
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if behind "$version" "$latest"; then
|
||||||
|
stale+=" $path $version (latest observed: $latest)"$'\n'
|
||||||
|
elif [ "$version" != "$latest" ]; then
|
||||||
|
unverified+=" $path $version (pin is newer than the latest observation $latest)"$'\n'
|
||||||
|
fi
|
||||||
|
done <<<"$pins"
|
||||||
|
|
||||||
|
if [ -n "$stale" ]; then
|
||||||
|
echo 'These go.mod pins are behind the latest observed releases:' >&2
|
||||||
|
printf '%s' "$stale" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -n "$unverified" ]; then
|
||||||
|
echo 'These go.mod pins could not be checked against the dependency facts:' >&2
|
||||||
|
printf '%s' "$unverified" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "ok: $count go.mod requirements match the latest releases observed by the execution profile"
|
||||||
|
echo "source: $source, observed at $observed_at (module_path_latest)"
|
||||||
|
if [ -n "$digest" ]; then
|
||||||
|
echo "note: dependency-facts manifest digest: $digest"
|
||||||
|
fi
|
||||||
Executable
+35
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# check.sh runs every verification step required before a change can land.
|
||||||
|
# `.gitea/workflows/ci.yml` invokes it on every pull request and every push to
|
||||||
|
# main, so this script is the single source of truth for what "CI passed" means.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||||
|
|
||||||
|
echo '==> ci workflow'
|
||||||
|
./scripts/test-ci-workflow.sh
|
||||||
|
|
||||||
|
echo '==> dependency check tests'
|
||||||
|
./scripts/test-check-deps.sh
|
||||||
|
|
||||||
|
echo '==> gofmt'
|
||||||
|
unformatted="$(gofmt -l .)"
|
||||||
|
if [ -n "$unformatted" ]; then
|
||||||
|
echo 'These files are not gofmt-formatted:' >&2
|
||||||
|
printf '%s\n' "$unformatted" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo '==> go mod verify'
|
||||||
|
go mod verify
|
||||||
|
|
||||||
|
echo '==> go vet'
|
||||||
|
go vet ./...
|
||||||
|
|
||||||
|
echo '==> go build'
|
||||||
|
go build ./...
|
||||||
|
|
||||||
|
echo '==> go test'
|
||||||
|
go test -cover ./...
|
||||||
Executable
+104
@@ -0,0 +1,104 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# test-check-deps.sh exercises scripts/check-deps.sh without a module proxy or
|
||||||
|
# network access. It builds throwaway manifests in a temporary directory and
|
||||||
|
# asserts the script's exit status and diagnostics.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
script="$here/check-deps.sh"
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$tmp"' EXIT
|
||||||
|
|
||||||
|
failures=0
|
||||||
|
expect_status() {
|
||||||
|
local want="$1" got
|
||||||
|
shift
|
||||||
|
set +e
|
||||||
|
"$@" >"$tmp/out" 2>&1
|
||||||
|
got=$?
|
||||||
|
set -e
|
||||||
|
if [ "$got" -ne "$want" ]; then
|
||||||
|
echo "FAIL: expected exit $want, got $got: $*" >&2
|
||||||
|
cat "$tmp/out" >&2
|
||||||
|
failures=$((failures + 1))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# fixture sets up $tmp/repo/go.mod and prints the go.mod path.
|
||||||
|
fixture() {
|
||||||
|
mkdir -p "$tmp/repo"
|
||||||
|
cat >"$tmp/repo/go.mod" <<'EOF'
|
||||||
|
module example.com/fixture
|
||||||
|
|
||||||
|
go 1.27.1
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/a/b v1.0.0
|
||||||
|
github.com/c/d v1.3.0
|
||||||
|
)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# facts writes a dependency-facts document to $tmp/facts.json.
|
||||||
|
# Arguments: <freshness_status> <item-json...>
|
||||||
|
facts() {
|
||||||
|
local freshness="$1"
|
||||||
|
shift
|
||||||
|
local items=''
|
||||||
|
local item
|
||||||
|
for item in "$@"; do
|
||||||
|
[ -z "$items" ] || items+=','
|
||||||
|
items+="$item"
|
||||||
|
done
|
||||||
|
cat >"$tmp/facts.json" <<EOF
|
||||||
|
{"schema_version":1,"observations":[{"ecosystem":"go","source":"https://proxy.golang.org","observed_at":"2026-10-28T09:00:00Z","manifest_digest":"abc123","command":["go","list","-m","-e","-json"],"items":[$items],"metadata":{"checksum_database":"sum.golang.org","freshness_status":"$freshness","graph_command":"go list -m -json all","query_scope":"module_path_latest"}}]}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
up_to_date='{"name":"github.com/a/b","current":"v1.0.0","latest":"v1.0.0","status":"observed"},{"name":"github.com/c/d","current":"v1.3.0","latest":"v1.3.0","status":"observed"}'
|
||||||
|
|
||||||
|
# 1. Every pin matches the latest observation.
|
||||||
|
fixture
|
||||||
|
facts available "$up_to_date"
|
||||||
|
expect_status 0 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/facts.json" GOPROXY=off "$script"
|
||||||
|
grep -q 'ok: 2 go.mod requirements' "$tmp/out" || { echo 'FAIL: missing success summary' >&2; failures=$((failures + 1)); }
|
||||||
|
|
||||||
|
# 2. A stale pin is reported and fails.
|
||||||
|
fixture
|
||||||
|
facts available '{"name":"github.com/a/b","current":"v1.0.0","latest":"v1.2.0","status":"observed"},{"name":"github.com/c/d","current":"v1.3.0","latest":"v1.3.0","status":"observed"}'
|
||||||
|
expect_status 1 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/facts.json" GOPROXY=off "$script"
|
||||||
|
grep -q 'github.com/a/b v1.0.0 (latest observed: v1.2.0)' "$tmp/out" || { echo 'FAIL: stale module not named' >&2; failures=$((failures + 1)); }
|
||||||
|
|
||||||
|
# 3. A pin that is newer than the observation cannot be verified.
|
||||||
|
fixture
|
||||||
|
facts available '{"name":"github.com/a/b","current":"v1.0.0","latest":"v1.0.0","status":"observed"}'
|
||||||
|
expect_status 1 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/facts.json" GOPROXY=off "$script"
|
||||||
|
grep -q 'not covered by the dependency facts' "$tmp/out" || { echo 'FAIL: uncovered module not reported' >&2; failures=$((failures + 1)); }
|
||||||
|
|
||||||
|
# 4. Without a proxy and without facts nothing is verified.
|
||||||
|
fixture
|
||||||
|
expect_status 2 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/missing.json" GOPROXY=off "$script"
|
||||||
|
grep -q 'cannot verify dependency freshness' "$tmp/out" || { echo 'FAIL: unverified run did not explain itself' >&2; failures=$((failures + 1)); }
|
||||||
|
|
||||||
|
# 5. Incomplete dependency facts are not trusted.
|
||||||
|
fixture
|
||||||
|
facts unavailable "$up_to_date"
|
||||||
|
expect_status 2 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/facts.json" GOPROXY=off "$script"
|
||||||
|
|
||||||
|
# 6. Items that were not observed are not treated as current.
|
||||||
|
fixture
|
||||||
|
facts available '{"name":"github.com/a/b","current":"v1.0.0","latest":"v1.0.0","status":"not_found"},{"name":"github.com/c/d","current":"v1.3.0","latest":"v1.3.0","status":"observed"}'
|
||||||
|
expect_status 1 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/facts.json" GOPROXY=off "$script"
|
||||||
|
|
||||||
|
# 7. A facts document from a different source is rejected.
|
||||||
|
fixture
|
||||||
|
sed 's#https://proxy.golang.org#https://example.invalid#' "$tmp/facts.json" >"$tmp/other.json"
|
||||||
|
expect_status 2 env CHECK_DEPS_ROOT="$tmp/repo" MAINTAINER_DEPENDENCY_FACTS="$tmp/other.json" GOPROXY=off "$script"
|
||||||
|
|
||||||
|
if [ "$failures" -ne 0 ]; then
|
||||||
|
echo "$failures check-deps test(s) failed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo 'ok: check-deps.sh behaviour is covered'
|
||||||
Executable
+44
@@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# test-ci-workflow.sh checks the properties of .gitea/workflows/ci.yml that
|
||||||
|
# gate pull requests. It runs without Go modules so CI configuration can be
|
||||||
|
# validated even when the module proxy is unavailable; the equivalent Go test
|
||||||
|
# in internal/ci/workflow_test.go parses the same file as YAML.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
workflow="$root/.gitea/workflows/ci.yml"
|
||||||
|
|
||||||
|
if [ ! -f "$workflow" ]; then
|
||||||
|
echo "missing workflow: $workflow" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
failures=0
|
||||||
|
require_line() {
|
||||||
|
if ! grep -qF "$1" "$workflow"; then
|
||||||
|
echo "workflow is missing: $1" >&2
|
||||||
|
failures=$((failures + 1))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
require_line 'on:'
|
||||||
|
require_line ' pull_request:'
|
||||||
|
require_line ' push:'
|
||||||
|
require_line 'branches: [main]'
|
||||||
|
require_line 'run: ./scripts/check.sh'
|
||||||
|
require_line 'run: ./scripts/check-deps.sh'
|
||||||
|
require_line 'go-version-file: go.mod'
|
||||||
|
|
||||||
|
# The workflow must be a single action so "all checks passed" has one meaning.
|
||||||
|
jobs="$(awk '/^jobs:/{j=1;next} j && /^ [a-z0-9_-]+:$/{n++} END{print n+0}' "$workflow")"
|
||||||
|
if [ "$jobs" -ne 1 ]; then
|
||||||
|
echo "workflow must define exactly one job, found $jobs" >&2
|
||||||
|
failures=$((failures + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$failures" -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo 'ok: the pull request workflow runs the repository checks'
|
||||||
Reference in new issue
Block a user