@@ -21,14 +21,17 @@ jobs:
21
21
- name : Find package directories
22
22
id : set-matrix
23
23
run : |
24
+ # Find all package.json and pyproject.toml files, excluding root
24
25
DIRS=$(git ls-tree -r HEAD --name-only | grep -E "package.json|pyproject.toml" | xargs dirname | grep -v "^.$" | jq -R -s -c 'split("\n")[:-1]')
25
26
echo "matrix=${DIRS}" >> $GITHUB_OUTPUT
27
+ echo "Found directories: ${DIRS}"
26
28
27
29
- name : Get last release hash
28
30
id : last-release
29
31
run : |
30
32
HASH=$(git rev-list --tags --max-count=1 || echo "HEAD~1")
31
33
echo "hash=${HASH}" >> $GITHUB_OUTPUT
34
+ echo "Using last release hash: ${HASH}"
32
35
33
36
release :
34
37
needs : prepare
@@ -50,54 +53,122 @@ jobs:
50
53
- uses : astral-sh/setup-uv@v5
51
54
52
55
- name : Setup Node.js
53
- if : endsWith(matrix.directory, 'package.json')
56
+ if : endsWith(matrix.directory, '/ package.json')
54
57
uses : actions/setup-node@v4
55
58
with :
56
59
node-version : ' 18'
57
60
registry-url : ' https://registry.npmjs.org'
58
61
59
62
- name : Setup Python
60
- if : endsWith(matrix.directory, 'pyproject.toml')
63
+ if : endsWith(matrix.directory, '/ pyproject.toml')
61
64
run : uv python install
62
65
63
66
- name : Release package
67
+ id : release
64
68
env :
65
69
NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
66
70
UV_PUBLISH_TOKEN : ${{ secrets.PYPI_TOKEN }}
67
- run : uv run --script scripts/release.py "${{ matrix.directory }}" "${{ needs.prepare.outputs.last_release }}" >> "$GITHUB_OUTPUT"
71
+ run : |
72
+ # Create unique hash for this directory
73
+ dir_hash=$(echo "${{ matrix.directory }}" | sha256sum | awk '{print $1}')
74
+
75
+ # Run git diff first to show changes
76
+ echo "Changes since last release:"
77
+ git diff --name-only "${{ needs.prepare.outputs.last_release }}" -- "${{ matrix.directory }}" || true
78
+
79
+ # Run the release
80
+ output=$(uv run --script scripts/release.py "${{ matrix.directory }}" "${{ needs.prepare.outputs.last_release }}" 2>&1)
81
+ exit_code=$?
82
+
83
+ echo "Release output (exit code: $exit_code):"
84
+ echo "$output"
85
+
86
+ # Extract package info if successful
87
+ if [ $exit_code -eq 0 ]; then
88
+ pkg_info=$(echo "$output" | grep -o -E "[a-zA-Z0-9\-]+@[0-9]+\.[0-9]+\.[0-9]+" || true)
89
+ else
90
+ echo "Release failed"
91
+ exit 1
92
+ fi
93
+
94
+ if [ ! -z "$pkg_info" ]; then
95
+ echo "Released package: $pkg_info"
96
+
97
+ # Create outputs directory
98
+ mkdir -p ./outputs
99
+
100
+ # Save both package info and full changes
101
+ echo "$pkg_info" > "./outputs/${dir_hash}_info"
102
+ echo "dir_hash=${dir_hash}" >> $GITHUB_OUTPUT
103
+
104
+ # Log what we're saving
105
+ echo "Saved package info to ./outputs/${dir_hash}_info:"
106
+ cat "./outputs/${dir_hash}_info"
107
+ else
108
+ echo "No release needed for this package"
109
+ fi
68
110
69
- create-release :
111
+ - name : Set artifact name
112
+ if : steps.release.outputs.dir_hash
113
+ id : artifact
114
+ run : |
115
+ # Replace forward slashes with dashes
116
+ SAFE_DIR=$(echo "${{ matrix.directory }}" | tr '/' '-')
117
+ echo "name=release-outputs-${SAFE_DIR}" >> $GITHUB_OUTPUT
118
+
119
+ - uses : actions/upload-artifact@v4
120
+ if : steps.release.outputs.dir_hash
121
+ with :
122
+ name : ${{ steps.artifact.outputs.name }}
123
+ path : ./outputs/${{ steps.release.outputs.dir_hash }}*
124
+
125
+ create-tag :
70
126
needs : [prepare, release]
71
127
runs-on : ubuntu-latest
72
128
permissions :
73
129
contents : write
74
130
steps :
75
131
- uses : actions/checkout@v4
76
132
77
- - name : Create Release
133
+ - uses : actions/download-artifact@v4
134
+ with :
135
+ pattern : release-outputs-src-*
136
+ merge-multiple : true
137
+ path : outputs
138
+
139
+ - name : Create tag and release
78
140
env :
79
141
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
80
142
run : |
81
- # Check if there's output from release step
82
- if [ -s "$GITHUB_OUTPUT" ]; then
83
- DATE=$(date +%Y.%m.%d)
84
-
85
- # Create git tag
86
- git tag -s -a -m"automated release v${DATE}" "v${DATE}"
87
- git push origin "v${DATE}"
88
-
89
- # Create release notes
90
- echo "# Release ${DATE}" > notes.md
91
- echo "" >> notes.md
92
- echo "## Updated Packages" >> notes.md
93
-
94
- # Read updated packages from github output
95
- while IFS= read -r line; do
96
- echo "- ${line}" >> notes.md
97
- done < "$GITHUB_OUTPUT"
98
-
99
- # Create GitHub release
100
- gh release create "v${DATE}" \
101
- --title "Release ${DATE}" \
102
- --notes-file notes.md
103
- fi
143
+ if [ -d outputs ]; then
144
+ # Collect package info
145
+ find outputs -name "*_info" -exec cat {} \; > packages.txt
146
+
147
+ if [ -s packages.txt ]; then
148
+ DATE=$(date +%Y.%m.%d)
149
+ echo "Creating tag v${DATE}"
150
+
151
+ # Generate comprehensive release notes
152
+ {
153
+ echo "# Release ${DATE}"
154
+ echo ""
155
+ echo "## Updated Packages"
156
+ while IFS= read -r line; do
157
+ echo "- $line"
158
+ done < packages.txt
159
+ } > notes.md
160
+
161
+ # Create and push tag
162
+ git tag -a "v${DATE}" -m "Release ${DATE}"
163
+ git push origin "v${DATE}"
164
+
165
+ # Create GitHub release
166
+ gh release create "v${DATE}" \
167
+ --title "Release ${DATE}" \
168
+ --notes-file notes.md
169
+ else
170
+ echo "No packages need release"
171
+ fi
172
+ else
173
+ echo "No release artifacts found"
174
+ fi
0 commit comments