Update publish workflow, npmignore, prettierrc, and add license #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish npm package | |
on: push | |
env: | |
NPM_TOKEN: ${{secrets.GH_PRIVATE_NPM_TOKEN}} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout source code" | |
uses: actions/checkout@v3 | |
- name: "Setup node" | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: "Install pnpm" | |
run: npm install -g pnpm | |
- name: "Check build" | |
run: pnpm install | |
bump-version: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: "Checkout source code" | |
uses: actions/checkout@v3 | |
- name: "cat package.json (before bump)" | |
run: cat ./package.json | |
- name: "Automated Version Bump" | |
id: version-bump | |
uses: "phips28/gh-action-bump-version@master" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: "cat package.json (after bump)" | |
run: cat ./package.json | |
- name: "Output New Version" | |
env: | |
NEW_TAG: ${{ steps.version-bump.outputs.newTag }} | |
run: echo "new tag $NEW_TAG" | |
- name: "Upload modified files" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: modified-files | |
path: | | |
./package.json | |
./package-lock.json | |
publish-gpr: | |
needs: bump-version | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- name: "Checkout source code" | |
uses: actions/checkout@v3 | |
- name: "Download modified files" | |
uses: actions/download-artifact@v3 | |
with: | |
name: modified-files | |
- name: "Setup node" | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: "Install pnpm" | |
run: | | |
npm install -g pnpm | |
pnpm setup | |
env: | |
SHELL: bash | |
- name: "Install can-npm-publish" | |
run: | | |
pnpm add can-npm-publish --save-dev | |
- name: Setup .temp-npmrc file to authenticate with npm | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${{ env.NPM_TOKEN }}" > .temp-npmrc | |
- name: "Git status check" | |
run: git status | |
- name: "Publish package if needed" | |
run: npx can-npm-publish --verbose && pnpm publish --no-git-checks --userconfig .temp-npmrc || echo "Does not publish" |