Skip to content

Commit c355fba

Browse files
committed
chore: proper setup linked versions
1 parent dd7fee8 commit c355fba

File tree

3 files changed

+183
-11
lines changed

3 files changed

+183
-11
lines changed

.github/workflows/release-please.yml

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
outputs:
1717
releases_created: ${{ steps.release.outputs.releases_created }}
1818
paths_released: ${{ steps.release.outputs.paths_released }}
19+
pr_created: ${{ steps.release.outputs.pr_created }}
20+
pr_number: ${{ steps.release.outputs.pr_number }}
1921
steps:
2022
- name: Release Please
2123
id: release
@@ -26,6 +28,59 @@ jobs:
2628
manifest-file: .release-please-manifest.json
2729
token: ${{ secrets.GITHUB_TOKEN }}
2830

31+
update-dependencies:
32+
needs: release-please
33+
if: needs.release-please.outputs.pr_created == 'true'
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout PR branch
37+
uses: actions/checkout@v4
38+
with:
39+
token: ${{ secrets.GITHUB_TOKEN }}
40+
ref: release-please--branches--${{ github.ref_name }}
41+
42+
- name: Setup Dart
43+
uses: dart-lang/setup-dart@v1
44+
with:
45+
sdk: stable
46+
47+
- name: Setup Flutter
48+
uses: subosito/flutter-action@v2
49+
with:
50+
flutter-version: 'stable'
51+
channel: 'stable'
52+
53+
- name: Get Dart dependencies
54+
run: dart pub global activate melos
55+
56+
- name: Bootstrap workspace
57+
run: melos bootstrap
58+
59+
- name: Update dependency versions using melos
60+
run: |
61+
# Run melos version in dry-run to update dependency versions in pubspec.yaml
62+
# This will update dependencies between packages to match new versions
63+
echo "Updating dependency versions..."
64+
65+
# Read the current versions and update dependencies manually
66+
node scripts/update-dependencies.js
67+
68+
- name: Configure git
69+
run: |
70+
git config --global user.name "github-actions[bot]"
71+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
72+
73+
- name: Commit dependency updates
74+
run: |
75+
if git diff --quiet; then
76+
echo "No dependency updates needed"
77+
else
78+
git add packages/*/pubspec.yaml
79+
git commit -m "chore: update package dependencies"
80+
git push origin release-please--branches--${{ github.ref_name }}
81+
echo "Pushed dependency updates to release PR"
82+
fi
83+
2984
publish:
3085
needs: release-please
3186
if: needs.release-please.outputs.releases_created == 'true'
@@ -51,12 +106,6 @@ jobs:
51106
- name: Bootstrap workspace
52107
run: melos bootstrap
53108

54-
# - name: Run version update hook
55-
# run: melos run update-version
56-
57-
# - name: Run tests
58-
# run: melos run test --no-select
59-
60109
- name: Setup pub credentials
61110
run: |
62111
mkdir -p ~/.config/dart

release-please-config.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,19 @@
4848
"changelog-path": "CHANGELOG.md",
4949
"extra-files": [
5050
"lib/src/version.dart"
51-
]
51+
],
52+
"bump-minor-pre-major": true,
53+
"bump-patch-for-minor-pre-major": true
5254
},
5355
"packages/supabase_flutter": {
5456
"release-type": "dart",
5557
"package-name": "supabase_flutter",
5658
"changelog-path": "CHANGELOG.md",
5759
"extra-files": [
5860
"lib/src/version.dart"
59-
]
61+
],
62+
"bump-minor-pre-major": true,
63+
"bump-patch-for-minor-pre-major": true
6064
},
6165
"packages/yet_another_json_isolate": {
6266
"release-type": "dart",
@@ -67,7 +71,7 @@
6771
"plugins": [
6872
{
6973
"type": "linked-versions",
70-
"group-name": "supabase-flutter-packages",
74+
"group-name": "supabase-packages",
7175
"components": [
7276
"packages/functions_client",
7377
"packages/gotrue",
@@ -77,7 +81,9 @@
7781
"packages/supabase",
7882
"packages/supabase_flutter",
7983
"packages/yet_another_json_isolate"
80-
]
84+
],
85+
"groupPullRequestTitlePattern": "chore(release): release packages"
8186
}
82-
]
87+
],
88+
"sequential-calls": true
8389
}

scripts/update-dependencies.js

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const { execSync } = require('child_process');
6+
7+
// Package dependency map - defines which packages depend on which
8+
const DEPENDENCY_MAP = {
9+
'supabase': [
10+
'functions_client',
11+
'gotrue',
12+
'postgrest',
13+
'realtime_client',
14+
'storage_client',
15+
'yet_another_json_isolate'
16+
],
17+
'supabase_flutter': [
18+
'supabase'
19+
]
20+
};
21+
22+
// Read package version from pubspec.yaml
23+
function getPackageVersion(packagePath) {
24+
const pubspecPath = path.join(packagePath, 'pubspec.yaml');
25+
const pubspec = fs.readFileSync(pubspecPath, 'utf8');
26+
const match = pubspec.match(/^version:\s+(.+)$/m);
27+
return match ? match[1].trim() : null;
28+
}
29+
30+
// Update dependency version in pubspec.yaml
31+
function updateDependencyVersion(packagePath, depName, newVersion) {
32+
const pubspecPath = path.join(packagePath, 'pubspec.yaml');
33+
let pubspec = fs.readFileSync(pubspecPath, 'utf8');
34+
35+
// Update dependency version (exact match)
36+
const regex = new RegExp(`(\\s+${depName}:\\s+)([\\d\\.]+)`, 'g');
37+
const updated = pubspec.replace(regex, `$1${newVersion}`);
38+
39+
if (updated !== pubspec) {
40+
fs.writeFileSync(pubspecPath, updated);
41+
console.log(`Updated ${depName} to ${newVersion} in ${packagePath}`);
42+
return true;
43+
}
44+
45+
return false;
46+
}
47+
48+
// Check if any package has been updated by looking at git diff
49+
function getUpdatedPackages() {
50+
try {
51+
const diff = execSync('git diff --name-only HEAD~1', { encoding: 'utf8' });
52+
const updatedPackages = new Set();
53+
54+
diff.split('\\n').forEach(file => {
55+
const match = file.match(/^packages\/([^\/]+)\//);
56+
if (match) {
57+
updatedPackages.add(match[1]);
58+
}
59+
});
60+
61+
return Array.from(updatedPackages);
62+
} catch (error) {
63+
console.log('Could not determine updated packages, assuming all may need updates');
64+
return Object.keys(DEPENDENCY_MAP).concat(['functions_client', 'gotrue', 'postgrest', 'realtime_client', 'storage_client', 'yet_another_json_isolate']);
65+
}
66+
}
67+
68+
function main() {
69+
console.log('Updating package dependencies...');
70+
71+
const packagesDir = 'packages';
72+
const updatedPackages = getUpdatedPackages();
73+
let hasChanges = false;
74+
75+
// For each package that depends on others
76+
Object.entries(DEPENDENCY_MAP).forEach(([packageName, dependencies]) => {
77+
const packagePath = path.join(packagesDir, packageName);
78+
79+
if (!fs.existsSync(packagePath)) {
80+
console.log(`Package ${packageName} not found, skipping`);
81+
return;
82+
}
83+
84+
// Check if any of its dependencies were updated
85+
const updatedDeps = dependencies.filter(dep => updatedPackages.includes(dep));
86+
87+
if (updatedDeps.length === 0) {
88+
console.log(`No dependency updates needed for ${packageName}`);
89+
return;
90+
}
91+
92+
console.log(`Updating dependencies for ${packageName}: ${updatedDeps.join(', ')}`);
93+
94+
// Update each dependency to its new version
95+
updatedDeps.forEach(depName => {
96+
const depPath = path.join(packagesDir, depName);
97+
const newVersion = getPackageVersion(depPath);
98+
99+
if (newVersion) {
100+
const updated = updateDependencyVersion(packagePath, depName, newVersion);
101+
if (updated) {
102+
hasChanges = true;
103+
}
104+
}
105+
});
106+
});
107+
108+
if (hasChanges) {
109+
console.log('Dependencies updated, changes will be committed automatically');
110+
} else {
111+
console.log('No dependency updates were needed');
112+
}
113+
}
114+
115+
if (require.main === module) {
116+
main();
117+
}

0 commit comments

Comments
 (0)