Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSpencer committed Jan 2, 2024
1 parent 3ee88f5 commit 7269e07
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/canary-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// @ts-check

import { exec } from "child_process";
import fs from "fs";

try {
exec("git rev-parse --short HEAD", (err, stdout) => {
if (err) {
console.log(err);
process.exit(1);
}
const commitHash = stdout.trim();

const pkg = JSON.parse(fs.readFileSync("package.json", "utf-8"));
const oldVersion = pkg.version;
const [major, minor, patch] = oldVersion.split(".").map(Number);
const newVersion = `${major}.${minor}.${patch + 1}-canary.${commitHash}`;

pkg.version = newVersion;

const content = `${JSON.stringify(pkg, null, "\t")}\n`;
const newContent = content
.replace(
new RegExp(`"@uploadthing/\\*": "${oldVersion}"`, "g"),
`"@uploadthing/*": "${newVersion}"`,
)
.replace(
new RegExp(`"uploadthing": "${oldVersion}"`, "g"),
`"uploadthing": "${newVersion}"`,
);

fs.writeFileSync("package.json", newContent);
});
} catch (error) {
console.error(error);
process.exit(1);
}
2 changes: 1 addition & 1 deletion .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run: pnpm build

- name: Bump version to canary
run: node .github/canary-version.js
run: node .github/canary-version.mjs

- name: Authenticate to npm and publish
run: |
Expand Down

0 comments on commit 7269e07

Please sign in to comment.