mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
## Summary Removes the GitHub Actions-driven releaser **v2** pipeline so the interactive release wizard is the only release path, and drops the `v1` naming now that it is the sole implementation. ## Changes - Delete `.github/workflows/tag-and-release.yaml` (the v2 workflow). - Delete `scripts/releaser/v2/`. - Move `scripts/releaser/v1/` into `scripts/releaser/` as `package main`. - Rewrite `scripts/releaser/main.go` to a single wizard command: drop the `--legacy` flag and the v2 `rc`/`branch`/`release` subcommands and hidden CI compat commands. `--dry-run` is preserved. - Update `scripts/release.sh` to run `go run ./scripts/releaser "$@"` (no `--legacy`). The legacy `release.yaml` workflow (triggered by `scripts/release.sh`) is unchanged and remains the release pipeline. ## Validation - `go build ./scripts/releaser/...` - `go test ./scripts/releaser/...` - `go vet` + `golangci-lint run ./scripts/releaser/...` - `gofmt -l` clean > [!NOTE] > The GPG signing key check removal is handled in a stacked follow-up PR based on this branch. <details> <summary>Implementation plan</summary> - v2 flow = `scripts/releaser/v2/` + `.github/workflows/tag-and-release.yaml` (uses `go run ./scripts/releaser prepare-release|generate-notes`). `v2` was imported only by `main.go`; the workflow was referenced nowhere else. - v1 flow = interactive wizard in `scripts/releaser/v1/`, reached via `--legacy`, driving `release.yaml` (triggered by `scripts/release.sh`). - No `docs/` referenced the releaser tool or these workflows. - Steps: delete the v2 workflow and package; move `v1/*` up to `scripts/releaser/` (`package main`, including test files); rewrite `main.go` to a single wizard command; update `release.sh`. </details> --- Generated by Coder Agents on behalf of @f0ssel.
81 lines
2.3 KiB
Go
81 lines
2.3 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
|
|
"golang.org/x/xerrors"
|
|
)
|
|
|
|
// ReleaseExecutor handles dangerous write/mutating operations
|
|
// that should be skipped in dry-run mode. Only actions that
|
|
// modify the git repo or trigger external side effects belong
|
|
// here. Safe operations (file writes, fetches, editor) are
|
|
// called directly.
|
|
type ReleaseExecutor interface {
|
|
// CreateTag creates an annotated git tag.
|
|
CreateTag(ctx context.Context, tag, ref, message string) error
|
|
// PushTag pushes a tag to the origin remote.
|
|
PushTag(ctx context.Context, tag string) error
|
|
// TriggerWorkflow dispatches the release.yaml GitHub Actions
|
|
// workflow with the given inputs.
|
|
TriggerWorkflow(ctx context.Context, ref, channel, releaseNotes string) error
|
|
}
|
|
|
|
// liveExecutor performs real operations.
|
|
type liveExecutor struct{}
|
|
|
|
func (*liveExecutor) CreateTag(_ context.Context, tag, ref, message string) error {
|
|
return gitRun("tag", "-a", tag, "-m", message, ref)
|
|
}
|
|
|
|
func (*liveExecutor) PushTag(_ context.Context, tag string) error {
|
|
return gitRun("push", "origin", tag)
|
|
}
|
|
|
|
func (*liveExecutor) TriggerWorkflow(_ context.Context, ref, channel, releaseNotes string) error {
|
|
payload := map[string]string{
|
|
"dry_run": "false",
|
|
"release_channel": channel,
|
|
"release_notes": releaseNotes,
|
|
}
|
|
payloadJSON, err := json.Marshal(payload)
|
|
if err != nil {
|
|
return xerrors.Errorf("marshaling workflow payload: %w", err)
|
|
}
|
|
cmd := exec.Command("gh", "workflow", "run", "release.yaml",
|
|
"--repo", owner+"/"+repo,
|
|
"--ref", ref,
|
|
"--json",
|
|
)
|
|
cmd.Stdin = strings.NewReader(string(payloadJSON))
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
return cmd.Run()
|
|
}
|
|
|
|
// dryRunExecutor prints what would happen without doing it.
|
|
type dryRunExecutor struct {
|
|
w io.Writer
|
|
}
|
|
|
|
func (e *dryRunExecutor) CreateTag(_ context.Context, tag, ref, message string) error {
|
|
_, _ = fmt.Fprintf(e.w, "[DRYRUN] would run: git tag -a %s -m %q %s\n", tag, message, ref)
|
|
return nil
|
|
}
|
|
|
|
func (e *dryRunExecutor) PushTag(_ context.Context, tag string) error {
|
|
_, _ = fmt.Fprintf(e.w, "[DRYRUN] would run: git push origin %s\n", tag)
|
|
return nil
|
|
}
|
|
|
|
func (e *dryRunExecutor) TriggerWorkflow(_ context.Context, ref, channel, _ string) error {
|
|
_, _ = fmt.Fprintf(e.w, "[DRYRUN] would trigger release.yaml workflow (ref=%s, channel=%s)\n", ref, channel)
|
|
return nil
|
|
}
|