Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(publish): dual publish #14

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -100,24 +108,30 @@ 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

- 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 }}
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,37 @@
[![GitHub stars](https://img.shields.io/github/stars/lizardbyte/shared-web.svg?logo=github&style=for-the-badge)](https://github.com/LizardByte/shared-web)
[![GitHub Workflow Status (CI)](https://img.shields.io/github/actions/workflow/status/lizardbyte/shared-web/ci.yml.svg?branch=master&label=CI%20build&logo=github&style=for-the-badge)](https://github.com/LizardByte/shared-web/actions/workflows/CI.yml?query=branch%3Amaster)
[![Codecov](https://img.shields.io/codecov/c/gh/LizardByte/shared-web?token=gWHqqpMAuO&style=for-the-badge&logo=codecov&label=codecov)](https://codecov.io/gh/LizardByte/shared-web)
[![Downloads](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fipitio.github.io%2Fbackage%2FLizardByte%2Fshared-web%2Fshared-web.json&query=%24.downloads&label=downloads&style=for-the-badge&logo=npm)](https://github.com/LizardByte/Sunshine/pkgs/npm/shared-web)
[![NPM Version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fipitio.github.io%2Fbackage%2FLizardByte%2Fshared-web%2Fshared-web.json&query=%24.version%5B%3F(%40.latest%3D%3Dtrue)%5D.name&label=latest&style=for-the-badge&logo=npm)](https://github.com/LizardByte/Sunshine/pkgs/npm/shared-web)
[![NPM Monthly Downloads](https://img.shields.io/npm/dm/%40lizardbyte%2Fshared-web?style=for-the-badge&logo=npm&label=npm%20downloads/m)](https://www.npmjs.com/package/@lizardbyte/shared-web)
[![NPM Version](https://img.shields.io/npm/v/%40lizardbyte%2Fshared-web?style=for-the-badge&logo=npm&label=npm%20version)](https://www.npmjs.com/package/@lizardbyte/shared-web)
[![GitHub Monthly Downloads](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fipitio.github.io%2Fbackage%2FLizardByte%2Fshared-web%2Fshared-web.json&query=%24.downloads_month&label=github%20downloads/m&style=for-the-badge&logo=github%20actions)](https://github.com/LizardByte/Sunshine/pkgs/npm/shared-web)
[![GitHub Version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fipitio.github.io%2Fbackage%2FLizardByte%2Fshared-web%2Fshared-web.json&query=%24.version%5B%3F(%40.latest%3D%3Dtrue)%5D.name&label=gh%20version&style=for-the-badge&logo=github%20actions)](https://github.com/LizardByte/Sunshine/pkgs/npm/shared-web)

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
```
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
],
"testEnvironment": "jsdom"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com"
},
"scripts": {
"build": "cross-env NODE_ENV=production webpack",
"start": "webpack serve",
Expand Down