Skip to content

Commit

Permalink
create release command
Browse files Browse the repository at this point in the history
  • Loading branch information
raulfdm committed Jan 28, 2024
1 parent c9a1f12 commit f4b89c1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
- name: Create Release Pull Request
uses: changesets/action@v1
with:
publish: pnpm publish --no-git-checks
publish: bun run scripts/release.ts
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
39 changes: 39 additions & 0 deletions scripts/release.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { $ } from "bun";
import { execaCommand } from "execa";
import consola from "consola";

consola.info("Starting release process");

try {
consola.log("Trying to publish");
await execaCommand("pnpm publish --no-git-checks", {
shell: true,
all: true,
});
consola.success("Published successfully");

consola.log("Trying to push tags...");
await $`git push --follow-tags`;
consola.success("tags pushed successfully");
} catch (error) {
if (error instanceof Error) {
if (
error.message.includes(
"You cannot publish over the previously published versions",
)
) {
console.info("Version already published, skipping...");
process.exit(0);
} else {
consola.error("Something went wrong", error.message);
process.exit(1);
}
} else {
consola.error("Unknown error", error);
process.exit(1);
}
}

// const a = await $`git`.text();

// console.log(a);

0 comments on commit f4b89c1

Please sign in to comment.