diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c422629..61093e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,6 +92,14 @@ jobs: permissions: contents: read packages: write + strategy: + fail-fast: false + matrix: + include: + - registry-url: "https://npm.pkg.github.com" + extra-args: "" + - registry-url: "https://registry.npmjs.org" + extra-args: "--provenance --access public" steps: - name: Checkout uses: actions/checkout@v4 @@ -100,16 +108,12 @@ jobs: uses: actions/setup-node@v4 with: node-version: latest - registry-url: https://npm.pkg.github.com/ - - - name: Configure git - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" + registry-url: ${{ matrix.registry-url }} + scope: '@lizardbyte' - name: Update package.json run: | - npm version ${{ needs.setup_release.outputs.release_version }} + npm version ${{ needs.setup_release.outputs.release_version }} --no-git-tag-version - name: Install dependencies run: npm install @@ -117,7 +121,17 @@ jobs: - name: Build run: npm run build + - name: Set token + id: token + run: | + # if github registry, use GITHUB_TOKEN + if [ "${{ matrix.registry-url }}" == "https://npm.pkg.github.com" ]; then + echo "NODE_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT + else + echo "NODE_AUTH_TOKEN=${{ secrets.NPM_TOKEN }}" >> $GITHUB_OUTPUT + fi + - name: Publish - run: npm publish + run: npm publish ${{ matrix.extra-args }} env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ steps.token.outputs.NODE_AUTH_TOKEN }} diff --git a/README.md b/README.md index bb5b074..115119a 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,29 @@ Common web assets for use in LizardByte projects. ## Installation -1. Add a `.npmrc` file to the root of your project with the following line: + +### Install via NPM registry + +1. Add the dependency to your package.json file: + ```bash + npm install @lizardbyte/shared-web ``` + +### Install via GitHub Package Registry + +1. Add a `.npmrc` file to the root of your project with the following contents. + ``` + //npm.pkg.github.com/:_authToken=TOKEN @lizardbyte:registry=https://npm.pkg.github.com ``` + + Replace `TOKEN` with a valid GitHub token with read access to the package registry. + + See + [Authenticating with a personal access token](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token) + for more information or alternative methods of authentication. 2. Add the dependency to your package.json file: ```bash - npm install LizardByte/shared-web + npm install @lizardbyte/shared-web ``` diff --git a/package.json b/package.json index 906560f..ac728e2 100644 --- a/package.json +++ b/package.json @@ -47,9 +47,6 @@ ], "testEnvironment": "jsdom" }, - "publishConfig": { - "registry": "https://npm.pkg.github.com" - }, "scripts": { "build": "cross-env NODE_ENV=production webpack", "start": "webpack serve",