You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve failure diagnostics for release actions (#59)
When things go wrong, it'd be nice if the messages were clearer about
what went wrong and how to remedy it.
This pull request:
- Adds richer environment dumps for JS and Python
- Adds annotations and additional messages for failure conditions so
that they appear prominently on the GHA workflow page (not just cryptic
"process exited with code 1")
echo "::error title=Dependency install failed::'pnpm install --frozen-lockfile' failed — the lockfile is likely out of sync with package.json (run 'pnpm install' and commit pnpm-lock.yaml)."
echo "::error title=npm publish failed::auth/ENEEDAUTH → the npm trusted publisher must list this repo, workflow, and (if gated) environment; 'cannot publish over <version>' → the version already exists on npm (bump it)."
219
+
exit 1
220
+
}
215
221
216
222
- name: Create GitHub release
217
223
shell: bash
@@ -404,7 +410,7 @@ runs:
404
410
if echo "$RESPONSE" | jq -e '.ok' > /dev/null 2>&1; then
echo "::error title=Dependency install failed::'pnpm install --frozen-lockfile' failed — the lockfile is likely out of sync with package.json (run 'pnpm install' and commit pnpm-lock.yaml)."
if [ -z "$VERSION" ] || [ "$VERSION" = "undefined" ]; then
154
+
echo "::error title=Could not read version::resolved an empty version — check the \"version\" field in package.json (or pass a version override)."
155
+
exit 1
156
+
fi
157
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
150
158
151
159
- name: Check npm version availability
152
160
shell: bash
@@ -165,15 +173,14 @@ runs:
165
173
"$REGISTRY/$PACKAGE_NAME/$VERSION")
166
174
case "$CODE" in
167
175
200)
168
-
echo "Error: $PACKAGE_NAME@$VERSION already exists on npm — has the version been bumped?"
176
+
echo "::error title=Version already published::$PACKAGE_NAME@$VERSION already exists on npm — has the version been bumped?"
169
177
exit 1
170
178
;;
171
179
404)
172
180
echo "$PACKAGE_NAME@$VERSION is available on npm."
173
181
;;
174
182
*)
175
-
echo "Error: unexpected response from the npm registry (HTTP $CODE) checking $PACKAGE_NAME@$VERSION;"
176
-
echo "cannot confirm the version is unpublished — aborting rather than risk a bad release."
183
+
echo "::error title=Registry check failed::unexpected response from the npm registry (HTTP $CODE) checking $PACKAGE_NAME@$VERSION — cannot confirm the version is unpublished; aborting rather than risk a bad release."
177
184
exit 1
178
185
;;
179
186
esac
@@ -188,7 +195,7 @@ runs:
188
195
for c in "${OK[@]}"; do
189
196
[ "$(echo "$c" | xargs)" = "$CHANNEL" ] && exit 0
190
197
done
191
-
echo "Error: release channel '$CHANNEL' is not in the allowed set: $ALLOWED"
198
+
echo "::error title=Release channel not allowed::release channel '$CHANNEL' is not in the allowed set: $ALLOWED"
192
199
exit 1
193
200
194
201
- name: Validate SHA format
@@ -197,7 +204,7 @@ runs:
197
204
SHA: ${{ inputs.sha }}
198
205
run: |
199
206
if ! echo "$SHA" | grep -qE '^[0-9a-f]{40}$'; then
200
-
echo "Error: sha must be a full 40-character commit SHA — branch names and short SHAs are not accepted."
207
+
echo "::error title=Invalid release SHA::sha must be a full 40-character commit SHA — branch names and short SHAs are not accepted."
201
208
exit 1
202
209
fi
203
210
@@ -217,9 +224,9 @@ runs:
217
224
218
225
if git rev-parse "$TAG" >/dev/null 2>&1; then
219
226
if [ "$DRY_RUN" = "true" ]; then
220
-
echo "Warning: Tag $TAG already exists — skipping in dry run"
227
+
echo "::warning title=Release tag already exists::Tag $TAG already exists — skipping in dry run."
221
228
else
222
-
echo "Error: Tag $TAG already exists — has the version been bumped?"
229
+
echo "::error title=Release tag already exists::Tag $TAG already exists — has the version been bumped?"
Copy file name to clipboardExpand all lines: actions/release/lang/py/publish/action.yml
+20-5Lines changed: 20 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -179,7 +179,10 @@ runs:
179
179
else
180
180
ARGS+=(--no-attestations)
181
181
fi
182
-
uv publish "${ARGS[@]}"
182
+
uv publish "${ARGS[@]}" || {
183
+
echo "::error title=PyPI publish failed::auth/OIDC error → the PyPI trusted publisher must list this repo, workflow, and (if gated) environment; a 400 'File already exists' → the version is already on PyPI (bump it)."
184
+
exit 1
185
+
}
183
186
184
187
- name: Create GitHub release
185
188
shell: bash
@@ -372,7 +375,7 @@ runs:
372
375
if echo "$RESPONSE" | jq -e '.ok' > /dev/null 2>&1; then
echo "cannot confirm the version is unpublished — aborting rather than risk a bad release."
149
+
echo "::error title=Registry check failed::unexpected response from PyPI (HTTP $CODE) checking $PACKAGE_NAME $VERSION — cannot confirm the version is unpublished; aborting rather than risk a bad release."
147
150
exit 1
148
151
;;
149
152
esac
@@ -154,7 +157,7 @@ runs:
154
157
SHA: ${{ inputs.sha }}
155
158
run: |
156
159
if ! echo "$SHA" | grep -qE '^[0-9a-f]{40}$'; then
157
-
echo "Error: sha must be a full 40-character commit SHA — branch names and short SHAs are not accepted."
160
+
echo "::error title=Invalid release SHA::sha must be a full 40-character commit SHA — branch names and short SHAs are not accepted."
158
161
exit 1
159
162
fi
160
163
@@ -174,9 +177,9 @@ runs:
174
177
175
178
if git rev-parse "$TAG" >/dev/null 2>&1; then
176
179
if [ "$DRY_RUN" = "true" ]; then
177
-
echo "Warning: Tag $TAG already exists — skipping in dry run"
180
+
echo "::warning title=Release tag already exists::Tag $TAG already exists — skipping in dry run."
178
181
else
179
-
echo "Error: Tag $TAG already exists — has the version been bumped?"
182
+
echo "::error title=Release tag already exists::Tag $TAG already exists — has the version been bumped?"
180
183
exit 1
181
184
fi
182
185
fi
@@ -228,5 +231,17 @@ runs:
228
231
echo "${UV_PYTHON:-(unset)}"
229
232
echo "=== Built artifacts ==="
230
233
ls -la dist 2>/dev/null || echo "(no dist/)"
231
-
echo "=== pyproject.toml ==="
232
-
head -40 pyproject.toml 2>/dev/null || echo "(no pyproject.toml)"
234
+
echo "=== pyproject.toml (release-relevant) ==="
235
+
uv run --no-project python -c '
236
+
import json, tomllib, pathlib
237
+
t = tomllib.loads(pathlib.Path("pyproject.toml").read_text())
238
+
proj = t.get("project", {})
239
+
print(json.dumps({
240
+
"name": proj.get("name"),
241
+
"version": proj.get("version") or ("(dynamic)" if "version" in proj.get("dynamic", []) else None),
242
+
"requires-python": proj.get("requires-python"),
243
+
"dependencies": proj.get("dependencies"),
244
+
"optional-dependencies": sorted((proj.get("optional-dependencies") or {}).keys()),
echo "::error title=Could not read version::resolved an empty version — check VERSION in $VERSION_FILE (module $VERSION_MODULE), or pass a version override."
echo "cannot confirm the version is unpublished — aborting rather than risk a bad release."
119
+
echo "::error title=Registry check failed::unexpected response from RubyGems (HTTP $CODE) checking $PACKAGE_NAME $VERSION — cannot confirm the version is unpublished; aborting rather than risk a bad release."
117
120
exit 1
118
121
;;
119
122
esac
@@ -124,7 +127,7 @@ runs:
124
127
SHA: ${{ inputs.sha }}
125
128
run: |
126
129
if ! echo "$SHA" | grep -qE '^[0-9a-f]{40}$'; then
127
-
echo "Error: sha must be a full 40-character commit SHA — branch names and short SHAs are not accepted."
130
+
echo "::error title=Invalid release SHA::sha must be a full 40-character commit SHA — branch names and short SHAs are not accepted."
128
131
exit 1
129
132
fi
130
133
@@ -144,9 +147,9 @@ runs:
144
147
145
148
if git rev-parse "$TAG" >/dev/null 2>&1; then
146
149
if [ "$DRY_RUN" = "true" ]; then
147
-
echo "Warning: Tag $TAG already exists — skipping in dry run"
150
+
echo "::warning title=Release tag already exists::Tag $TAG already exists — skipping in dry run."
148
151
else
149
-
echo "Error: Tag $TAG already exists — has the version been bumped?"
152
+
echo "::error title=Release tag already exists::Tag $TAG already exists — has the version been bumped?"
0 commit comments