Merge pull request #98 from mj-studio-library/develop #95
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
push: | |
branches: | |
- main | |
- alpha | |
jobs: | |
publish-packages: | |
name: Publish packages to NPM | |
if: ${{ github.actor != 'github-actions[bot]' && github.event.pusher.name != 'github-actions[bot]' }} | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
fetch-depth: '0' | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Set node version | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: 'https://registry.npmjs.org/' | |
- name: Set git config | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Cache dependencies | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: yarn install --immutable | |
- name: Cache Example dependencies | |
id: cache-example | |
uses: actions/cache@v3 | |
with: | |
path: 'example/node_modules' | |
key: ${{ runner.os }}-node-${{ hashFiles('example/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ hashFiles('example/yarn.lock') }} | |
${{ runner.os }}-node- | |
- name: Install Example dependencies | |
if: steps.cache-example.outputs.cache-hit != 'true' | |
working-directory: example | |
run: yarn install --immutable | |
- name: Cache Doc dependencies | |
id: cache-doc | |
uses: actions/cache@v3 | |
with: | |
path: 'doc/node_modules' | |
key: ${{ runner.os }}-node-${{ hashFiles('doc/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ hashFiles('doc/yarn.lock') }} | |
${{ runner.os }}-node- | |
- name: Install Doc dependencies | |
if: steps.cache-doc.outputs.cache-hit != 'true' | |
working-directory: doc | |
run: yarn install --immutable | |
- name: Build Docs | |
working-directory: doc | |
run: yarn build | |
- name: Deploy Docs | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GH_TOKEN }} | |
publish_dir: ./doc/build | |
user_name: github-actions[bot] | |
user_email: 41898282+github-actions[bot]@users.noreply.github.com | |
- name: Check | |
run: yarn check:all | |
- name: Version | |
run: yarn pub:version | |
- name: 'NPM Identity' | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc | |
cat .npmrc | |
- name: Publish | |
run: yarn pub:release |