Skip to content

Commit a38268a

Browse files
committed
Revert "chore: build and test before releasing"
This reverts commit da7ae1c.
1 parent da7ae1c commit a38268a

File tree

7 files changed

+83
-2
lines changed

7 files changed

+83
-2
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ jobs:
4242
run: yarn install --immutable
4343
- name: Ensure linted
4444
run: yarn run ensure-linted
45+
- name: Build
46+
run: yarn build
47+
- name: Test
48+
run: yarn test
4549
- name: Release
4650
env:
4751
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"semantic-release": "semantic-release",
2929
"build": "yarn run clean && rollup -c --configPlugin 'typescript={target:`es6`}'",
3030
"clean": "rimraf dist",
31-
"prepublishOnly": "yarn run build && yarn run test",
3231
"prepare": "husky install"
3332
},
3433
"devDependencies": {

release.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ module.exports = {
1212
"@semantic-release/release-notes-generator",
1313
"@semantic-release/changelog",
1414
["@semantic-release/npm", { pkgRoot: "dist" }],
15+
[
16+
"@semantic-release/exec",
17+
{
18+
// https://semantic-release.gitbook.io/semantic-release/support/faq#how-can-i-use-a-npm-build-script-that-requires-the-package-jsons-version
19+
prepareCmd:
20+
"node scripts/prepublish.js && node scripts/postversion.js -v ${nextRelease.version}",
21+
},
22+
],
1523
"@semantic-release/git",
1624
"@semantic-release/github",
1725
],

rollup.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ export default rollupOptions({
44
node: true,
55
dts: true,
66
inputPatterns: 2,
7-
copyMeta: true,
87
});

scripts/postversion.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* This script file will be executed AFTER the new version is generated
3+
* (before the `git push`)
4+
*
5+
* The following procedures are included:
6+
*
7+
* 1. Before this process, the new version has been generated
8+
* and it should be synced to `package.json` and git,
9+
* as described in [semantic-release/npm](https://github.com/semantic-release/npm#examples).
10+
*
11+
*/
12+
13+
const { readFile, writeFile } = require("fs").promises;
14+
15+
const outputPkg = "package.json";
16+
17+
async function main() {
18+
if (process.argv[2] !== "-v") {
19+
throw new Error(
20+
`postversion.js executed with wrong args: ${process.argv.join(" ")}`,
21+
);
22+
}
23+
24+
const version = process.argv[3];
25+
if (!version || typeof version !== "string") {
26+
throw new Error(`new version is invalid: ${version}`);
27+
}
28+
29+
const pkg = await readFile(outputPkg, "utf8");
30+
31+
const newPkg = pkg.replace(
32+
/([{,]\s*"version"\s*:\s*)("[^"]+")(\s*[},])/,
33+
"$1" + JSON.stringify(version) + "$3",
34+
);
35+
36+
await writeFile(outputPkg, newPkg);
37+
}
38+
39+
main();

scripts/prepublish.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* This script file will be executed BEFORE the package is prepared and packed
3+
*
4+
* The following procedures are included:
5+
*
6+
* 1. Copy files including `README.md` in to `dist` so that they are published
7+
*
8+
*/
9+
10+
const { copyFile } = require("fs").promises;
11+
12+
const files = [
13+
"README.md",
14+
"LICENSE",
15+
// updated by @semantic-release/changelog before npm publish
16+
"CHANGELOG.md",
17+
];
18+
19+
async function main() {
20+
await Promise.all(files.map((f) => copyFile(f, "dist/" + f)));
21+
}
22+
23+
main();

scripts/test-ts-node.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const args = process.argv.slice(2);
2+
3+
console.log(
4+
`ts-node called successfully with ${
5+
args.length > 0
6+
? `args:\n${args.map((arg) => `\t${arg}`).join("\n")}`
7+
: "no args."
8+
}`,
9+
);

0 commit comments

Comments
 (0)