Skip to content

Commit 0c5a657

Browse files
feat: Publish to hex.pm (#48)
--------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent a0f0c9e commit 0c5a657

File tree

5 files changed

+83
-11
lines changed

5 files changed

+83
-11
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Cynthia Mini's client package
2+
3+
Cynthia Mini consists of two packages: A client (you are here) and a server (cynthia_websites_mini_server).
4+
5+
To install or use Cynthia Mini, please refer to [GitHub releases](https://github.com/CynthiaWebsiteEngine/Mini/releases).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Cynthia Mini's server package
2+
3+
Cynthia Mini consists of two packages: A client (cynthia_websites_mini_client) and a server (you are here).
4+
5+
To install or use Cynthia Mini, please refer to [GitHub releases](https://github.com/CynthiaWebsiteEngine/Mini/releases).

cynthia_websites_mini_server/gleam.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ gleam_fetch = "1.3.0"
2424
argv = "1.0.2"
2525
birl = "1.8.0"
2626
conversation = "2.0.1"
27-
bungibindies = { git = "https://github.com/strawmelonjuice/bungibindies.git", ref = "main" }
27+
bungibindies = "1.2.0-rc"
2828
cynthia_websites_mini_client = { path = "../cynthia_websites_mini_client" }
2929
edit_distance = "2.0.1"
3030
envoy = "1.0.2"

cynthia_websites_mini_server/manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages = [
77
{ name = "birl", version = "1.8.0", build_tools = ["gleam"], requirements = ["gleam_regexp", "gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "2AC7BA26F998E3DFADDB657148BD5DDFE966958AD4D6D6957DD0D22E5B56C400" },
88
{ name = "bungibindies", version = "1.1.8", build_tools = ["gleam"], requirements = ["gleam_javascript", "gleam_stdlib"], source = "git", repo = "https://github.com/strawmelonjuice/bungibindies.git", commit = "350be6716c308771bbdfbb3f53d6f50e100c6a21" },
99
{ name = "conversation", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript", "gleam_stdlib"], otp_app = "conversation", source = "hex", outer_checksum = "103DF47463B8432AB713D6643DC17244B9C82E2B172A343150805129FE584A2F" },
10-
{ name = "cynthia_websites_mini_client", version = "1.1.6", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_fetch", "gleam_http", "gleam_javascript", "gleam_json", "gleam_stdlib", "gleam_time", "houdini", "jot", "lustre", "modem", "odysseus", "plinth", "rsvp"], source = "local", path = "../cynthia_websites_mini_client" },
10+
{ name = "cynthia_websites_mini_client", version = "1.2.0-rc", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_fetch", "gleam_http", "gleam_javascript", "gleam_json", "gleam_stdlib", "gleam_time", "houdini", "jot", "lustre", "modem", "odysseus", "plinth", "rsvp"], source = "local", path = "../cynthia_websites_mini_client" },
1111
{ name = "edit_distance", version = "2.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "edit_distance", source = "hex", outer_checksum = "A1E485C69A70210223E46E63985FA1008B8B2DDA9848B7897469171B29020C05" },
1212
{ name = "envoy", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "95FD059345AA982E89A0B6E2A3BF1CF43E17A7048DCD85B5B65D3B9E4E39D359" },
1313
{ name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },

mise/tasks/new-release

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if (mainBranch !== "main") {
4747
}
4848

4949
// Now, we want to know if the user wants to bump the version or set it to a specific value. The optional parameter is either "bump" or "set", followed by the version number.
50-
// It can also be `x.x.x` instead of `set`, or `+x.x.x` instead of `bump`, as a shorthand for the same operation.
50+
// It can also be `x.x.x` instead of `set`, or `+x.x.x` instead of `bump`, as a shorthand for the same operation.
5151
// (The x's are numbers in this case, e.g., `+0.2.0` bumps the minor version by 2, while `1.2.3` sets the version to 1.2.3., you could call these 'relative' or 'absolute'.)
5252
if (args.length === 0) {
5353
console.error("Please provide a version to bump or set. Usage: new-release <bump|set> <version>");
@@ -165,18 +165,80 @@ if (!noCommit) {
165165
console.log("Skipping commit and tag as --no-commit flag is set.");
166166
}
167167

168-
// Push the changes and the new tag to the remote repository
168+
// Push commits, publish Gleam packages, then push the tag to the remote repository
169169
if (noPush) {
170170
console.log("Skipping push to remote repository as --no-push flag is set.");
171171
}
172172
else if (!noCommit) {
173-
const pushResult = Bun.spawnSync(["git", "push", "origin", `v${newVersion}`], {
174-
cwd: config_root,
175-
});
176-
if (pushResult.exitCode !== 0) {
177-
console.error("Failed to push changes to the remote repository. Please check the output above for details.");
178-
if (pushResult.stderr) {
179-
console.error(pushResult.stderr.toString());
173+
// First push the commits
174+
const pushCommits = Bun.spawnSync(["git", "push"], { cwd: config_root });
175+
if (pushCommits.exitCode !== 0) {
176+
console.error("Failed to push commits to the remote repository. Please check the output above for details.");
177+
if (pushCommits.stderr) {
178+
console.error(pushCommits.stderr.toString());
179+
}
180+
process.exit(1);
181+
}
182+
183+
// Publish client first
184+
const clientDir = join(config_root, "cynthia_websites_mini_client");
185+
const serverDir = join(config_root, "cynthia_websites_mini_server");
186+
console.log("Running 'gleam publish -y' in client directory...");
187+
const clientPublish = Bun.spawnSync(["gleam", "publish", "-y"], { cwd: clientDir });
188+
if (clientPublish.exitCode !== 0) {
189+
console.error("Failed to publish client package via Gleam.");
190+
if (clientPublish.stderr) {
191+
console.error(clientPublish.stderr.toString());
192+
}
193+
process.exit(1);
194+
}
195+
196+
// Temporarily replace server's path dependency on client with a version string
197+
const serverTomlPath = join(serverDir, "gleam.toml");
198+
const serverTomlOrig = await Bun.file(serverTomlPath).text();
199+
const pathDepRegex = /cynthia_websites_mini_client\s*=\s*\{\s*path\s*=\s*"\.\.\/cynthia_websites_mini_client"\s*\}/;
200+
const versionDepLine = `cynthia_websites_mini_client = "${newVersion}"`;
201+
const serverTomlUpdated = serverTomlOrig.replace(pathDepRegex, versionDepLine);
202+
if (serverTomlOrig !== serverTomlUpdated) {
203+
try {
204+
await Bun.write(serverTomlPath, serverTomlUpdated);
205+
} catch (err) {
206+
console.error("Failed to update server gleam.toml to version dependency.");
207+
process.exit(1);
208+
}
209+
} else {
210+
console.warn("Warning: Could not find path dependency for client in server's gleam.toml; proceeding.");
211+
}
212+
213+
// Publish server second
214+
console.log("Running 'gleam publish -y' in server directory...");
215+
const serverPublish = Bun.spawnSync(["gleam", "publish", "-y"], { cwd: serverDir });
216+
if (serverPublish.exitCode !== 0) {
217+
console.error("Failed to publish server package via Gleam.");
218+
if (serverPublish.stderr) {
219+
console.error(serverPublish.stderr.toString());
220+
}
221+
// Attempt to revert the gleam.toml if modified
222+
try { await Bun.write(serverTomlPath, serverTomlOrig); } catch { }
223+
process.exit(1);
224+
}
225+
226+
// Revert server gleam.toml back to path dependency
227+
if (serverTomlOrig !== serverTomlUpdated) {
228+
try {
229+
await Bun.write(serverTomlPath, serverTomlOrig);
230+
} catch (err) {
231+
console.error("Failed to revert server gleam.toml back to path dependency.");
232+
process.exit(1);
233+
}
234+
}
235+
236+
// Then push the tag
237+
const pushTag = Bun.spawnSync(["git", "push", "origin", `v${newVersion}`], { cwd: config_root });
238+
if (pushTag.exitCode !== 0) {
239+
console.error("Failed to push tag to the remote repository. Please check the output above for details.");
240+
if (pushTag.stderr) {
241+
console.error(pushTag.stderr.toString());
180242
}
181243
process.exit(1);
182244
}

0 commit comments

Comments
 (0)