Skip to content

Commit 6883e5b

Browse files
Bump v0.1.6
1 parent 0890d80 commit 6883e5b

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

.github/workflows/publish.yml

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
- run: yarn
3333
- run: node scripts/publish.js
3434

35+
- name: Push changes to repo
36+
run: git push "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" --follow-tags
37+
3538
docs:
3639
name: Publish Docs
3740
runs-on: ubuntu-latest

lib/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-table-ui",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "Out-of-the-box UI for React-Table 7.",
55
"author": {
66
"name": "Siddhant Gupta",

lib/scripts/publish.js

+21-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
#!/usr/bin/env node
2-
// Script to publish CLI to NPM.
31
// @ts-check
42

53
const { npmPublish } = require('@jsdevtools/npm-publish')
6-
const { readFileSync, writeFileSync } = require('fs')
74
const { spawnSync } = require('child_process')
5+
const { readFileSync, writeFileSync } = require('fs')
86
const manifestPath = './package.json'
97

108
publishToNpm().then(handleSuccess).catch(handleError)
@@ -16,15 +14,18 @@ async function publishToNpm() {
1614
const { name, version: currentVersion } = manifest
1715
const publishedVersion = getPublishedVersion(name)
1816

17+
console.log('Current published version:', currentVersion)
18+
1919
if (publishedVersion === currentVersion) {
20-
return publishCanary(manifest)
20+
return await publishCanary(manifest)
2121
}
2222

23-
return publishLatest()
23+
return await publishLatest(currentVersion)
2424
}
2525

26-
async function publishLatest() {
27-
const result = await npmPublish({ checkVersion: true })
26+
async function publishLatest(version) {
27+
const result = await npmPublish({ checkVersion: true, access: 'public' })
28+
gitTag(version)
2829

2930
return result
3031
}
@@ -35,14 +36,14 @@ async function publishCanary(manifest, tag = 'canary') {
3536
writeFileSync(manifestPath, JSON.stringify(canaryManifest, null, 2))
3637

3738
console.log('Publishing', tag, 'version:', canaryVersion)
38-
return npmPublish({ tag })
39+
return npmPublish({ tag, access: 'public' })
3940
}
4041

4142
/** @param {import("@jsdevtools/npm-publish").Results} results */
42-
function handleSuccess({ version, package: packageName }) {
43-
console.log(
44-
`Link : https://www.npmjs.com/package/${packageName}/v/${version}`
45-
)
43+
function handleSuccess({ package: name, tag, version }) {
44+
console.log()
45+
console.log(`Usage: npm install ${name}@${tag}`)
46+
console.log(`Link : https://www.npmjs.com/package/${name}/v/${version}`)
4647
}
4748

4849
function handleError(error) {
@@ -61,3 +62,11 @@ function getPublishedVersion(name) {
6162
})
6263
return result.stdout.trim().split('\\')[0]
6364
}
65+
66+
/** @param {string} version */
67+
function gitTag(version) {
68+
spawnSync('git', ['config', '--local', 'user.email', `"[email protected]"`])
69+
spawnSync('git', ['config', '--local', 'user.name', `"GitHub Action"`])
70+
71+
spawnSync('git', ['tag', '-a', `v${version}`, '-m', `Release v${version}`])
72+
}

0 commit comments

Comments
 (0)