Skip to content

Commit bde87a3

Browse files
committed
chore: simplify release workflow, set version to 0.1.1
1 parent cbfd4b5 commit bde87a3

6 files changed

Lines changed: 113 additions & 27 deletions

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ name: Release
33
on:
44
workflow_dispatch:
55
inputs:
6-
version:
7-
description: 'Version bump type'
8-
required: true
9-
type: choice
10-
options:
11-
- patch
12-
- minor
13-
- major
146
dry_run:
157
description: 'Dry run (no publish)'
168
required: false
@@ -55,27 +47,34 @@ jobs:
5547
- name: Run tests
5648
run: pnpm test
5749

58-
- name: Bump version
59-
run: |
60-
# Bump version in all packages
61-
pnpm -r exec -- npm version ${{ inputs.version }} --no-git-tag-version
62-
63-
# Also bump root package.json
64-
npm version ${{ inputs.version }} --no-git-tag-version
65-
66-
- name: Get new version
50+
- name: Get version
6751
id: version
6852
run: |
6953
VERSION=$(node -p "require('./package.json').version")
7054
echo "version=$VERSION" >> $GITHUB_OUTPUT
55+
echo "Publishing version: $VERSION"
56+
57+
- name: Check version consistency
58+
run: |
59+
ROOT_VERSION=$(node -p "require('./package.json').version")
60+
SDK_VERSION=$(node -p "require('./packages/sdk/package.json').version")
61+
X402_VERSION=$(node -p "require('./packages/x402/package.json').version")
62+
63+
echo "Root version: $ROOT_VERSION"
64+
echo "SDK version: $SDK_VERSION"
65+
echo "x402 version: $X402_VERSION"
7166
72-
- name: Commit version bump
67+
if [ "$ROOT_VERSION" != "$SDK_VERSION" ] || [ "$ROOT_VERSION" != "$X402_VERSION" ]; then
68+
echo "::error::Version mismatch! All package.json files must have the same version."
69+
echo "Please run: npm version <patch|minor|major>"
70+
exit 1
71+
fi
72+
73+
- name: Create git tag
7374
if: ${{ !inputs.dry_run }}
7475
run: |
75-
git add .
76-
git commit -m "chore: release v${{ steps.version.outputs.version }}"
7776
git tag "v${{ steps.version.outputs.version }}"
78-
git push origin main --tags
77+
git push origin "v${{ steps.version.outputs.version }}"
7978
8079
- name: Configure npm for Trusted Publishing
8180
run: |
@@ -108,8 +107,13 @@ jobs:
108107
run: |
109108
echo "## Dry Run Summary" >> $GITHUB_STEP_SUMMARY
110109
echo "" >> $GITHUB_STEP_SUMMARY
111-
echo "Would have released version: **v${{ steps.version.outputs.version }}**" >> $GITHUB_STEP_SUMMARY
110+
echo "Current version in package.json: **v${{ steps.version.outputs.version }}**" >> $GITHUB_STEP_SUMMARY
112111
echo "" >> $GITHUB_STEP_SUMMARY
113-
echo "### Packages" >> $GITHUB_STEP_SUMMARY
112+
echo "### Would publish:" >> $GITHUB_STEP_SUMMARY
114113
echo "- @moneymq/sdk@${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
115114
echo "- @moneymq/x402@${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
115+
echo "" >> $GITHUB_STEP_SUMMARY
116+
echo "### To release:" >> $GITHUB_STEP_SUMMARY
117+
echo "1. Bump version: \`npm version patch\` (auto-syncs to all packages)" >> $GITHUB_STEP_SUMMARY
118+
echo "2. Push: \`git push && git push --tags\`" >> $GITHUB_STEP_SUMMARY
119+
echo "3. Run this workflow again with dry_run disabled" >> $GITHUB_STEP_SUMMARY

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,41 @@ pnpm lint
224224
pnpm format
225225
```
226226

227+
## Releasing
228+
229+
Releases are managed via GitHub Actions with npm Trusted Publishing.
230+
231+
### Version Bumping
232+
233+
All packages share the same version. When you bump the root version, all packages are automatically synced:
234+
235+
```bash
236+
# Bump version (patch, minor, or major)
237+
npm version patch
238+
239+
# Push the commit and tag
240+
git push && git push --tags
241+
```
242+
243+
The `npm version` command automatically:
244+
1. Updates the root `package.json` version
245+
2. Runs the sync script to update all packages in `packages/*/package.json`
246+
3. Creates a git commit and tag
247+
248+
### Publishing to npm
249+
250+
1. After pushing the version bump, go to [GitHub Actions](https://github.com/txtx/moneymq-js/actions/workflows/release.yml)
251+
2. Click "Run workflow"
252+
3. Optionally enable "Dry run" to test without publishing
253+
4. Click "Run workflow" to start the release
254+
255+
The workflow will:
256+
- Build and test all packages
257+
- Validate version consistency across packages
258+
- Create a git tag (if not already created)
259+
- Publish `@moneymq/sdk` and `@moneymq/x402` to npm with provenance
260+
- Create a GitHub Release with auto-generated release notes
261+
227262
## Contributing
228263

229264
See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "moneymq-js",
3-
"version": "0.1.8",
3+
"version": "0.1.1",
44
"private": true,
5+
"type": "module",
56
"description": "MoneyMQ JavaScript SDK for accepting stablecoin payments",
67
"repository": {
78
"type": "git",
@@ -24,7 +25,8 @@
2425
"test:coverage": "vitest run --coverage",
2526
"typecheck": "turbo run typecheck",
2627
"clean": "turbo run clean",
27-
"prepublishOnly": "pnpm build"
28+
"prepublishOnly": "pnpm build",
29+
"version": "node scripts/sync-versions.js && git add packages/*/package.json"
2830
},
2931
"devDependencies": {
3032
"@eslint/js": "^9.17.0",

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@moneymq/sdk",
3-
"version": "0.1.8",
3+
"version": "0.1.1",
44
"description": "MoneyMQ SDK for accepting stablecoin payments",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

packages/x402/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@moneymq/x402",
3-
"version": "0.1.8",
3+
"version": "0.1.1",
44
"description": "x402 protocol integration for MoneyMQ",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

scripts/sync-versions.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Syncs the version from root package.json to all workspace packages.
5+
* This script runs automatically via the npm `version` lifecycle hook.
6+
*/
7+
8+
import { readFileSync, writeFileSync, readdirSync, statSync } from "fs";
9+
import { join, dirname } from "path";
10+
import { fileURLToPath } from "url";
11+
12+
const __dirname = dirname(fileURLToPath(import.meta.url));
13+
const rootDir = join(__dirname, "..");
14+
const packagesDir = join(rootDir, "packages");
15+
16+
// Read root package.json version
17+
const rootPkg = JSON.parse(readFileSync(join(rootDir, "package.json"), "utf8"));
18+
const version = rootPkg.version;
19+
20+
console.log(`Syncing version ${version} to all packages...`);
21+
22+
// Find all packages
23+
const packages = readdirSync(packagesDir).filter((name) => {
24+
const pkgPath = join(packagesDir, name);
25+
return (
26+
statSync(pkgPath).isDirectory() &&
27+
statSync(join(pkgPath, "package.json")).isFile()
28+
);
29+
});
30+
31+
// Update each package
32+
for (const pkg of packages) {
33+
const pkgJsonPath = join(packagesDir, pkg, "package.json");
34+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
35+
36+
if (pkgJson.version !== version) {
37+
pkgJson.version = version;
38+
writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + "\n");
39+
console.log(` Updated ${pkgJson.name} to ${version}`);
40+
} else {
41+
console.log(` ${pkgJson.name} already at ${version}`);
42+
}
43+
}
44+
45+
console.log("Done!");

0 commit comments

Comments
 (0)