Skip to content

Commit bff701b

Browse files
committed
Fix publish script
1 parent 5301d2c commit bff701b

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

publish.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ function exec(command: string) {
1313
}
1414

1515
dotenv.config();
16-
console.log(process.env.NPM_TOKEN);
1716
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
1817

1918
(async () => {
@@ -30,37 +29,38 @@ const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
3029
})
3130
).data.tag_name.replace("v", "");
3231

32+
await fsAsync.writeFile(
33+
".npmrc",
34+
`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}`
35+
);
36+
3337
if (deviconVersion != currentVersion) {
3438
console.log(
3539
`New version available (${currentVersion} -> ${deviconVersion})`
3640
);
3741
console.log(" - Building");
3842
await exec("yarn build");
3943
console.log(" - Publishing");
40-
await fsAsync.writeFile(
41-
"dist/.npmrc",
42-
`//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}`
43-
);
4444
await exec(
4545
`yarn --cwd dist publish --non-interactive --new-version ${deviconVersion}`
4646
);
47-
// console.log(" - Creating github release");
48-
// const release_id = (
49-
// await octokit.request("POST /repos/{owner}/{repo}/releases", {
50-
// owner: "maltejur",
51-
// repo: "react-devicons",
52-
// tag_name: `v${deviconVersion}`,
53-
// })
54-
// ).data.id;
55-
// await exec("zip react-devicons.zip dist -r");
56-
// await axios({
57-
// url: `https://uploads.github.com/repos/maltejur/react-devicons/releases/${release_id}/assets?name=react-devicons.zip`,
58-
// data: Buffer.from(await fsAsync.readFile("./react-devicons.zip")),
59-
// headers: {
60-
// Authorization: `token ${process.env.GITHUB_TOKEN}`,
61-
// "Content-Type": "application/zip",
62-
// },
63-
// });
47+
console.log(" - Creating github release");
48+
const release_id = (
49+
await octokit.request("POST /repos/{owner}/{repo}/releases", {
50+
owner: "maltejur",
51+
repo: "react-devicons",
52+
tag_name: `v${deviconVersion}`,
53+
})
54+
).data.id;
55+
await exec("zip react-devicons.zip dist -r");
56+
await axios({
57+
url: `https://uploads.github.com/repos/maltejur/react-devicons/releases/${release_id}/assets?name=react-devicons.zip`,
58+
data: Buffer.from(await fsAsync.readFile("./react-devicons.zip")),
59+
headers: {
60+
Authorization: `token ${process.env.GITHUB_TOKEN}`,
61+
"Content-Type": "application/zip",
62+
},
63+
});
6464
console.log("All done!");
6565
} else {
6666
console.log(`Version up to date (${deviconVersion})`);

0 commit comments

Comments
 (0)