Skip to content

Instantly share code, notes, and snippets.

@btorresgil
Last active January 14, 2020 23:55
Show Gist options
  • Save btorresgil/2699f4ce5703f295579577d15cbb7e73 to your computer and use it in GitHub Desktop.
Save btorresgil/2699f4ce5703f295579577d15cbb7e73 to your computer and use it in GitHub Desktop.
GitHub Action: Deploy Babel or TypeScript project to npm and gpr, the right way
# Publish a Babel or TypeScript package to NPM and Github Package Repository
#
# This version triggers when you create a GitHub release in the repo
# Note there is no caching because currently caching is not supported
# for release events, only push and pull_request.
#
# Required secrets:
# NPM_TOKEN: A token for NPM with write access
name: Publish
on:
release:
types: [created]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: npm ci
- run: npm run build
- run: npm test
publish-npm:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-gpr:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: https://npm.pkg.github.com/
scope: '@${{ github.event.repository.owner.login }}'
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment