From b75be00e9fc1b5257f29c0c52deb9f56552bf775 Mon Sep 17 00:00:00 2001 From: Todd Bluhm Date: Wed, 2 Jul 2025 02:05:54 -0800 Subject: [PATCH] feat(github action): added npm release github action release-npm fix(release): use new npm publish github action Only publish to npm if the semver version is different from npm fix(workflow): update release workflow to improve clarity --- .github/workflows/release.yml | 49 +++++++++++++++++++++++++++++++++++ package.json | 7 +++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0e78975 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: release + +# Run action on every commit to main, release only when requested through commit annotation. +on: + push: + branches: [master] + +jobs: + publish-npm: + runs-on: ubuntu-latest + + env: + HUSKY: 0 + NODE_VERSION: 24.x + + permissions: + id-token: write # Required to mint token for npm package provenance + contents: write # Needed to create and write release notes in GitHub release + + steps: + - name: Checkout Project + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Install Dependencies + run: npm install + + - name: Lint Files + run: npm run lint + + - name: Build Project + run: npm run build + + - name: Run Tests + env: + CI: true + run: npm run test + + - name: Publish to NPM + uses: JS-DevTools/npm-publish@v3 + with: + token: ${{ secrets.NPM_TOKEN }} + provenance: true diff --git a/package.json b/package.json index 4e203b2..21253ea 100644 --- a/package.json +++ b/package.json @@ -84,5 +84,12 @@ "text", "lcov" ] + }, + "release": { + "branches": ["master"], + "tagFormat": "${version}" + }, + "publishConfig": { + "provenance": true } }