Skip to content

ci(packages): github action for build & release #41

ci(packages): github action for build & release

ci(packages): github action for build & release #41

Workflow file for this run

name: CI/CD
on:
push:
branches:
- main
- dev
- 'feat*'
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
environment: Production
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: dependencies cache
uses: actions/cache@v3
with:
path: |
~/.npm
~/.cache
~/node_modules
key: ${{ runner.os }}-dependencies-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Debug NPM_TOKEN
run: |
echo "NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}"
echo "NPM_TOKEN_EMPTY: ${{ secrets.NPM_TOKEN_EMPTY }}"
- name: Yarn install
run: yarn install
- name: Run Packages Tests
run: |
ls -la
# yarn run test skip
- name: Build Packages
run: |
npx lerna exec --scope='@pagenote/*' --no-private --include-dependencies yarn build
- name: Set Git Identity
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
#https://github.com/lerna/lerna/tree/main/libs/commands/version#semver-bump
- name: Lerna patch Version
if: github.ref != 'refs/heads/main'
run: |
npx lerna version prepatch --amend --conventional-commits --conventional-prerelease --yes
- name: Lerna main Version
if: github.ref == 'refs/heads/main'
run: |
npx lerna version --no-private minor --yes
- name: Create .npmrc
run: echo 'registry=https://registry.npmjs.org' > ~/.npmrc && echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> ~/.npmrc
# https://github.com/lerna/lerna/tree/main/libs/commands/publish#readme
- name: Publish to NPM
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main'
run: |
npx lerna publish from-git --yes
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}