-
Notifications
You must be signed in to change notification settings - Fork 75
ci: Add a workflow to undo/yank a release, if necessary #512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| name: Undo Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: "Released version to undo (example: 0.14.0)" | ||
| required: true | ||
| type: string | ||
| confirm: | ||
| description: 'Type "UNDO RELEASE" to continue' | ||
| required: true | ||
| type: string | ||
| delete_github_release: | ||
| description: "Delete the GitHub release for tag v<version>" | ||
| required: true | ||
| type: boolean | ||
| default: true | ||
| delete_git_tag: | ||
| description: "Delete tag v<version> from origin" | ||
| required: true | ||
| type: boolean | ||
| default: true | ||
| yank_pypi: | ||
| description: "Yank redisvl==<version> on PyPI" | ||
| required: true | ||
| type: boolean | ||
| default: true | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| env: | ||
| PACKAGE_NAME: redisvl | ||
|
|
||
| jobs: | ||
| undo-release: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Validate inputs | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| CONFIRM: ${{ inputs.confirm }} | ||
| run: | | ||
| set -euo pipefail | ||
| if [ "${CONFIRM}" != "UNDO RELEASE" ]; then | ||
| echo "Confirmation text mismatch." | ||
| exit 1 | ||
| fi | ||
| if ! [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([a-zA-Z0-9\.\-]+)?$ ]]; then | ||
| echo "Version must look like 1.2.3 (optionally with a suffix)." | ||
| exit 1 | ||
| fi | ||
| echo "TAG=v${VERSION}" >> "$GITHUB_ENV" | ||
| echo "SPEC=${PACKAGE_NAME}==${VERSION}" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Generate GitHub App token | ||
| id: app_token | ||
| uses: actions/create-github-app-token@v2 | ||
| with: | ||
| app-id: ${{ vars.RELEASE_BOT_APP_ID }} | ||
| private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} | ||
| owner: ${{ github.repository_owner }} | ||
|
|
||
| - name: Checkout repository | ||
| if: ${{ inputs.delete_git_tag }} | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| fetch-tags: true | ||
| token: ${{ steps.app_token.outputs.token }} | ||
|
|
||
| - name: Delete GitHub release | ||
| if: ${{ inputs.delete_github_release }} | ||
| env: | ||
| GH_TOKEN: ${{ steps.app_token.outputs.token }} | ||
| run: | | ||
| set -euo pipefail | ||
| if gh release view "${TAG}" >/dev/null 2>&1; then | ||
| gh release delete "${TAG}" --yes | ||
| echo "Deleted GitHub release ${TAG}." | ||
| else | ||
| echo "No GitHub release found for ${TAG}; skipping." | ||
| fi | ||
|
|
||
| - name: Delete git tag from origin | ||
| if: ${{ inputs.delete_git_tag }} | ||
| env: | ||
| GH_TOKEN: ${{ steps.app_token.outputs.token }} | ||
| run: | | ||
| set -euo pipefail | ||
| git fetch --tags --force | ||
| if git rev-parse "${TAG}" >/dev/null 2>&1; then | ||
| git tag -d "${TAG}" || true | ||
| fi | ||
| if git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null 2>&1; then | ||
| git push origin ":refs/tags/${TAG}" | ||
| echo "Deleted remote tag ${TAG}." | ||
| else | ||
| echo "Remote tag ${TAG} not found; skipping." | ||
| fi | ||
|
|
||
| - name: Install Python | ||
| if: ${{ inputs.yank_pypi }} | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Yank package on PyPI | ||
| if: ${{ inputs.yank_pypi }} | ||
| env: | ||
| TWINE_USERNAME: __token__ | ||
| TWINE_PASSWORD: ${{ secrets.PYPI }} | ||
| run: | | ||
| set -euo pipefail | ||
| python -m pip install --upgrade pip twine | ||
| twine yank "${SPEC}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| echo "Yanked ${SPEC} on PyPI." | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Release deletion silently fails without repo checkout context
Medium Severity
The checkout step is conditional on
inputs.delete_git_tag, but thegh release view/gh release deletecommands also depend on having a repo context. Whendelete_github_releaseis true butdelete_git_tagis false, no checkout occurs, andghcannot determine the base repository. Because thegh release viewerror is suppressed by>/dev/null 2>&1, the step silently falls through to theelsebranch printing "No GitHub release found," even though the release exists. The checkout condition needs to also account fordelete_github_release, or theghcommands need an explicit--repoflag.Additional Locations (1)
.github/workflows/release-undo.yml#L73-L85