From dfe61c6d1f69019baa9e79c8b54b8c95fba47d9e Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Wed, 21 Aug 2024 20:18:59 +0100 Subject: [PATCH] chore: add publish workflow (#138) --- .github/workflows/main.yml | 4 +-- .github/workflows/publish.yml | 47 +++++++++++++++++++++++++++++++++++ package-lock.json | 4 +-- package.json | 2 +- 4 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b87b414..d61540b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,9 +14,9 @@ jobs: fail-fast: false steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Use Node v${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: Install Dependencies diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..1cbc4d7 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,47 @@ +name: Publish Release (npm) + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install Dependencies + run: npm ci + - name: Lint + run: npm run lint + - name: Test + run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22.x + registry-url: 'https://registry.npmjs.org' + cache: 'npm' + - run: npm ci + - run: npm version ${TAG_NAME} --git-tag-version=false + env: + TAG_NAME: ${{ github.ref_name }} + - run: npm publish --provenance --access public --tag next + if: "github.event.release.prerelease" + env: + NODE_AUTH_TOKEN: ${{ secrets.npm_token }} + - run: npm publish --provenance --access public + if: "!github.event.release.prerelease" + env: + NODE_AUTH_TOKEN: ${{ secrets.npm_token }} diff --git a/package-lock.json b/package-lock.json index 9290188..86ea135 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "eslint-plugin-wc", - "version": "2.1.0", + "version": "0.0.0-dev", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "eslint-plugin-wc", - "version": "2.1.0", + "version": "0.0.0-dev", "license": "MIT", "dependencies": { "is-valid-element-name": "^1.0.0", diff --git a/package.json b/package.json index adf5143..9b481bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-wc", - "version": "2.1.0", + "version": "0.0.0-dev", "description": "ESLint plugin for Web Components", "main": "lib/index.js", "files": [