Skip to content

scripts: rewrite installer for versioned releases - #49

Merged
somanshreddy merged 5 commits into
mainfrom
04-06-scripts_rewrite_installer_for_versioned_releases
Apr 6, 2026
Merged

somanshreddy merged 5 commits into
mainfrom
04-06-scripts_rewrite_installer_for_versioned_releases

Conversation

@somanshreddy

@somanshreddy somanshreddy commented Apr 6, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Replaces the dev-phase installer and release workflow with a versioned release cycle. Three changes:

1. Dev release workflow rewrite (.github/workflows/dev-release.yml):
The old workflow used a rolling dev tag with unversioned assets (heygen_linux_amd64.tar.gz) and version="dev-<sha>". The new workflow auto-computes a semver-compliant tag from the latest stable release: bumps patch, appends -dev.YYYYMMDD.SHORTHASH (e.g., v0.1.1-dev.20260406.abc1234). Creates an immutable git tag and delegates to GoReleaser for versioned asset names, checksums, and prerelease publishing. Each dev build is a separate prerelease, not a rolling overwrite.

Version derivation: reads latest stable tag via git tag --list, bumps patch (v0.1.0 → v0.1.1), appends dev metadata. If no stable tag exists, starts from v0.0.1-dev.*.

2. Install script rewrite (scripts/install.sh):
The old installer defaulted to the dev tag and required GITHUB_TOKEN. The new installer:

  • Defaults to latest stable release (not dev)
  • --dev flag installs latest dev prerelease
  • --version v0.1.0 pins to a specific version (v prefix required)
  • Falls back to unauthenticated GitHub API when no token is available (ready for public repo)
  • Uses versioned GoReleaser asset names (heygen_v0.1.0_linux_amd64.tar.gz)
  • --help flag for discoverability
  • --dev and --version are mutually exclusive

3. GoReleaser asset naming (.goreleaser.yaml):
Archive name template changed from {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }} to {{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }} — includes the v prefix in the filename for consistency with the tag format.

README, RELEASE.md, and SKILL.md updated to reflect the new install commands and versioning scheme.

Stacked on PR #23 (stable release workflow).

Testing

Install script tested manually with --help, --dev, --version, and default (stable) modes. Dev release workflow validated by reading the computed version step output. GoReleaser config validated via make goreleaser-check.

somanshreddy commented Apr 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

@somanshreddy
somanshreddy marked this pull request as ready for review April 6, 2026 20:09
@somanshreddy
somanshreddy requested a review from jrusso1020 April 6, 2026 20:26
Comment thread SKILL.md Resolved
@somanshreddy
somanshreddy force-pushed the 04-06-scripts_rewrite_installer_for_versioned_releases branch from b375061 to 5066125 Compare April 6, 2026 23:28
@somanshreddy
somanshreddy force-pushed the 04-01-ci_add_release_workflow_for_goreleaser_on_tag_push branch from ce452f9 to 182a6a1 Compare April 6, 2026 23:28
somanshreddy added a commit that referenced this pull request Apr 6, 2026
## Description

Adds a `.gitleaks.toml` allowlist so the PostHog project API token in `internal/analytics/analytics.go` doesn't fail the secrets CI check.

PostHog project tokens are public client-side ingest tokens by design — they're embedded in every frontend and CLI that uses PostHog. This is not a secret leak. The allowlist is scoped narrowly: only matches the exact `const posthogAPIKey = "phc_..."` assignment in that one file.

Without this, the `secrets` CI job fails on PRs #23, #49, and #50 (the entire M6 stack).

## Testing

CI `secrets` job should pass after this merges. Verified the allowlist regex matches the token assignment pattern.
@somanshreddy
somanshreddy changed the base branch from 04-01-ci_add_release_workflow_for_goreleaser_on_tag_push to graphite-base/49 April 6, 2026 23:42
somanshreddy added a commit that referenced this pull request Apr 6, 2026
## Description

Adds a manual GitHub Actions workflow for cutting stable releases. This is the first PR in the M6 release cycle stack (#23 → #49 → #50).

### Versioning Strategy

The CLI uses semver with a `v` prefix everywhere — git tags, `--version` output, `--version` flag input, JSON responses, install script.

| Build type | Tag format | Example | How triggered |
|---|---|---|---|
| **Stable** | `v{major}.{minor}.{patch}` | `v0.1.0` | Manual — GitHub Actions UI, operator inputs version |
| **Dev** | `v{base}-dev.{YYYYMMDD}.{shorthash}` | `v0.1.1-dev.20260406.abc1234` | Manual — GitHub Actions UI, version auto-computed |
| **Local** | — | `dev` | `go build` without ldflags |

**Semver ordering:** `v0.2.0` > `v0.1.1-dev.20260407.def` > `v0.1.1-dev.20260406.abc` > `v0.1.0`. Stable always beats prerelease. Dev builds sort chronologically by date.

**Dev version auto-derivation (PR #49):** The dev workflow reads the latest stable tag, bumps patch (`v0.1.0` → `v0.1.1`), and appends `-dev.YYYYMMDD.SHORTHASH`. No VERSION file, no manual bumps. Dev builds always sort above the latest stable.

**Bumping rules:** Pre-1.0 (`v0.x.y`): minor = features, patch = fixes, no stability guarantees. Post-1.0: full semver contract.

### This PR — Stable Release Workflow

**Trigger:** GitHub Actions UI → "Stable Release" → input version tag (e.g., `v0.1.0`) → "Run workflow"

**What it does:**
1. Validates version is semver format (`v0.1.0` — rejects `1.0` or `foo`)
2. Validates the tag doesn't already exist (prevents accidental overwrite)
3. Runs tests
4. Creates git tag on current `main` HEAD
5. GoReleaser builds platform binaries + `checksums.txt`, publishes as a stable GitHub release

**Downstream PRs:**
- PR #49 — rewrites dev release workflow + installer for versioned assets
- PR #50 — adds `heygen update` / `heygen update check` commands (channel-aware: stable users get stable updates, dev users get dev updates)

## Testing

Workflow syntax validated. GoReleaser config tested by `goreleaser-check` CI job. Version validation tested manually with valid/invalid inputs.
somanshreddy and others added 4 commits April 6, 2026 23:43
Add format table, semver ordering examples, dev version auto-derivation
explanation, bumping rules, and update channel detection.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Set HEYGEN_CONFIG_DIR to an empty temp dir in runCommand() so
FileCredentialResolver doesn't pick up real credentials from
~/.heygen/credentials on dev machines. Skips the override if the
test already set HEYGEN_CONFIG_DIR (e.g., config tests that write
a config file to a specific dir).

Fixes TestVideoDownload_AuthRequired and TestVideoList_AuthMissing
which failed on machines with stored credentials.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
SKILL.md is agent-facing — agents should install the stable release,
not dev builds. Dev install instructions stay in README.md and RELEASE.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@somanshreddy
somanshreddy force-pushed the 04-06-scripts_rewrite_installer_for_versioned_releases branch from 5066125 to a7c9b3f Compare April 6, 2026 23:43
@graphite-app
graphite-app Bot changed the base branch from graphite-base/49 to main April 6, 2026 23:43
Remove exit codes, flag details, pagination, and --output-path notes —
all derivable from --help. Keep: install, auth, async workflow pattern,
output contract, schema discovery, and key gotchas.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@somanshreddy
somanshreddy force-pushed the 04-06-scripts_rewrite_installer_for_versioned_releases branch from a7c9b3f to dd325d3 Compare April 6, 2026 23:43

somanshreddy commented Apr 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

Merge activity

  • Apr 6, 11:53 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 6, 11:54 PM UTC: @somanshreddy merged this pull request with Graphite.

@somanshreddy
somanshreddy merged commit b8981b7 into main Apr 6, 2026
9 checks passed
@somanshreddy
somanshreddy deleted the 04-06-scripts_rewrite_installer_for_versioned_releases branch April 6, 2026 23:54
somanshreddy added a commit that referenced this pull request Apr 7, 2026
## Description

Adds `heygen update` and `heygen update check` — explicit self-update commands for the CLI. No auto-update, no startup notifications, no network calls in `--help` or `--version`.

**`heygen update check`** — queries GitHub Releases for the latest stable version, returns JSON:
```json
{"current": "v0.1.0", "latest": "v0.2.0", "update_available": true}
```

**`heygen update`** — downloads the latest stable release, verifies SHA256 checksum, replaces the binary. Returns JSON:
```json
{"previous": "v0.1.0", "current": "v0.2.0", "message": "Updated heygen from v0.1.0 to v0.2.0"}
```

**`heygen update --version v0.1.0`** — pins to a specific version. The `v` prefix is required; bare `0.1.0` returns exit 2 (usage error).

**Design decisions:**
- `skipAuth: true` — no HeyGen API key needed. GitHub Releases are the source.
- GitHub token sourced from `GITHUB_TOKEN` → `GH_TOKEN` → `gh auth token` (same chain as the installer). Empty token works once the repo is public.
- Package manager detection: if binary is under `/homebrew/`, `/Cellar/`, `/linuxbrew/`, or `node_modules/`, returns a `CLIError` telling the user to use their package manager instead.
- Local `dev` builds (no ldflags) get a clear error: "reinstall from a release build to use heygen update."
- `releaseUpdater` interface abstracts `go-selfupdate` for testability. All tests use a mock — no real GitHub API calls.
- Static hint in root `--help`: `Use "heygen update check" to see if a newer version is available.` No dynamic notifications.
- `version` field added to `cmdContext` to pass the build-time version string to the update command.

**Dependencies added:** `creativeprojects/go-selfupdate` (GitHub Releases source, checksum validation, atomic binary replacement, rollback on failure) and `Masterminds/semver` (version parsing and validation).

Stacked on PR #49 (installer rewrite).

## Testing

7 tests with mock `releaseUpdater`:
- `TestUpdateCheck_NewVersionAvailable` — newer version returns `update_available: true`
- `TestUpdateCheck_AlreadyCurrent` — same version returns `update_available: false`
- `TestUpdateCheck_LocalDevVersion` — `dev` build returns exit 1 with "not release-tagged" error
- `TestUpdate_SkipsAuth` — no API key needed, exit 0
- `TestUpdate_PackageManagerWarning` — Homebrew path returns `wrong_install_method` error with brew hint
- `TestUpdate_JSONOutput` — success returns valid JSON with previous/current/message
- `TestUpdate_RejectsBareVersion` — `--version 0.1.0` (no `v`) returns exit 2

Root help test updated to verify the static update hint line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants