From 19dc63bff682c35f58f984e89cb7f94f9c89b535 Mon Sep 17 00:00:00 2001 From: Patrick Kalita Date: Mon, 23 Dec 2024 15:00:49 -0800 Subject: [PATCH 1/2] Add workflow to publish NPM package --- .github/workflows/publish.yaml | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..a8de383 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,61 @@ +name: Publish package +on: + workflow_dispatch: + inputs: + release-type: + description: | + Release type, determines how the version number is incremented. Note: premajor, preminor, + and prepatch will increment the version number **and** add a `-beta.0` suffix. If the + current version number already has a `-beta` suffix, use the prerelease option to + increment the beta number **without** changing the version number. + required: true + options: + - patch + - minor + - major + - prepatch + - preminor + - premajor + - prerelease + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '22.x' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + # This git user config is recommended by the actions/checkout documentation + # https://github.com/actions/checkout/tree/v4.2.2?tab=readme-ov-file#push-a-commit-using-the-built-in-token + - name: Configure git user + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Increment version + run: | + echo "NEW_VERSION=$(npm --preid=beta version $RELEASE_TYPE)" >> $GITHUB_ENV + env: + RELEASE_TYPE: ${{ github.event.inputs.release-type }} + + - name: Publish to NPM + run: npm publish --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ env.NEW_VERSION }} + generate_release_notes: true + prerelease: ${{ startsWith(github.event.inputs.release-type, 'pre') }} From 96d9599e35ca9f8ed00cd9c0e6843c21efdc03e0 Mon Sep 17 00:00:00 2001 From: Patrick Kalita Date: Mon, 23 Dec 2024 15:05:44 -0800 Subject: [PATCH 2/2] Format with Prettier --- .github/workflows/publish.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index a8de383..9a39e35 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -26,8 +26,8 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: '22.x' - registry-url: 'https://registry.npmjs.org' + node-version: "22.x" + registry-url: "https://registry.npmjs.org" - name: Install dependencies run: npm ci