Publish package #943
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 package | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
- run: npm ci | |
- run: npm run build:package | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: mojds-package | |
path: package | |
- run: npm run build:dist | |
- run: ENV="production" npm run build:docs | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: mojds-dist | |
path: dist | |
test: | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x, 22.x] | |
steps: | |
- name: Set commit status as pending | |
uses: myrotvorets/set-commit-status-action@master | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
sha: ${{ github.sha }} | |
status: pending | |
context: Tests | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: npm install | |
run: npm install | |
- name: Lint Sass | |
run: npm run lint:scss | |
- name: Lint JavaScript | |
run: npm run lint:js | |
- name: Prettier | |
run: npm run lint:prettier | |
- name: JavaScript unit tests | |
run: npm run test:js | |
- name: Sass compilation | |
run: npm run test:scss | |
result: | |
runs-on: ubuntu-latest | |
needs: [test] | |
if: always() | |
steps: | |
- name: Set final commit status | |
uses: myrotvorets/set-commit-status-action@master | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
sha: ${{ github.sha }} | |
status: ${{ needs.test.result }} | |
context: Tests | |
publish: | |
runs-on: ubuntu-latest | |
needs: [result] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
- uses: actions/download-artifact@v4 | |
with: | |
name: mojds-package | |
path: package | |
- uses: actions/download-artifact@v4 | |
with: | |
name: mojds-dist | |
path: dist | |
- run: npm ci | |
- name: Publish to NPM | |
run: npm run ci:release | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.ADMIN_TOKEN }} |