Skip to content

Commit c8ff06e

Browse files
igorcostaAutohand Evolve
andcommitted
Derive alpha releases from stable tags
Use the latest non-prerelease Git tag as the alpha base version before falling back to package.json so alpha builds advance beyond stale package metadata. Co-authored-by: Autohand Evolve <code-noreply@autohand.ai>
1 parent 14969df commit c8ff06e

3 files changed

Lines changed: 37 additions & 24 deletions

File tree

.github/workflows/README.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@ This directory contains automated CI/CD workflows for the Autohand CLI project.
77
### 🚀 Release (`release.yml`)
88

99
**Triggers:**
10-
- Push to `main` (stable release)
11-
- Push to `beta` (beta release)
12-
- Push to `alpha` (alpha release)
10+
- Push to `main` (alpha release)
1311
- Manual workflow dispatch
1412

1513
**What it does:**
16-
1. **Determines version** based on conventional commits
17-
- `feat:` → MINOR bump (0.1.0 → 0.2.0)
18-
- `fix:` → PATCH bump (0.1.0 → 0.1.1)
19-
- `feat!:` or `BREAKING CHANGE:` → MAJOR bump (0.1.0 → 1.0.0)
14+
1. **Determines version** based on the selected release channel
15+
- Alpha bumps the patch from the latest stable tag and appends the short SHA
16+
- Stable releases use the current `package.json` version unless manually overridden
2017

2118
2. **Builds binaries** for all platforms:
2219
- macOS Apple Silicon (`autohand-macos-arm64`)
@@ -32,9 +29,8 @@ This directory contains automated CI/CD workflows for the Autohand CLI project.
3229
5. **Publishes to npm** (stable releases only)
3330

3431
**Release Channels:**
35-
- **main**`v1.2.3` (stable)
36-
- **beta**`v1.2.3-beta.202511221100` (beta with timestamp)
37-
- **alpha**`v1.2.3-alpha.20251122110530` (alpha with timestamp)
32+
- **main push**`v1.2.4-alpha.abc1234` (next patch from the latest stable tag plus short SHA)
33+
- **manual release**`v1.2.3` (stable)
3834

3935
### ✅ CI (`ci.yml`)
4036

@@ -109,9 +105,9 @@ Add these secrets in GitHub Settings → Secrets → Actions:
109105

110106
1. Go to: Actions → Release → Run workflow
111107
2. Choose:
112-
- **Branch**: main/beta/alpha
108+
- **Branch**: main or another release source branch
113109
- **Version**: Leave empty for auto, or specify (e.g., `1.2.3`)
114-
- **Channel**: alpha/beta/release
110+
- **Channel**: alpha/release
115111
3. Click "Run workflow"
116112

117113
## Version Strategy
@@ -120,14 +116,13 @@ Add these secrets in GitHub Settings → Secrets → Actions:
120116

121117
Format: `MAJOR.MINOR.PATCH[-prerelease]`
122118

123-
- **MAJOR**: Breaking changes (`feat!:` or `BREAKING CHANGE:`)
124-
- **MINOR**: New features (`feat:`)
125-
- **PATCH**: Bug fixes (`fix:`)
119+
- **MAJOR**: Breaking changes
120+
- **MINOR**: New features
121+
- **PATCH**: Bug fixes and small improvements
126122

127123
### Prerelease Tags
128124

129-
- **Alpha**: `1.2.3-alpha.20251122110530` (timestamp)
130-
- **Beta**: `1.2.3-beta.202511221100` (timestamp)
125+
- **Alpha**: `1.2.4-alpha.abc1234` (next patch from the latest stable tag plus short SHA)
131126
- **Release**: `1.2.3` (no suffix)
132127

133128
## Changelog Generation
@@ -151,9 +146,8 @@ Check:
151146
### Release Not Created
152147

153148
Check:
154-
1. Commit message follows conventional commits
155-
2. Not a version bump commit (contains `chore(release):`)
156-
3. Repository has write permissions enabled
149+
1. The last commit is not a version bump commit (contains `chore(release):`)
150+
2. Repository has write permissions enabled
157151

158152
### npm Publish Fails
159153

.github/workflows/release.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,18 @@ jobs:
8585
NEW_VERSION="${CURRENT_VERSION}"
8686
echo "🎯 Using existing package.json version: ${NEW_VERSION}"
8787
elif [ "$CHANNEL" = "alpha" ]; then
88-
# Alpha: bump patch from current version and append -alpha.<sha>
89-
MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1)
90-
MINOR=$(echo $CURRENT_VERSION | cut -d. -f2)
91-
PATCH=$(echo $CURRENT_VERSION | cut -d. -f3 | cut -d- -f1)
88+
# Alpha: bump patch from the latest stable release tag, falling back to package.json.
89+
LATEST_STABLE_TAG=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | grep -Ev -- '-(alpha|beta|rc|pre)' | head -n 1)
90+
if [ -n "$LATEST_STABLE_TAG" ]; then
91+
ALPHA_BASE_VERSION="${LATEST_STABLE_TAG#v}"
92+
echo "🎯 Latest stable tag: ${LATEST_STABLE_TAG}"
93+
else
94+
ALPHA_BASE_VERSION="${CURRENT_VERSION}"
95+
echo "🎯 No stable tag found; using package.json version: ${ALPHA_BASE_VERSION}"
96+
fi
97+
MAJOR=$(echo $ALPHA_BASE_VERSION | cut -d. -f1)
98+
MINOR=$(echo $ALPHA_BASE_VERSION | cut -d. -f2)
99+
PATCH=$(echo $ALPHA_BASE_VERSION | cut -d. -f3 | cut -d- -f1)
92100
PATCH=$((PATCH + 1))
93101
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}-alpha.${SHORT_SHA}"
94102
echo "🎯 Alpha version: ${NEW_VERSION}"

tests/installLocalScript.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,15 @@ describe('dependency install guardrails', () => {
8282
expect(packageJson.scripts?.['test:ci']).toBe("node --max-old-space-size=8192 ./node_modules/vitest/vitest.mjs run --pool=threads --exclude 'tests/tuistory/**/*.tuistory.test.ts'");
8383
expect(releaseWorkflow).toContain('run: bun run test:ci');
8484
});
85+
86+
it('bases alpha releases on the latest stable release tag before package.json fallback', () => {
87+
const releaseWorkflow = readFileSync('.github/workflows/release.yml', 'utf8');
88+
89+
expect(releaseWorkflow).toContain('LATEST_STABLE_TAG=$(git tag --list');
90+
expect(releaseWorkflow).toContain("grep -Ev -- '-(alpha|beta|rc|pre)'");
91+
expect(releaseWorkflow).toContain('ALPHA_BASE_VERSION="${LATEST_STABLE_TAG#v}"');
92+
expect(releaseWorkflow).toContain('ALPHA_BASE_VERSION="${CURRENT_VERSION}"');
93+
expect(releaseWorkflow).toContain('MAJOR=$(echo $ALPHA_BASE_VERSION');
94+
expect(releaseWorkflow).not.toContain('Alpha: bump patch from current version');
95+
});
8596
});

0 commit comments

Comments
 (0)