Skip to content

Commit

Permalink
feat: switch to @anolilab/multi-semantic-release (#1450)
Browse files Browse the repository at this point in the history
Replaces semantic-release-monorepo with @anolilab/multi-semantic-release
as srm is abandonware.

Also updates semantic release deps and gets rid of forks due to ESM
support landing in semantic release upstream.
  • Loading branch information
achingbrain committed Jan 15, 2024
1 parent b8c8996 commit 5dbd120
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {
'playwright-test',
'react-native-test-runner',
'semantic-release',
'semantic-release-monorepo',
'@anolilab/multi-semantic-release',
'source-map-support',
'typedoc-plugin-mdn-links',
'typedoc-plugin-missing-exports',
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,15 @@
"release": "node src/index.js release --no-bundle"
},
"dependencies": {
"@anolilab/multi-semantic-release": "^1.0.3",
"@electron/get": "^3.0.0",
"@polka/send-type": "^0.5.2",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^10.0.1",
"@semantic-release/commit-analyzer": "^11.1.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^9.0.3",
"@semantic-release/npm": "^10.0.4",
"@semantic-release/release-notes-generator": "^11.0.4",
"@semantic-release/npm": "^11.0.2",
"@semantic-release/release-notes-generator": "^12.1.0",
"@types/chai": "^4.2.16",
"@types/chai-as-promised": "^7.1.3",
"@types/chai-string": "^1.4.2",
Expand All @@ -246,7 +247,7 @@
"chai-parentheses": "^0.0.2",
"chai-string": "^1.5.0",
"chai-subset": "^1.6.0",
"conventional-changelog-conventionalcommits": "^6.1.0",
"conventional-changelog-conventionalcommits": "^7.0.2",
"cors": "^2.8.5",
"depcheck": "^1.4.3",
"diff": "^5.1.0",
Expand Down Expand Up @@ -297,8 +298,7 @@
"react-native-test-runner": "^5.0.0",
"read-pkg-up": "^11.0.0",
"rimraf": "^5.0.0",
"semantic-release": "https://registry.npmjs.org/@achingbrain/semantic-release/-/semantic-release-21.0.9.tgz",
"semantic-release-monorepo": "https://registry.npmjs.org/@achingbrain/semantic-release-monorepo/-/semantic-release-monorepo-8.0.2.tgz",
"semantic-release": "^23.0.0",
"semver": "^7.3.8",
"source-map-support": "^0.5.20",
"strip-bom": "^5.0.0",
Expand Down
29 changes: 19 additions & 10 deletions src/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { execa } from 'execa'
import fs from 'fs-extra'
import Listr from 'listr'
import { calculateSiblingVersion } from './check-project/utils.js'
import { isMonorepoProject, hasDocs, glob } from './utils.js'
import { isMonorepoProject, isMonorepoRoot, hasDocs, glob } from './utils.js'

/**
* @typedef {import("./types").GlobalOptions} GlobalOptions
Expand All @@ -29,16 +29,25 @@ const tasks = new Listr([
* @param {GlobalOptions} ctx
*/
task: async (ctx) => {
let args = ctx['--'] ?? []

if (isMonorepoProject()) {
args = ['-e', 'semantic-release-monorepo', ...args]
const args = ctx['--'] ?? []

if (isMonorepoRoot()) {
await execa('multi-semantic-release', [
// eslint-disable-next-line no-template-curly-in-string
'--tag-format', '${name}-${version}',
'--deps.bump', 'satisfy',
'--deps.release', 'minor',
...args
], {
preferLocal: true,
stdio: 'inherit'
})
} else {
await execa('semantic-release', args, {
preferLocal: true,
stdio: 'inherit'
})
}

await execa('semantic-release', args, {
preferLocal: true,
stdio: 'inherit'
})
}
},
{
Expand Down
8 changes: 8 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ export const isMonorepoProject = (dir = process.cwd()) => {
return manifest?.packageJson.workspaces != null
}

export const isMonorepoRoot = (dir = process.cwd()) => {
const manifest = readPackageUpSync({
cwd: dir
})

return manifest?.packageJson.workspaces != null
}

export const usesReleasePlease = (dir = process.cwd()) => {
try {
const mainYmlPath = path.resolve(dir, '.github', 'workflows', 'main.yml')
Expand Down

0 comments on commit 5dbd120

Please sign in to comment.