Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisl9029 committed Aug 6, 2024
1 parent 18d0a01 commit 72843f3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 35 deletions.
67 changes: 34 additions & 33 deletions .github/bot/src/nightly-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,57 @@
import { octokit, owner, repo } from "./util/octokit";

function addZ(n: number) {
return n < 10 ? "0" + n : "" + n;
return n < 10 ? "0" + n : "" + n;
}

async function main() {
// Default to the core version in packages/core/package.json
const coreVersion = require("../../../packages/core/package.json").version;
// Default to the core version in packages/core/package.json
const coreVersion = require("../../../packages/core/package.json").version;
process.stdout.write(`version=${coreVersion}\n`);

return coreVersion;
return coreVersion;

const latest: string = process.argv[2] || coreVersion;
const latest: string = process.argv[2] || coreVersion;

process.stderr.write(`Previous version: ${latest}\n`);
process.stderr.write(`Previous version: ${latest}\n`);

// Bump patch version
// Bump patch version

const [major, minor, patch] = latest.split("-")[0].split(".").map(Number);
const [major, minor, patch] = latest.split("-")[0].split(".").map(Number);

// Nightly version after 1.2.3 is 1.2.4-nightly-20211020.1
// Nightly version after 1.2.3-nightly-20211020.1 is 1.2.3-nightly-20211020.2
// Nightly version after 1.2.3 is 1.2.4-nightly-20211020.1
// Nightly version after 1.2.3-nightly-20211020.1 is 1.2.3-nightly-20211020.2

const version = `${major}.${minor}.${patch}`;
// Nightly version
const version = `${major}.${minor}.${patch}`;
// Nightly version

const date = new Date();
const date = new Date();

const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();

const datePart = `${year}${addZ(month)}${addZ(day)}`;
const datePart = `${year}${addZ(month)}${addZ(day)}`;

const base = `v${version}-nightly-${datePart}`;
let idx = 1;
let nightlyVersion = `${base}.${idx}`;
const base = `v${version}-nightly-${datePart}`;
let idx = 1;
let nightlyVersion = `${base}.${idx}`;

// Check if the nightly version already exists, using octokit and git tags
// Check if the nightly version already exists, using octokit and git tags

const { data: tagData } = await octokit.repos.listTags({
owner,
repo,
order: "desc",
});
const tags = tagData.map((tag) => tag.name);
while (tags.includes(nightlyVersion)) {
idx += 1;
nightlyVersion = `${base}.${idx}`;
}
process.stderr.write(`Nightly version: ${nightlyVersion}\n`);
const { data: tagData } = await octokit.repos.listTags({
owner,
repo,
order: "desc",
});
const tags = tagData.map((tag) => tag.name);
while (tags.includes(nightlyVersion)) {
idx += 1;
nightlyVersion = `${base}.${idx}`;
}
process.stderr.write(`Nightly version: ${nightlyVersion}\n`);

process.stdout.write(`version=${nightlyVersion.substring(1)}\n`);
process.stdout.write(`version=${nightlyVersion.substring(1)}\n`);
}

main();
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
inputs:
version:
description: "Version to publish"
required: false
required: true
type: string
skipBuild:
description: "Skip build. Used to debug swc-ecosystem-ci."
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lewisl9029/swc-core",
"version": "1.7.7-nightly-20240806.2-2",
"version": "1.7.7-nightly-20240806.2-3",
"description": "Super-fast alternative for babel",
"homepage": "https://swc.rs",
"main": "./index.js",
Expand Down

0 comments on commit 72843f3

Please sign in to comment.