Skip to content

Commit ec1642e

Browse files
fix(ci): harden workflow files flagged on #4994
1 parent 9f51867 commit ec1642e

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,10 @@ jobs:
257257
fi
258258
259259
- name: Create or checkout release branch
260+
env:
261+
BRANCH: ${{ steps.version.outputs.branch }}
262+
RELEASE_TYPE: ${{ inputs.release_type }}
260263
run: |
261-
BRANCH="${{ steps.version.outputs.branch }}"
262-
RELEASE_TYPE="${{ inputs.release_type }}"
263264
264265
if [[ "$RELEASE_TYPE" == *-prerelease ]]; then
265266
# For prereleases: create branch from main if it doesn't exist, or reuse existing
@@ -284,17 +285,19 @@ jobs:
284285
fi
285286
286287
- name: Update version in __init__.py
288+
env:
289+
VERSION: ${{ steps.version.outputs.version }}
287290
run: |
288-
VERSION="${{ steps.version.outputs.version }}"
289291
sed -i -E "s/__version__ = \".*\"/__version__ = \"${VERSION}\"/" src/huggingface_hub/__init__.py
290292
echo "Updated version to:"
291293
grep "__version__" src/huggingface_hub/__init__.py
292294
293295
- name: Commit, tag, and push
296+
env:
297+
TAG: ${{ steps.version.outputs.tag }}
298+
BRANCH: ${{ steps.version.outputs.branch }}
299+
IS_PRERELEASE: ${{ steps.version.outputs.is_prerelease }}
294300
run: |
295-
TAG="${{ steps.version.outputs.tag }}"
296-
BRANCH="${{ steps.version.outputs.branch }}"
297-
IS_PRERELEASE="${{ steps.version.outputs.is_prerelease }}"
298301
299302
git add src/huggingface_hub/__init__.py
300303
git commit -m "Release: ${TAG}"
@@ -499,10 +502,21 @@ jobs:
499502
HF_TOKEN: ${{ secrets.RELEASE_NOTES_HF_TOKEN }}
500503
GITHUB_TOKEN_RELEASE_NOTES: ${{ secrets.GITHUB_TOKEN }}
501504
RELEASE_NOTES_MODEL: ${{ vars.RELEASE_NOTES_MODEL }}
505+
SINCE_TAG: ${{ needs.prepare.outputs.since_tag }}
506+
BUMP_TYPE: ${{ needs.prepare.outputs.bump_type }}
502507
run: |
508+
set -euo pipefail
509+
case "$BUMP_TYPE" in
510+
minor|major|patch) ;;
511+
*) echo "::error::Unexpected bump type: $BUMP_TYPE"; exit 1 ;;
512+
esac
513+
case "$SINCE_TAG" in
514+
v[0-9]*) ;;
515+
*) echo "::error::Unexpected since tag: $SINCE_TAG"; exit 1 ;;
516+
esac
503517
python -m utils.release_notes.generate_release_notes \
504-
--since "${{ needs.prepare.outputs.since_tag }}" \
505-
--${{ needs.prepare.outputs.bump_type }}
518+
--since "$SINCE_TAG" \
519+
"--$BUMP_TYPE"
506520
507521
- name: Create draft GitHub release (prerelease)
508522
if: ${{ endsWith(inputs.release_type, '-prerelease') && steps.check_draft.outputs.skip != 'true' }}
@@ -674,8 +688,9 @@ jobs:
674688
env:
675689
HF_TOKEN: ${{ secrets.RELEASE_NOTES_HF_TOKEN }}
676690
RELEASE_NOTES_MODEL: ${{ vars.RELEASE_NOTES_MODEL }}
691+
VERSION: ${{ needs.prepare.outputs.version }}
677692
run: |
678-
VERSION="${{ needs.prepare.outputs.version }}"
693+
set -euo pipefail
679694
BASE_VERSION=$(echo "$VERSION" | sed -E 's/\.rc.*//')
680695
# Create output directory (.release-notes/ is in .gitignore so absent after checkout)
681696
mkdir -p .release-notes

0 commit comments

Comments
 (0)