-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Publish to hex.pm #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds README files for client and server packages, pins the bungibindies dependency to version 1.2.0-rc, updates the server manifest to reference cynthia_websites_mini_client at 1.2.0-rc, and replaces the single-step release script with a multi-stage Changes
Sequence Diagram(s)sequenceDiagram
actor Maintainer
participant Script as mise/tasks/new-release
participant Git as Git
participant ClientPub as Client (gleam publish)
participant Toml as server/gleam.toml
participant ServerPub as Server (gleam publish)
Maintainer->>Script: Run new-release
Script->>Git: Push commits
alt push fails
Git-->>Script: error
Script->>Maintainer: abort with error
end
rect rgb(220,235,255)
Note over Script,ClientPub: Publish client package first
Script->>ClientPub: gleam publish (client)
alt client publish fails
ClientPub-->>Script: error
Script->>Maintainer: abort with error
end
end
Script->>Toml: Modify dependency (path → version) (temporary)
Script->>ServerPub: gleam publish (server)
alt server publish fails
ServerPub-->>Script: error
Script->>Toml: attempt revert
Script->>Maintainer: abort with error
end
Script->>Toml: Revert dependency to path
Script->>Git: Push tag
Script->>Maintainer: complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (1)
mise/tasks/new-release (1)
184-186: Consider using the already-importedjoinfrom 'path' instead of a custom implementation.The
joinfunction from thepathmodule is already imported at line 115. The custompathJoinusing URL manipulation is unnecessary complexity.- const pathJoin = (a, b) => new URL(b, new URL('file://' + (a.endsWith('/') ? a : a + '/'))).pathname; - const clientDir = pathJoin(config_root, "cynthia_websites_mini_client"); - const serverDir = pathJoin(config_root, "cynthia_websites_mini_server"); + const clientDir = join(config_root, "cynthia_websites_mini_client"); + const serverDir = join(config_root, "cynthia_websites_mini_server");
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
cynthia_websites_mini_client/README.md(1 hunks)cynthia_websites_mini_server/README.md(1 hunks)cynthia_websites_mini_server/gleam.toml(1 hunks)mise/tasks/new-release(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-07-10T13:40:49.897Z
Learnt from: strawmelonjuice
Repo: CynthiaWebsiteEngine/Mini PR: 33
File: cynthia_websites_mini_server/src/cynthia_websites_mini_server/config.gleam:896-899
Timestamp: 2025-07-10T13:40:49.897Z
Learning: In CynthiaWebsiteEngine Mini, the user prefers to avoid requiring external dependencies like Pandoc during initial setup to maintain a smooth out-of-the-box experience, even if it means accepting some compatibility risks with Markdown/Djot parsing differences.
Applied to files:
cynthia_websites_mini_server/README.mdcynthia_websites_mini_client/README.md
📚 Learning: 2025-07-11T23:05:46.554Z
Learnt from: strawmelonjuice
Repo: CynthiaWebsiteEngine/Mini PR: 39
File: cynthia_websites_mini_server/test/cynthia_websites_mini_server_test.gleam:2-3
Timestamp: 2025-07-11T23:05:46.554Z
Learning: In the CynthiaWebsiteEngine/Mini project, Mise build tasks handle compilation order and codegen, ensuring proper dependency resolution even when server tests import from the client package.
Applied to files:
cynthia_websites_mini_server/README.mdcynthia_websites_mini_client/README.md
🔇 Additional comments (3)
cynthia_websites_mini_client/README.md (1)
1-5: LGTM!The README provides a clear, concise description of the package structure and directs users appropriately to the releases page for installation guidance.
cynthia_websites_mini_server/gleam.toml (1)
27-27: LGTM!Pinning
bungibindiesto a versioned dependency rather than a git reference is appropriate for the release workflow.mise/tasks/new-release (1)
227-235: Uncommitted changes may remain after tag push.After reverting the server's
gleam.tomlback to the path dependency (line 230), this change is not committed. If the script completes successfully, the working directory will have uncommitted modifications togleam.toml. Consider whether this is intentional or if the revert should be committed (or the modification should happen in a way that doesn't affect the working tree).
mise/tasks/new-release
Outdated
| const serverPublish = Bun.spawnSync(["gleam", "publish"], { cwd: serverDir }); | ||
| if (serverPublish.exitCode !== 0) { | ||
| console.error("Failed to publish server package via Gleam."); | ||
| if (serverPublish.stderr) { | ||
| console.error(serverPublish.stderr.toString()); | ||
| } | ||
| // Attempt to revert the gleam.toml if modified | ||
| try { await Bun.write(serverTomlPath, serverTomlOrig); } catch { } | ||
| process.exit(1); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add --yes flag here as well, and improve error handling on revert.
Same issue as the client publish — needs --yes to avoid hanging. Additionally, the silent catch {} on line 223 swallows any error details if the revert fails, making debugging difficult.
- const serverPublish = Bun.spawnSync(["gleam", "publish"], { cwd: serverDir });
+ const serverPublish = Bun.spawnSync(["gleam", "publish", "--yes"], { cwd: serverDir });
if (serverPublish.exitCode !== 0) {
console.error("Failed to publish server package via Gleam.");
if (serverPublish.stderr) {
console.error(serverPublish.stderr.toString());
}
// Attempt to revert the gleam.toml if modified
- try { await Bun.write(serverTomlPath, serverTomlOrig); } catch { }
+ try {
+ await Bun.write(serverTomlPath, serverTomlOrig);
+ } catch (revertErr) {
+ console.error("Additionally failed to revert server gleam.toml:", revertErr);
+ }
process.exit(1);
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const serverPublish = Bun.spawnSync(["gleam", "publish"], { cwd: serverDir }); | |
| if (serverPublish.exitCode !== 0) { | |
| console.error("Failed to publish server package via Gleam."); | |
| if (serverPublish.stderr) { | |
| console.error(serverPublish.stderr.toString()); | |
| } | |
| // Attempt to revert the gleam.toml if modified | |
| try { await Bun.write(serverTomlPath, serverTomlOrig); } catch { } | |
| process.exit(1); | |
| } | |
| const serverPublish = Bun.spawnSync(["gleam", "publish", "--yes"], { cwd: serverDir }); | |
| if (serverPublish.exitCode !== 0) { | |
| console.error("Failed to publish server package via Gleam."); | |
| if (serverPublish.stderr) { | |
| console.error(serverPublish.stderr.toString()); | |
| } | |
| // Attempt to revert the gleam.toml if modified | |
| try { | |
| await Bun.write(serverTomlPath, serverTomlOrig); | |
| } catch (revertErr) { | |
| console.error("Additionally failed to revert server gleam.toml:", revertErr); | |
| } | |
| process.exit(1); | |
| } |
🤖 Prompt for AI Agents
In mise/tasks/new-release around lines 216 to 225, the Gleam publish call needs
the non-interactive flag and the revert catch must not silently swallow errors:
change the spawn to include the "--yes" arg (e.g. ["gleam","publish","--yes"])
so it won’t hang, and replace the empty catch around the
Bun.write(serverTomlPath, serverTomlOrig) with error handling that logs the
failure (include the caught error message and stack) and exits with a non-zero
code or rethrows so a failed revert is visible for debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@strawmelonjuice Thanks for adding the -y flag! 👍 That will prevent the command from hanging.
However, I notice the error handling improvement for the revert operation hasn't been applied yet. On line 227, the catch block is still empty:
try { await Bun.write(serverTomlPath, serverTomlOrig); } catch { }This silently swallows any errors that occur during the revert, making it difficult to debug if something goes wrong. Could you update it to log the error details? For example:
try {
await Bun.write(serverTomlPath, serverTomlOrig);
} catch (revertErr) {
console.error("Additionally failed to revert server gleam.toml:", revertErr);
}This way, if the revert fails after a publish error, you'll have visibility into what went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
mise/tasks/new-release (1)
168-246: Success message does not reflect--no-commit/--no-pushbehaviourWhen
--no-pushor--no-commitare set, the block that pushes, publishes, and pushes the tag is skipped, but the final log line still says:
Successfully bumped version from ... and created a new release!In those cases no release has actually been created (and for
--no-committhere may not even be a commit/tag), which can mislead both humans and automation.Consider tracking whether the publish+tag path actually ran and adjusting the final message accordingly, for example:
-let noPush = args.includes("--no-push"); +let noPush = args.includes("--no-push"); +let didPublish = false; ... -if (noPush) { +if (noPush) { console.log("Skipping push to remote repository as --no-push flag is set."); } else if (!noCommit) { @@ - const pushTag = Bun.spawnSync(["git", "push", "origin", `v${newVersion}`], { cwd: config_root }); + const pushTag = Bun.spawnSync(["git", "push", "origin", `v${newVersion}`], { cwd: config_root }); @@ - process.exit(1); - } -} -console.log(`Successfully bumped version from ${currentVersion} to ${newVersion} and created a new release!`); + process.exit(1); + } + didPublish = true; +} +if (didPublish) { + console.log(`Successfully bumped version from ${currentVersion} to ${newVersion} and created a new release!`); +} else { + console.log(`Successfully bumped version from ${currentVersion} to ${newVersion}. No push/publish was performed because of the flags in use.`); +}This keeps the message accurate in all flag combinations.
♻️ Duplicate comments (1)
mise/tasks/new-release (1)
221-223: Do not silently swallow errors when revertingserver’sgleam.tomlon failureOn server publish failure you attempt to revert
gleam.toml, but any error in the revert is ignored:// Attempt to revert the gleam.toml if modified try { await Bun.write(serverTomlPath, serverTomlOrig); } catch { }If the revert fails (permissions, disk full, etc.), the script exits with an error but you lose the crucial signal that the file is now left in a modified, inconsistent state, making debugging and cleanup harder.
You already log and exit on revert failure in the successful-publish path a few lines below; mirroring that pattern here would make failures much more observable:
- // Attempt to revert the gleam.toml if modified - try { await Bun.write(serverTomlPath, serverTomlOrig); } catch { } + // Attempt to revert the gleam.toml if modified + try { + await Bun.write(serverTomlPath, serverTomlOrig); + } catch (revertErr) { + console.error("Additionally failed to revert server gleam.toml:", revertErr); + }This retains the original exit behaviour but surfaces the revert problem in logs.
🧹 Nitpick comments (2)
mise/tasks/new-release (2)
27-37: “Up to date with remote” check is ineffective as written
git rev-parse --abbrev-ref @returns the same branch name asHEAD, sobranchandremotewill always be equal and this check never detects being behind or ahead of the upstream. To actually compare with the tracking branch you probably want@{u}or a different mechanism (for example, checkinggit status --porcelain=v2 --branchfor ahead/behind markers) before allowing a release.
49-104: Tighten version argument handling and relative bump behaviourTwo small edge cases here:
setwithout an explicit version (new-release set) silently defaults to0.0.0viaversionValue = args[1] || "0.0.0", which is surprising and potentially dangerous. It would be safer to require an explicit version forsetand error out ifargs[1]is missing.The relative bump shorthand
+x.x.xassumescurrentVersion.split('.')yields plain numbers. IfcurrentVersionever includes a pre-release suffix (for example1.2.3-rc.1),Numberwill produceNaNand you will hit the “Resulting version is not valid semver” path even though a sensible bump could be computed. If you plan to use+x.x.xwhen on pre-release versions, consider parsingcurrentVersionviasemver.parseand derivingmajor/minor/patchfrom that rather than splitting the raw string.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
cynthia_websites_mini_server/manifest.toml(1 hunks)mise/tasks/new-release(2 hunks)
🔇 Additional comments (1)
cynthia_websites_mini_server/manifest.toml (1)
10-10: Client manifest version bump looks fine; keep it in sync with Gleam outputThe updated
cynthia_websites_mini_clientversion to1.2.0-rcundersource = "local"is consistent with the staged publish flow. Just make sure this file gets regenerated by Gleam (e.g. viagleam deps/ build) as part of your normal workflow so it does not drift from the tool’s canonical output.
Summary by CodeRabbit
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.