From 8e8675f9444b26dd58e1317906495bad2950cd00 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Sun, 8 Dec 2024 20:02:25 -0500 Subject: [PATCH] feat(ci): automate publishing npm package --- .github/workflows/publish-npm.yml | 31 +++++++++++++++++++++++++++++++ .npmignore | 1 + 2 files changed, 32 insertions(+) create mode 100644 .github/workflows/publish-npm.yml diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..cd9065c --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,31 @@ +name: Publish npm package + +on: + push: + tags: [ 'v*' ] + + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + + - uses: actions/setup-node@v1 + with: + node-version: '20.x' + registry-url: 'https://registry.npmjs.org' + + - uses: actions/checkout@v3 + + - name: Place tag in environment + run: | + echo "SOURCE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV + + - name: Setting package.json version + run: npm version --no-git-tag-version "${SOURCE_TAG#v}" + + - run: npm install + + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.npmignore b/.npmignore index b1380a3..6e0b316 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,4 @@ **/test/ **/.vscode/ +.github/** .eslintrc.json