diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..50d18ef --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,57 @@ +name: Publish + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 14 + - run: npm ci --ignore-scripts + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 14 + registry-url: https://registry.npmjs.org/ + - run: npm ci --ignore-scripts + - run: npm run build + - run: echo "tag=latest" >> $GITHUB_ENV + - name: Sets npm tag + if: contains(github.event.release.tag_name, 'beta') + run: echo "tag=beta" >> $GITHUB_ENV + - run: npm publish --access public --tag {{ env.tag }} + env: + NODE_AUTH_TOKEN: ${{ secrets.npm_token }} + + publish-github: + needs: build + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 14 + registry-url: https://npm.pkg.github.com/ + - run: npm ci --ignore-scripts + - run: npm run build + - run: echo "tag=latest" >> $GITHUB_ENV + - name: Sets npm tag + if: contains(github.event.release.tag_name, 'beta') + run: echo "tag=beta" >> $GITHUB_ENV + - run: npm publish --tag {{ env.tag }} + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 8a1a90a..4f9dbdc 100644 --- a/package.json +++ b/package.json @@ -40,9 +40,8 @@ "dist/src/**/*" ], "scripts": { - "prepack": "npm i && tsc", "test": "tsc --sourceMap && ava", - "build": "tsc" + "build": "rm -rf dist && tsc" }, "dependencies": {}, "devDependencies": { @@ -61,4 +60,4 @@ "failFast": true, "failWithoutAssertions": true } -} +} \ No newline at end of file