@@ -98,24 +98,82 @@ jobs:
98
98
steps :
99
99
- uses : actions/checkout@v4
100
100
101
- - name : Create tag
101
+ - name : Install uv
102
+ uses : astral-sh/setup-uv@v5
103
+
104
+ - name : Install Node.js
105
+ uses : actions/setup-node@v4
106
+ with :
107
+ node-version : ' 20'
108
+
109
+ - name : Update package versions and create tag
102
110
env :
103
111
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
104
112
run : |
105
113
# Configure git
106
114
git config --global user.name "GitHub Actions"
107
115
git config --global user.email "[email protected] "
108
116
109
- # Get packages array
117
+ # Get packages array and version
110
118
PACKAGES='${{ needs.detect-packages.outputs.packages }}'
119
+ VERSION="${{ needs.create-tag-name.outputs.tag_name }}"
120
+ VERSION_NO_V="${VERSION#v}" # Remove 'v' prefix for package versions
111
121
112
- if [ "$(echo "$PACKAGES" | jq 'length')" -gt 0 ]; then
113
- # Create and push tag
114
- git tag -a "${{ needs.create-tag-name.outputs.tag_name }}" -m "Release ${{ needs.create-tag-name.outputs.tag_name }}"
115
- git push origin "${{ needs.create-tag-name.outputs.tag_name }}"
116
- else
117
- echo "No packages need release"
118
- fi
122
+ # Create version update script
123
+ cat << 'EOF' > update_versions.py
124
+ import json
125
+ import os
126
+ import sys
127
+ import toml
128
+ from pathlib import Path
129
+
130
+ def update_package_json(path, version):
131
+ with open(path) as f:
132
+ data = json.load(f)
133
+ data['version'] = version
134
+ with open(path, 'w') as f:
135
+ json.dump(data, f, indent=2)
136
+ f.write('\n')
137
+
138
+ def update_pyproject_toml(path, version):
139
+ data = toml.load(path)
140
+ if 'project' in data:
141
+ data['project']['version'] = version
142
+ elif 'tool' in data and 'poetry' in data['tool']:
143
+ data['tool']['poetry']['version'] = version
144
+ with open(path, 'w') as f:
145
+ toml.dump(data, f)
146
+
147
+ packages = json.loads(os.environ['PACKAGES'])
148
+ version = os.environ['VERSION']
149
+
150
+ for package_dir in packages:
151
+ package_dir = Path('src') / package_dir
152
+
153
+ # Update package.json if it exists
154
+ package_json = package_dir / 'package.json'
155
+ if package_json.exists():
156
+ update_package_json(package_json, version)
157
+
158
+ # Update pyproject.toml if it exists
159
+ pyproject_toml = package_dir / 'pyproject.toml'
160
+ if pyproject_toml.exists():
161
+ update_pyproject_toml(pyproject_toml, version)
162
+ EOF
163
+
164
+ # Install toml package for Python
165
+ uv pip install toml
166
+
167
+ # Update versions
168
+ PACKAGES="$PACKAGES" VERSION="$VERSION_NO_V" uv run update_versions.py
169
+
170
+ # Commit version updates
171
+ git add src/*/package.json src/*/pyproject.toml
172
+ git commit -m "chore: update package versions to $VERSION"
173
+
174
+ # Create and push tag
175
+ git tag -a "$VERSION" -m "Release $VERSION"
176
+ git push origin HEAD "$VERSION"
119
177
120
178
- name : Create release
121
179
env :
0 commit comments