Skip to content

Commit

Permalink
fix: release
Browse files Browse the repository at this point in the history
  • Loading branch information
joelcox22 committed Apr 14, 2024
1 parent 3976015 commit 0b1048c
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: yarn
run: yarn
- name: release
run: yarn workspaces run semantic-release -e semantic-release-monorepo
run: yarn release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
10 changes: 9 additions & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@joelbot/eslint-config",
"version": "0.0.0",
"private": true,
"private": false,
"main": "index.js",
"description": "A personal opinionated eslint configuration.",
"author": "Joel Cox <[email protected]>",
Expand Down Expand Up @@ -31,5 +31,13 @@
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"publishConfig": {
"access": "public"
},
"release": {
"branches": [
"main"
]
}
}
10 changes: 9 additions & 1 deletion packages/lint/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@joelbot/lint",
"version": "0.0.0",
"private": true,
"private": false,
"main": "index.js",
"description": "A personal opinionated linting tool.",
"keywords": [
Expand Down Expand Up @@ -30,5 +30,13 @@
},
"engines": {
"node": ">=18"
},
"publishConfig": {
"access": "public"
},
"release": {
"branches": [
"main"
]
}
}
47 changes: 47 additions & 0 deletions packages/release/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env node

import * as fs from 'fs';
import * as cp from 'child_process';
import root from 'app-root-path';
import Debug from 'debug';

const debug = Debug(`@joelbot/release`);

debug('running in directory', process.cwd());
debug('project root directory is', root.path);

if (!fs.existsSync('package.json')) {
debug('package.json does not exist, doing nothing');
process.exit(0);
}

const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));

if (packageJson.workspaces) {
debug('running in a workspace, looping through workspaces and re-running release');
const result = cp.spawnSync('yarn', ['workspaces', 'run', 'release'], {
stdio: 'inherit',
});
process.exit(result.status);
}

if (packageJson.publishConfig?.access !== 'public') {
debug('publishConfig.access is not public, doing nothing');
process.exit(0);
}

debug('publishConfig.access is public, running semantic-release');

if (process.cwd() !== root.path) {
debug('running in a workspace folder, using semantic-release-monorepo');
const result = cp.spawnSync('yarn', ['semantic-release', '-e', 'semantic-release-monorepo'], {
stdio: 'inherit',
});
process.exit(result.status);
} else {
debug('running semantic-release in project root');
const result = cp.spawnSync('yarn', ['semantic-release'], {
stdio: 'inherit',
});
process.exit(result.status);
}
17 changes: 17 additions & 0 deletions packages/release/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@joelbot/release",
"version": "0.0.0",
"private": true,
"main": "index.js",
"description": "An opinionated semantic-release wrapper / helper tool for my personal projects.",
"author": "Joel Cox <[email protected]>",
"license": "0BSD",
"type": "module",
"dependencies": {
"app-root-path": "^3.1.0",
"debug": "^4.3.4"
},
"bin": {
"release": "index.js"
}
}

0 comments on commit 0b1048c

Please sign in to comment.