Skip to content

Commit

Permalink
feat(ci): setup lerna for workspace publishing (#160)
Browse files Browse the repository at this point in the history
* ci: setup lerna for workspace publishing

* build: define repositories for each package

* ci: run TS build before electron

* chore: specify category for electron app

* chore: use yml config for electron-builder

* ci: build only dependencies before electron-build
  • Loading branch information
mirceanis authored Sep 26, 2023
1 parent 32894be commit 45b2603
Show file tree
Hide file tree
Showing 10 changed files with 1,949 additions and 223 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build-test-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: build-test-on-pr
on: [ pull_request, workflow_dispatch ]
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
with:
version: 8

- name: 'Setup Node.js with pnpm cache'
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
- run: pnpm add -g pnpm

- run: pnpm install
- run: pnpm run build
- run: pnpm run test

build-electron:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
with:
version: 8

- name: 'Setup Node.js with pnpm cache'
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
- run: pnpm add -g pnpm

- run: pnpm install
- run: pnpm run -r --filter "agent-explorer^..." build # only the dependencies of agent-explorer

- name: Build Electron app
uses: paneron/action-electron-builder@v1.8.1
with:
github_token: ${{ secrets.GH_TOKEN }}
package_root: "./packages/agent-explorer"
build_script_name: build-electron
package_manager: pnpm
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
name: Test, Build and Publish
name: build-test-publish-on-push
on:
workflow_dispatch:
push:
branches:
- 'main'
- 'next'

jobs:
build-test-publish:
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
GH_TOKEN: ${{secrets.GH_TOKEN}}
GITHUB_TOKEN: ${{secrets.GH_TOKEN}}
GH_USER: ${{secrets.GH_USER}}
GH_EMAIL: ${{secrets.GH_EMAIL}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- uses: pnpm/action-setup@v2
with:
version: 7
- name: Use Node.js
version: 8
- run: pnpm add -g pnpm
- name: 'Setup Node.js with pnpm cache'
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
- run: pnpm add -g pnpm
- run: pnpm install
- run: pnpm test
- run: pnpm build

- name: 'setup git coordinates'
- run: pnpm run build
- run: pnpm run test
- name: 'Setup git coordinates'
run: |
git remote set-url origin https://veramolabs:$GH_TOKEN@github.com/veramolabs/agent-explorer.git
git remote set-url origin https://${{secrets.GH_USER}}:${{secrets.GH_TOKEN}}@github.com/veramolabs/agent-explorer.git
git config user.name $GH_USER
git config user.email $GH_EMAIL
Expand All @@ -42,9 +46,14 @@ jobs:
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm whoami
- name: 'publish'
- name: 'Publish @latest when on main'
if: github.ref == 'refs/heads/main'
run: pnpm release
run: pnpm publish:latest

- name: 'Publish @next when on next'
if: github.ref == 'refs/heads/next'
run: pnpm publish:next

release-electron:
needs: build-test-publish
env:
Expand All @@ -59,28 +68,28 @@ jobs:
os: [macos-latest, ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
ref: main

- uses: pnpm/action-setup@v2
with:
version: 7
- name: Use Node.js
version: 8

- name: 'Setup Node.js with pnpm cache'
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
- run: pnpm add -g pnpm

- run: pnpm install
- run: pnpm run -r --filter "agent-explorer^..." build # only the dependencies of agent-explorer

- name: Build/release Electron app
uses: paneron/action-electron-builder@v1.8.1
with:
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.GH_TOKEN }}

# If the commit is tagged with a version (e.g. "v1.0.0"),
Expand All @@ -89,4 +98,3 @@ jobs:
package_root: "./packages/agent-explorer"
build_script_name: build-electron
package_manager: pnpm

22 changes: 0 additions & 22 deletions .github/workflows/test-pr.yml

This file was deleted.

6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ coverage
.eslintcache

# production
build
build/
dist/

# misc
.DS_Store
Expand All @@ -23,4 +24,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

.idea/
.idea/
tsconfig.tsbuildinfo
20 changes: 20 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.37.0",
"npmClient": "pnpm",
"changelog": {
"repo": "veramolabs/agent-explorer",
"cacheDir": ".changelog"
},
"command": {
"publish": {
"allowBranch": [
"main",
"next",
"unstable"
],
"conventionalCommits": true,
"gitRemote": "origin",
"message": "chore(release): %s [skip ci]"
}
}
}
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
{
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/veramolabs/agent-explorer.git"
},
"scripts": {
"build": "pnpm -r build",
"test": "pnpm -r test",
"release": "pnpm -r --workspace-concurrency=1 exec -- npx --no-install semantic-release -e semantic-release-monorepo"
"publish:latest": "lerna publish --conventional-commits --include-merged-tags --create-release github --yes --dist-tag latest --registry \"https://registry.npmjs.org/:_authToken=${NPM_TOKEN}\"",
"publish:next": "lerna publish --conventional-prerelease --force-publish --canary --no-git-tag-version --include-merged-tags --preid next --pre-dist-tag next --yes --registry \"https://registry.npmjs.org/:_authToken=${NPM_TOKEN}\""
},
"devDependencies": {
"lerna": "7.3.0",
"lerna-changelog": "2.2.0"
}
}
}
16 changes: 16 additions & 0 deletions packages/agent-explorer/electron-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
appId: io.veramo.explore
mac:
category: public.app-category.developer-tools
linux:
category: Development
publish:
- provider: github
releaseType: release
files:
- build/**/*
- node_modules/**/*
- electron/**/*
directories:
buildResources: assets
icon: AppIcon.icns
productName: Agent Explorer
63 changes: 10 additions & 53 deletions packages/agent-explorer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"name": "agent-explore",
"description": "Explore data accross multiple DID agents",
"name": "agent-explorer",
"description": "Explore data across multiple DID agents",
"homepage": "https://explore.veramo.dev",
"repository": {
"type": "git",
"url": "https://github.com/veramolabs/agent-explorer.git",
"directory": "packages/agent-explorer"
},
"author": "Simonas Karuzas <simonas.karuzas@mesh.xyz>",
"contributors": [
"Mircea Nistor <mircea.nistor@mesh.xyz>",
Expand All @@ -22,28 +28,6 @@
"exports": {
".": "./lib/express-router.js"
},
"build": {
"appId": "io.veramo.explore",
"mac": {
"category": "your.app.category.type"
},
"publish": [
{
"provider": "github",
"releaseType": "release"
}
],
"files": [
"build/**/*",
"node_modules/**/*",
"electron/**/*"
],
"directories": {
"buildResources": "assets"
},
"icon": "AppIcon.icns",
"productName": "Agent Explorer"
},
"bin": {
"agent-explore": "./bin/bin.js"
},
Expand All @@ -61,7 +45,6 @@
"electron-dist": "electron-builder",
"lint": "eslint ./src"
},
"homepage": "https://explore.veramo.dev",
"prettier": {
"jsxBracketSameLine": false,
"trailingComma": "all",
Expand Down Expand Up @@ -96,28 +79,6 @@
"express": "^4.18.2",
"express-favicon": "^2.0.4"
},
"release": {
"branches": [
"main"
],
"ci": true,
"extends": "semantic-release-monorepo",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": [
"package.json"
],
"message": "chore(release): :rocket: New version ${nextRelease.version} [skip ci] \n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
},
"devDependencies": {
"@ant-design/icons": "^5.1.4",
"@ant-design/pro-components": "^2.6.13",
Expand All @@ -129,10 +90,6 @@
"@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^7.0.2",
"@ethersproject/providers": "^5.7.2",
"@semantic-release/commit-analyzer": "^10.0.1",
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^10.0.4",
"@semantic-release/release-notes-generator": "^11.0.4",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
Expand Down Expand Up @@ -182,8 +139,8 @@
"crypto": "npm:crypto-browserify@^3.12.0",
"date-fns": "^2.30.0",
"did-resolver": "^4.1.0",
"electron": "^26.0.0",
"electron-builder": "^24.6.3",
"electron": "26.2.2",
"electron-builder": "24.6.4",
"eslint": "^8.47.0",
"ethr-did-resolver": "^8.0.0",
"https-browserify": "^1.0.0",
Expand Down
Loading

0 comments on commit 45b2603

Please sign in to comment.