# A workflow to delete (soft-delete) a release branch by renaming it. # # The branch will be renamed from its original name to deleted/{original_name}. # For example, oss_release/v0.2025.01.01.00.00 becomes # deleted/oss_release/v0.2025.01.01.00.00. # # This workflow will fail if: # - The branch doesn't start with the oss_release/ prefix # - The release has an entry in channel_versions.json (i.e., it's deployed) name: Delete Release on: workflow_dispatch: inputs: branch: description: 'The OSS release branch to delete (e.g., oss_release/v0.2025.01.01.00.00.oss)' required: true type: string confirmation: description: 'Type DELETE to confirm' required: true type: string jobs: delete_release: name: Delete Release Branch runs-on: ubuntu-latest steps: - name: Verify confirmation run: | if [[ "${{ inputs.confirmation }}" != "DELETE" ]]; then echo "::error::You must type DELETE to confirm branch deletion. \ If you're unsure about deleting, ask a TL in #oncall-client before running this workflow." exit 1 fi shell: bash - name: Validate release branch id: validate run: | BRANCH_NAME="${{ inputs.branch }}" # Validate that this is an OSS release branch. if [[ ! "$BRANCH_NAME" =~ ^oss_release/ ]]; then echo "::error::Branch '$BRANCH_NAME' is not an OSS release branch." && exit 1 fi CHANNEL="oss" # Extract the version base from the branch name # e.g., "oss_release/v0.2025.01.26.12.30.oss" -> "v0.2025.01.26.12.30.oss" VERSION_BASE="$(echo "$BRANCH_NAME" | sed -r 's|^oss_release/(.*)$|\1|')" echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT echo "new_branch_name=deleted/$BRANCH_NAME" >> $GITHUB_OUTPUT echo "channel=$CHANNEL" >> $GITHUB_OUTPUT echo "version_base=$VERSION_BASE" >> $GITHUB_OUTPUT shell: bash - name: Check if release has changelog in channel_versions.json id: check_deployed env: CHANNEL: ${{ steps.validate.outputs.channel }} VERSION_BASE: ${{ steps.validate.outputs.version_base }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # Fetch channel_versions.json from the channel-versions repository CHANNEL_VERSIONS=$(gh api repos/warpdotdev/channel-versions/contents/channel_versions.json --jq '.content' | base64 -d) # Fail fast if the channel section is missing from channel_versions.json CHANNEL_EXISTS=$(echo "$CHANNEL_VERSIONS" | jq -r --arg channel "$CHANNEL" 'has("changelogs") and (.changelogs | has($channel))') if [[ "$CHANNEL_EXISTS" != "true" ]]; then echo "::error::channel_versions.json is missing the 'changelogs.$CHANNEL' section. Cannot safely determine if release is deployed." exit 1 fi # Check if any key in the changelogs section for this channel starts with the version base # Keys are like "v0.2025.01.26.12.30.stable_01" and version_base is "v0.2025.01.26.12.30.stable" MATCHING_ENTRIES=$(echo "$CHANNEL_VERSIONS" | jq -r --arg channel "$CHANNEL" --arg version "$VERSION_BASE" \ '.changelogs[$channel] | keys[] | select(startswith($version))') if [[ -n "$MATCHING_ENTRIES" ]]; then echo "::error::Cannot delete release branch: version '$VERSION_BASE' has changelog entries in channel_versions.json:" echo "$MATCHING_ENTRIES" exit 1 fi echo "::notice::Release has no changelog in channel_versions.json, safe to delete." shell: bash - name: Checkout repository uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: ref: ${{ inputs.branch }} - name: Rename branch to deleted/ env: BRANCH_NAME: ${{ steps.validate.outputs.branch_name }} NEW_BRANCH_NAME: ${{ steps.validate.outputs.new_branch_name }} run: | echo "Renaming branch '$BRANCH_NAME' to '$NEW_BRANCH_NAME'" # Push the current HEAD to the new branch name git push origin "HEAD:refs/heads/$NEW_BRANCH_NAME" # Delete the original branch git push origin --delete "$BRANCH_NAME" echo "::notice::Successfully renamed branch '$BRANCH_NAME' to '$NEW_BRANCH_NAME'" shell: bash