From 08481625e1f496e93fc86f839b03be67fa9ae646 Mon Sep 17 00:00:00 2001 From: Ruben Arakelyan Date: Thu, 21 Sep 2023 09:22:51 +0100 Subject: [PATCH] Publish to GitHub Packages --- .github/workflows/integration_tests.yaml | 4 +-- .github/workflows/publish.yaml | 35 ++++++++++++++++++++++++ .github/workflows/test.yaml | 6 ++-- package.json | 11 ++++++-- 4 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/integration_tests.yaml b/.github/workflows/integration_tests.yaml index 23055246..cdb9b441 100644 --- a/.github/workflows/integration_tests.yaml +++ b/.github/workflows/integration_tests.yaml @@ -8,14 +8,14 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Read node version from .nvmrc id: nvm run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" - name: "Setup Node v${{ steps.nvm.outputs.NVMRC }}" - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: "${{ steps.nvm.outputs.NVMRC }}" cache: 'npm' diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 00000000..5e32b1b1 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,35 @@ +name: Publish + +on: [push] + +jobs: + build: + name: Publish to GitHub Packages + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + + - name: Read node version from .nvmrc + id: nvm + run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" + + - name: "Setup Node v${{ steps.nvm.outputs.NVMRC }}" + uses: actions/setup-node@v3 + with: + node-version: "${{ steps.nvm.outputs.NVMRC }}" + cache: 'npm' + registry-url: 'https://npm.pkg.github.com' + + - name: Install dependencies + run: | + npm install yarn + yarn install + + - name: Publish + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ba39fea9..2f6b3dd3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,6 +1,6 @@ name: Test -on: [pull_request, push] +on: [push, pull_request] jobs: build: @@ -8,14 +8,14 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Read node version from .nvmrc id: nvm run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" - name: "Setup Node v${{ steps.nvm.outputs.NVMRC }}" - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: "${{ steps.nvm.outputs.NVMRC }}" cache: 'npm' diff --git a/package.json b/package.json index 3b3c3d27..9872fc8a 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,13 @@ { - "name": "accessible-autocomplete-multi", + "name": "@OfficeForProductSafetyAndStandards/accessible-autocomplete-multi", "version": "2.0.4", "main": "dist/accessible-autocomplete.min.js", "style": "dist/accessible-autocomplete.min.css", "description": "An autocomplete component, built to be accessible.", - "repository": "github:OfficeForProductSafetyAndStandards/accessible-autocomplete-multi", + "repository": { + "type": "git", + "url": "https://github.com/OfficeForProductSafetyAndStandards/accessible-autocomplete-multi.git" + }, "author": "Government Digital Service (https://www.gov.uk/government/organisations/government-digital-service) and Office for Product Safety & Standards (https://www.gov.uk/government/organisations/office-for-product-safety-and-standards)", "license": "MIT", "keywords": [ @@ -99,5 +102,7 @@ "standard": { "parser": "@babel/eslint-parser" }, - "private": true + "publishConfig": { + "registry": "https://npm.pkg.github.com" + } }