Skip to content

Commit d765175

Browse files
committed
chore(scripts): update release script to include rivetkit
1 parent 3cc024b commit d765175

File tree

9 files changed

+394
-656
lines changed

9 files changed

+394
-656
lines changed

.github/workflows/release.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ jobs:
6767
npm install -g tsx
6868
6969
if [ "${{ inputs.latest }}" = "true" ]; then
70-
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --setupCi
70+
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --phase setup-ci
7171
else
72-
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --setupCi
72+
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --phase setup-ci
7373
fi
7474
7575
binaries:
@@ -254,7 +254,7 @@ jobs:
254254
npm install -g tsx
255255
256256
if [ "${{ inputs.latest }}" = "true" ]; then
257-
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --completeCi --noValidateGit
257+
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --phase complete-ci --no-validate-git
258258
else
259-
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --completeCi --noValidateGit
259+
./scripts/release/main.ts --version "${{ github.event.inputs.version }}" --no-latest --phase complete-ci --no-validate-git
260260
fi

justfile

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
[group('github')]
2-
release-latest VERSION:
3-
./scripts/release/main.ts --setupLocal --version {{ VERSION }}
4-
gh workflow run .github/workflows/release.yaml -f version={{ VERSION }} -f latest=true --ref $(git branch --show-current)
5-
echo 'Once workflow is complete, manually merge Release Please'
6-
7-
[group('github')]
8-
release-nolatest VERSION:
9-
./scripts/release/main.ts --setupLocal --version {{ VERSION }} --no-latest
10-
gh workflow run .github/workflows/release.yaml -f version={{ VERSION }} -f latest=false --ref $(git branch --show-current)
11-
echo 'Once workflow is complete, manually merge Release Please'
1+
[group('release')]
2+
release *ARGS:
3+
./scripts/release/main.ts {{ ARGS }}
124

135
[group('docker')]
146
docker-build:

pnpm-lock.yaml

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

scripts/release/git.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,71 @@ export async function validateGit(_opts: ReleaseOpts) {
1111
);
1212
}
1313
}
14+
15+
export async function createAndPushTag(opts: ReleaseOpts) {
16+
console.log(`Creating tag v${opts.version}...`);
17+
try {
18+
// Create tag and force update if it exists
19+
await $({ cwd: opts.root })`git tag -f v${opts.version}`;
20+
21+
// Push tag with force to ensure it's updated
22+
await $({ cwd: opts.root })`git push origin v${opts.version} -f`;
23+
24+
console.log(`✅ Tag v${opts.version} created and pushed`);
25+
} catch (err) {
26+
console.error("❌ Failed to create or push tag");
27+
throw err;
28+
}
29+
}
30+
31+
export async function createGitHubRelease(opts: ReleaseOpts) {
32+
console.log("Creating GitHub release...");
33+
34+
try {
35+
// Get the current tag name (should be the tag created during the release process)
36+
const { stdout: currentTag } = await $({
37+
cwd: opts.root,
38+
})`git describe --tags --exact-match`;
39+
const tagName = currentTag.trim();
40+
41+
console.log(`Looking for existing release for ${opts.version}`);
42+
43+
// Check if a release with this version name already exists
44+
const { stdout: releaseJson } = await $({
45+
cwd: opts.root,
46+
})`gh release list --json name,tagName`;
47+
const releases = JSON.parse(releaseJson);
48+
const existingRelease = releases.find(
49+
(r: any) => r.name === opts.version,
50+
);
51+
52+
if (existingRelease) {
53+
console.log(
54+
`Updating release ${opts.version} to point to new tag ${tagName}`,
55+
);
56+
await $({
57+
cwd: opts.root,
58+
})`gh release edit ${existingRelease.tagName} --tag ${tagName}`;
59+
} else {
60+
console.log(
61+
`Creating new release ${opts.version} pointing to tag ${tagName}`,
62+
);
63+
await $({
64+
cwd: opts.root,
65+
})`gh release create ${tagName} --title ${opts.version} --generate-notes`;
66+
67+
// Check if this is a pre-release (contains -rc. or similar)
68+
if (opts.version.includes("-")) {
69+
await $({
70+
cwd: opts.root,
71+
})`gh release edit ${tagName} --prerelease`;
72+
}
73+
}
74+
75+
console.log("✅ GitHub release created/updated");
76+
} catch (err) {
77+
console.error("❌ Failed to create GitHub release");
78+
console.warn("! You may need to create the release manually");
79+
throw err;
80+
}
81+
}

0 commit comments

Comments
 (0)