Skip to content

Commit 4b2260d

Browse files
committed
chore(release): add alpha channel and ts bump script
1 parent 41693e8 commit 4b2260d

9 files changed

Lines changed: 59 additions & 35 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches: [main, master, develop]
5+
branches: [main, master, develop, alpha]
66
pull_request:
77

88
jobs:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Release
22

33
on:
44
push:
5-
branches: [main, master]
5+
branches: [main, master, alpha]
66
workflow_dispatch:
77

88
jobs:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Network-ready Elytra racing minigame built on Paper with an ECS-driven architect
2121
3) (Releases) Install pnpm 9 and run `pnpm install` for release tooling.
2222

2323
## Release Flow (semantic-release)
24-
- Branches: `main`/`master` (adjust in `release.config.mts` if needed).
24+
- Branches: `main`/`master`; prerelease channel `alpha` (branch `alpha`).
2525
- Conventional commits drive versioning and changelog updates.
2626
- `pnpm run release` bumps Gradle version, writes `CHANGELOG.md`, tags, and publishes via GitHub Actions (`GITHUB_TOKEN` required).
2727

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group = "net.onelitefeather"
6-
version = "0.0.1-SNAPSHOT"
6+
version = providers.gradleProperty("version").getOrElse("0.0.1-alpha.0")
77

88
subprojects {
99
repositories {

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=0.0.1-alpha.0

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"packageManager": "pnpm@9.12.3",
1111
"scripts": {
1212
"release": "pnpm exec ts-node-esm ./scripts/run-semantic-release.mts",
13-
"bump-version": "node ./scripts/bump-version.js"
13+
"bump-version": "pnpm exec ts-node-esm ./scripts/bump-version.mts"
1414
},
1515
"devDependencies": {
1616
"@semantic-release/changelog": "6.0.3",
@@ -19,7 +19,9 @@
1919
"@semantic-release/git": "10.0.1",
2020
"@semantic-release/github": "9.0.2",
2121
"@semantic-release/release-notes-generator": "12.1.0",
22+
"@types/ini": "4.1.2",
2223
"semantic-release": "23.0.0",
24+
"ini": "4.1.1",
2325
"ts-node": "10.9.2",
2426
"typescript": "5.6.3"
2527
}

release.config.mts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import type { Options } from "semantic-release";
22

33
/** Semantic-release configuration using pnpm and Gradle version bumping. */
44
const config: Options = {
5-
branches: ["main", "master"],
5+
branches: [
6+
{ name: "main" },
7+
{ name: "master" },
8+
{ name: "alpha", prerelease: "alpha", channel: "alpha" }
9+
],
610
tagFormat: "v${version}",
711
plugins: [
812
"@semantic-release/commit-analyzer",
@@ -22,7 +26,7 @@ const config: Options = {
2226
[
2327
"@semantic-release/git",
2428
{
25-
assets: ["CHANGELOG.md", "build.gradle.kts"],
29+
assets: ["CHANGELOG.md", "gradle.properties"],
2630
message: "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
2731
}
2832
],

scripts/bump-version.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

scripts/bump-version.mts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import fs from "node:fs";
2+
import path from "node:path";
3+
import ini from "ini";
4+
5+
const [, , nextVersion] = process.argv;
6+
7+
if (!nextVersion) {
8+
console.error("No version supplied to bump-version script.");
9+
process.exit(1);
10+
}
11+
12+
const gradlePropsPath = path.join(__dirname, "..", "gradle.properties");
13+
const gradleFilePath = path.join(__dirname, "..", "build.gradle.kts");
14+
15+
function readProperties(filePath: string): Record<string, string> {
16+
if (!fs.existsSync(filePath)) return {};
17+
const content = fs.readFileSync(filePath, "utf8");
18+
return ini.parse(content);
19+
}
20+
21+
function writeProperties(filePath: string, props: Record<string, string>) {
22+
const serialized = ini.stringify(props);
23+
fs.writeFileSync(filePath, `${serialized}\n`, "utf8");
24+
}
25+
26+
function updateGradleProperties() {
27+
const props = readProperties(gradlePropsPath);
28+
props.version = nextVersion;
29+
writeProperties(gradlePropsPath, props);
30+
}
31+
32+
function updateBuildGradleIfNeeded() {
33+
if (!fs.existsSync(gradleFilePath)) return;
34+
const content = fs.readFileSync(gradleFilePath, "utf8");
35+
const versionPattern = /(^\s*version\s*=\s*")[^"]+(")/m;
36+
if (versionPattern.test(content)) {
37+
const updated = content.replace(versionPattern, `$1${nextVersion}$2`);
38+
fs.writeFileSync(gradleFilePath, updated, "utf8");
39+
}
40+
}
41+
42+
updateGradleProperties();
43+
updateBuildGradleIfNeeded();
44+
45+
console.log(`Set project version to ${nextVersion}`);

0 commit comments

Comments
 (0)