Skip to content
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

release script #9

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lift-html/cli",
"version": "0.0.2",
"version": "0.0.3",
"exports": "./cli.ts",
"imports": {},
"lint": {}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lift-html/core",
"version": "0.0.3",
"version": "0.0.4",
"exports": "./mod.ts",
"imports": {},
"lint": {
Expand Down
2 changes: 1 addition & 1 deletion packages/solid/deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lift-html/solid",
"version": "0.0.5",
"version": "0.0.6",
"exports": "./mod.ts",
"imports": {
"lift-html": "@lift-html/lift-html",
Expand Down
8 changes: 6 additions & 2 deletions packages/tiny/deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"name": "@lift-html/tiny",
"version": "0.0.1",
"version": "0.0.2",
"exports": "./mod.ts",
"imports": {},
"lint": {
"rules": {
"exclude": ["ban-types", "no-empty-interface", "no-explicit-any"]
"exclude": [
"ban-types",
"no-empty-interface",
"no-explicit-any"
]
}
}
}
44 changes: 44 additions & 0 deletions scripts/bump-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env -S DENO_TRACE_PERMISSIONS=1 deno run --allow-env --allow-read --allow-run
import { Checkbox } from "jsr:@cliffy/prompt@1.0.0-rc.7";
import $ from "jsr:@david/dax";

const options = ["core", "solid", "tiny", "cli"];

try {
const selected = await Checkbox.prompt({
message: "Select packages to bump:",
options: options.map((opt) => ({ name: opt, value: opt, checked: false })),
minOptions: 0,
maxOptions: options.length,
});

const versions = new Map<string, string>();
for (const name of selected) {
const filename = `packages/${name}/deno.jsonc`;
await $`deno run -A jsr:@kellnerd/bump --file ${filename}`;
await $`git add ${filename}`;
versions.set(
name,
await $`cat ${filename}`.json().then((json) => json.version),
);
}
if (selected.length === 0) {
console.log("No packages selected");
Deno.exit(0);
}
await $`git commit -m ${`Release: ${
selected.map(
(name) => `@lift-html/${name}@${versions.get(name)}`,
).join(", ")
}`}`;
for (const name of selected) {
await $`git tag @lift-html/${name}@${versions.get(name) ?? ""}`;
}
Comment on lines +35 to +36
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Git tag creation needs error handling
The script currently creates tags without checking for existing ones or handling potential errors. This could lead to failed releases if tags already exist. Consider:

  • Adding -f flag to overwrite existing tags or
  • Adding error handling around the tag creation
  • Adding a pre-check for existing tags before attempting creation

Example fix:

for (const name of selected) {
  const tagName = `@lift-html/${name}@${versions.get(name) ?? ""}`;
  try {
    await $`git tag ${tagName}`;
  } catch (error) {
    console.error(`Failed to create tag ${tagName}:`, error);
    // Either exit or prompt user to force
  }
}
🔗 Analysis chain

Consider confirming successful tags creation
Tagging errors (e.g., if a tag already exists) will throw an error. You could confirm success or handle collisions (e.g., prompt or overwrite).


Let me check the implementation of the bump-version script to see how it handles tag creation and potential conflicts.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that all newly created tags do not clash with existing tags
git fetch --tags
for tag in $(git tag); do
    echo "Found tag: $tag"
done

Length of output: 1938


Script:

#!/bin/bash
# Check the implementation of bump-version.ts
cat scripts/bump-version.ts

Length of output: 1412

console.log("Don't forget to push the changes and tags");
} catch (error) {
if (error instanceof Deno.errors.Interrupted) {
console.log("\nUser interrupted the process");
} else {
console.error("An error occurred:", error);
}
}
Loading