Publish MoBrix-ui package #31
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 MoBrix-ui package | |
on: workflow_dispatch | |
jobs: | |
publish-mobrix-ui-package: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
echo "LATEST_VERSION=$(curl -s https://registry.npmjs.org/mobrix-ui/latest -H "Accept: application/json" | jq -r '.version')" >> "$GITHUB_ENV" | |
echo "PACKAGE_JSON_VERSION=$(cat package.json | jq -r '.version')" >> "$GITHUB_ENV" | |
echo "CHANGELOG_INDEX_VERSION=$(cat package.json | jq -r '.version' | tr -d .)" >> "$GITHUB_ENV" | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
registry-url: "https://registry.npmjs.org/" | |
always-auth: "true" | |
- name: Create release | |
run: | | |
npm ci | |
output=$(node ./scripts/ci/check-version.js) | |
if [ $output -eq 1 ]; then | |
echo "Creating release..." | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GH_ACCESS_TOKEN }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/CianciarusoCataldo/mobrix-ui/releases \ | |
-d '{"tag_name":"v${{ env.PACKAGE_JSON_VERSION }}","target_commitish":"main","name":"mobrix-ui-v${{ env.PACKAGE_JSON_VERSION }}","body":"Release notes available at https://cianciarusocataldo.github.io/mobrix-ui/docs/Changelog/#${{ env.CHANGELOG_INDEX_VERSION }}","draft":false,"prerelease":false,"generate_release_notes":false}' | |
else | |
echo "Not a minor or major version bump, release won't be created" | |
fi | |
- name: Publish to npm registry | |
run: | | |
npm run build | |
npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
registry-url: "https://npm.pkg.github.com" | |
scope: "@cianciarusocataldo" | |
always-auth: "true" | |
- name: Publish to github registry | |
run: | | |
npx --yes json -I -f package.json -e "this.name=\"@cianciarusocataldo/mobrix-ui\"" | |
npx --yes json -I -f package.json -e "this.publishConfig={\"registry\": \"https://npm.pkg.github.com\"}" | |
npm i | |
npm run build | |
npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} |