Skip to content

Commit

Permalink
add publish script
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbedard committed Apr 10, 2020
1 parent 6dc8c0d commit 8bbfad1
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish

on:
release:
types: [created]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: npm test

publish-npm:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm test
- run: npm run publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@babel/preset-env": "^7.9.5",
"@rollup/plugin-node-resolve": "^6.0.0",
"babel-jest": "^25.3.0",
"consola": "^2.11.3",
"jest": "^25.3.0",
"rollup": "^1.32.1",
"rollup-plugin-babel": "^4.4.0",
Expand All @@ -35,6 +36,7 @@
"svelte": "src/index.js",
"scripts": {
"build": "rollup -c",
"publish": "node ./scripts/publish.js",
"test": "jest",
"watch": "rollup -c -w"
},
Expand Down
15 changes: 15 additions & 0 deletions scripts/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const consola = require('consola');
const exec = require('child_process').execSync;
const path = require('path');
const pkg = require('../package.json');

const distDir = path.resolve(__dirname, '..', 'dist');

async function cli() {
exec('npm publish --access public', { cwd: distDir, stdio: 'inherit' });
consola.success(`Published svelte-heatmap ${pkg.version}`);
}

if (require.main === module) {
cli();
}

0 comments on commit 8bbfad1

Please sign in to comment.