diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..140f827 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,50 @@ +on: + release: + types: [published] + +name: Publish to NPM + +jobs: + name: npm-publish + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Node + uses: actions/setup-node@v1 + with: + node-version: '14' + + - name: 'Cache node_modules' + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: | + **/node_modules + **/packages/**/node_modules + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: 'Yarn Install' + run: | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc + yarn install --frozen-lockfile + + - name: 'Build' + run: yarn build + + - name: 'Test' + run: yarn test + + - name: 'NPM Publish' + uses: JS-DevTools/npm-publish@v1 + with: + token: ${{ secrets.NPM_TOKEN }} + access: "public" + check-version: true \ No newline at end of file