Skip to content

Commit d89a830

Browse files
committed
Add GitHub release management and self-upgrade commands
1 parent 6919352 commit d89a830

7 files changed

Lines changed: 1030 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ uuid = { version = "1", features = ["v4"] }
4444
tempfile = "3"
4545
ctrlc = "3.4"
4646
rpassword = "7"
47+
atty = "0.2"
48+
49+
[target.'cfg(unix)'.dependencies]
50+
libc = "0.2"
4751

4852
[dev-dependencies]
4953
mockito = "1.7"

src/cli.rs

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,17 @@ pub enum Commands {
290290
long_about = "AI-maintained documentation that stays in sync with the codebase. Docs are stored in .ai/docs/ and can be updated based on recent commits."
291291
)]
292292
Docs(DocsCommand),
293+
#[command(
294+
about = "Upgrade flow to the latest version.",
295+
long_about = "Download and install the latest version of flow from GitHub releases. Checks for newer versions and replaces the current executable."
296+
)]
297+
Upgrade(UpgradeOpts),
298+
#[command(
299+
about = "Manage GitHub releases.",
300+
long_about = "Create, list, and manage GitHub releases. Supports uploading release assets (binaries, tarballs) and generating release notes.",
301+
alias = "rel"
302+
)]
303+
Release(GhReleaseCommand),
293304
}
294305

295306
#[derive(Args, Debug, Clone)]
@@ -1655,6 +1666,92 @@ pub struct DocsCommand {
16551666
pub action: Option<DocsAction>,
16561667
}
16571668

1669+
#[derive(Args, Debug, Clone)]
1670+
pub struct UpgradeOpts {
1671+
/// Upgrade to a specific version (e.g., "0.2.0" or "v0.2.0").
1672+
#[arg(value_name = "VERSION")]
1673+
pub version: Option<String>,
1674+
/// Print what would happen without making changes.
1675+
#[arg(long, short = 'n')]
1676+
pub dry_run: bool,
1677+
/// Force upgrade even if already on the latest version.
1678+
#[arg(long, short)]
1679+
pub force: bool,
1680+
/// Download to a specific path instead of replacing the current executable.
1681+
#[arg(long, short)]
1682+
pub output: Option<String>,
1683+
}
1684+
1685+
#[derive(Args, Debug, Clone)]
1686+
pub struct GhReleaseCommand {
1687+
#[command(subcommand)]
1688+
pub action: Option<GhReleaseAction>,
1689+
}
1690+
1691+
#[derive(Subcommand, Debug, Clone)]
1692+
pub enum GhReleaseAction {
1693+
/// Create a new GitHub release.
1694+
Create(GhReleaseCreateOpts),
1695+
/// List recent releases.
1696+
#[command(alias = "ls")]
1697+
List {
1698+
/// Number of releases to show.
1699+
#[arg(short, long, default_value = "10")]
1700+
limit: usize,
1701+
},
1702+
/// Delete a release.
1703+
Delete {
1704+
/// Release tag to delete.
1705+
tag: String,
1706+
/// Skip confirmation.
1707+
#[arg(short, long)]
1708+
yes: bool,
1709+
},
1710+
/// Download release assets.
1711+
Download {
1712+
/// Release tag (defaults to latest).
1713+
#[arg(short, long)]
1714+
tag: Option<String>,
1715+
/// Output directory.
1716+
#[arg(short, long, default_value = ".")]
1717+
output: String,
1718+
},
1719+
}
1720+
1721+
#[derive(Args, Debug, Clone)]
1722+
pub struct GhReleaseCreateOpts {
1723+
/// Version tag (e.g., "v0.1.0"). Auto-detected from Cargo.toml if not provided.
1724+
#[arg(value_name = "TAG")]
1725+
pub tag: Option<String>,
1726+
/// Release title (defaults to tag name).
1727+
#[arg(short, long)]
1728+
pub title: Option<String>,
1729+
/// Release notes (reads from stdin or file if not provided).
1730+
#[arg(short, long)]
1731+
pub notes: Option<String>,
1732+
/// Read release notes from a file.
1733+
#[arg(long)]
1734+
pub notes_file: Option<String>,
1735+
/// Generate release notes automatically from commits.
1736+
#[arg(long)]
1737+
pub generate_notes: bool,
1738+
/// Create as draft release.
1739+
#[arg(long)]
1740+
pub draft: bool,
1741+
/// Mark as prerelease.
1742+
#[arg(long)]
1743+
pub prerelease: bool,
1744+
/// Asset files to upload (can be specified multiple times).
1745+
#[arg(short, long, value_name = "FILE")]
1746+
pub asset: Vec<String>,
1747+
/// Target commit/branch for the release tag.
1748+
#[arg(long)]
1749+
pub target: Option<String>,
1750+
/// Skip confirmation prompts.
1751+
#[arg(short, long)]
1752+
pub yes: bool,
1753+
}
1754+
16581755
#[derive(Subcommand, Debug, Clone)]
16591756
pub enum DocsAction {
16601757
/// Sync documentation with recent commits.

0 commit comments

Comments
 (0)