Skip to content

Commit

Permalink
refactor: use lerna to manage monorepo (#64)
Browse files Browse the repository at this point in the history
* refactor: use lerna to manage monorepo

* fix: amend lerna arguments in github action

* ci: update install and publish commands

* chore: update package-lock
  • Loading branch information
neodmy authored Apr 27, 2023
1 parent 0c64480 commit 9922cb7
Show file tree
Hide file tree
Showing 7 changed files with 19,389 additions and 5,932 deletions.
70 changes: 6 additions & 64 deletions .github/workflows/cuckoojs-schematics-npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,8 @@ on:
types: [ published ]

jobs:
check-cuckoojs-schematics-version:
publish-npm-packages:
runs-on: ubuntu-latest
outputs:
version-changed: ${{ steps.version-changed.outputs.version-changed }}
steps:
- name: Check-out the repository
uses: actions/checkout@v3
- name: Check version changes
uses: EndBug/version-check@v2
id: version-changed
with:
file-name: ./packages/@guidesmiths/cuckoojs-schematics/package.json

publish-npm-cuckoojs-schematics:
runs-on: ubuntu-latest
needs: check-cuckoojs-schematics-version
steps:
- name: Check-out the repository
uses: actions/checkout@v3
- name: Setup node version 18
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Install dependencies
run: npm i -w @guidesmiths/cuckoojs-schematics
- name: Build artifact
run: npm run build -w @guidesmiths/cuckoojs-schematics
- name: Publish package to npm
if: ${{ needs.check-cuckoojs-schematics-version.outputs.version-changed }} === "true"
run: npm publish --ignore-scripts --access public -w @guidesmiths/cuckoojs-schematics
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_GUIDESMITHS }}

check-cuckoojs-cli-version:
runs-on: ubuntu-latest
outputs:
version-changed: ${{ steps.version-changed.outputs.version-changed }}
steps:
- name: Check-out the repository
uses: actions/checkout@v3
- name: Check version changes
uses: EndBug/version-check@v2
id: version-changed
with:
file-name: ./packages/@guidesmiths/cuckoojs-cli/package.json

publish-npm-cuckoojs-cli:
runs-on: ubuntu-latest
needs: [check-cuckoojs-cli-version, publish-npm-cuckoojs-schematics]
if: ${{ needs.check-cuckoojs-cli-version.outputs.version-changed }} === "true"
steps:
- name: Check-out the repository
uses: actions/checkout@v3
Expand All @@ -83,10 +25,10 @@ jobs:
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- name: Install dependencies
run: npm i -w @guidesmiths/cuckoojs-cli
- name: Build artifact
run: npm run build -w @guidesmiths/cuckoojs-cli
- name: Publish package to npm
run: npm publish --ignore-scripts --access public -w @guidesmiths/cuckoojs-cli
run: npm ci
- name: Build artifacts
run: npm run build
- name: Publish packages to npm
run: lerna publish from-git --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_GUIDESMITHS }}
5 changes: 5 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "0.0.0"
}
23 changes: 23 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"build",
"test"
]
}
}
},
"targetDefaults": {
"build": {
"dependsOn": [
"^build"
],
"outputs": [
"{projectRoot}/dist"
]
}
}
}
Loading

0 comments on commit 9922cb7

Please sign in to comment.