From 05ebdf9664fa7269d3b3d104d755622cc3e8f26b Mon Sep 17 00:00:00 2001 From: Danyal Aytekin Date: Fri, 27 Oct 2023 15:23:30 +0100 Subject: [PATCH] Add publishing workflow (#21) * Add publishing workflow * Remove `master` branch push trigger for test workflow * Update publisher's Node version to 20 from 16 --- .github/workflows/publish.yml | 37 +++++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 1 - 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..65d2f58 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,37 @@ +on: + release: + types: [created, edited, published] + workflow_dispatch: + inputs: + dryRun: + description: "Dry run only" + required: true + default: true + type: boolean + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 20 + registry-url: "https://registry.npmjs.org" + - run: npm ci + + - name: Publish package + env: + NODE_AUTH_TOKEN: ${{ secrets.REGISTRY_PUBLISH_TOKEN }} + if: > + (github.event_name == 'release' && github.event.action == 'published') || + (github.event_name == 'workflow_dispatch' && !inputs.dryRun) + run: npm publish + + - name: Publish package (dry run) + env: + NODE_AUTH_TOKEN: ${{ secrets.REGISTRY_PUBLISH_TOKEN }} + if: > + (github.event_name == 'release' && github.event.action != 'published') || + (github.event_name == 'workflow_dispatch' && inputs.dryRun) + run: npm publish --dry-run diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d30ccf7..5be7396 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,7 +1,6 @@ on: push: branches: - - master - main pull_request: