/
vshmidt
/
streamlit
Обзор
Документация
Войти
/
vshmidt
/
streamlit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
.github/workflows/patch-release-branch-creation.yml
166 строк
6 KB
Bob Nisco
[fix] Update the output of the Slack notification on release branch creation (#13237)
05 дек 2025, 22:29
Не верифицирован
05 дек 2025, 22:29
ce6f608
Код
Авторство
О чём код?
name: Patch Release Branch Creation on: workflow_dispatch: inputs: patch_version: description: "Patch version in full semver (x.y.z)" required: true type: string base_tag: description: "Existing release tag to base the patch on (e.g. 1.50.0)" required: true type: string dry_run: description: "Run without pushing or creating PR/tag" required: false type: boolean default: false permissions: contents: write concurrency: group: patch-branch-${{ inputs.patch_version || github.sha }} cancel-in-progress: false jobs: create-patch-branch: name: Create Patch Branch ${{ inputs.patch_version }} if: ${{ github.repository == 'streamlit/streamlit' && github.event_name == 'workflow_dispatch' }} runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v6 with: fetch-depth: 0 persist-credentials: true - name: Set Python version vars uses: ./.github/actions/build_info - name: Set up Python ${{ env.PYTHON_MAX_VERSION }} uses: actions/setup-python@v6 with: python-version: "${{ env.PYTHON_MAX_VERSION }}" - name: Set up uv uses: astral-sh/setup-uv@v7 - name: Install Python deps for release automation run: | uv pip install --system packaging semver requests - name: Configure Git run: | git config user.name "${{ github.actor }}" git config user.email "${{ github.actor }}@users.noreply.github.com" - name: Define variables id: vars run: | set -euo pipefail REL_VER='${{ inputs.patch_version }}' REL_BRANCH="release/${REL_VER}" echo "release_branch=${REL_BRANCH}" >> "$GITHUB_OUTPUT" - name: Validate inputs run: | set -euo pipefail # Basic format validation if ! echo "${{ inputs.patch_version }}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then echo "::error::patch_version must be full semver (x.y.z). Got '${{ inputs.patch_version }}'" >&2 exit 1 fi if ! echo "${{ inputs.base_tag }}" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then echo "::error::base_tag must be a release tag in full semver (x.y.z). Got '${{ inputs.base_tag }}'" >&2 exit 1 fi # Ensure the base tag exists remotely if ! git ls-remote --exit-code --tags origin "refs/tags/${{ inputs.base_tag }}" >/dev/null 2>&1; then echo "::error::Base tag ${{ inputs.base_tag }} does not exist on origin" >&2 exit 1 fi # Ensure the tag for the new patch doesn't already exist remotely if git ls-remote --exit-code --tags origin "refs/tags/${{ inputs.patch_version }}" >/dev/null 2>&1; then echo "::error::Tag ${{ inputs.patch_version }} already exists on origin" >&2 exit 1 fi # Ensure the release branch doesn't already exist remotely if git ls-remote --exit-code --heads origin "refs/heads/release/${{ inputs.patch_version }}" >/dev/null 2>&1; then echo "::error::Branch release/${{ inputs.patch_version }} already exists on origin" >&2 exit 1 fi # Validate major/minor match and patch increments by 1 BASE_MAJOR=$(echo "${{ inputs.base_tag }}" | awk -F. '{print $1}') BASE_MINOR=$(echo "${{ inputs.base_tag }}" | awk -F. '{print $2}') BASE_PATCH=$(echo "${{ inputs.base_tag }}" | awk -F. '{print $3}') PATCH_MAJOR=$(echo "${{ inputs.patch_version }}" | awk -F. '{print $1}') PATCH_MINOR=$(echo "${{ inputs.patch_version }}" | awk -F. '{print $2}') PATCH_PATCH=$(echo "${{ inputs.patch_version }}" | awk -F. '{print $3}') if [ "$BASE_MAJOR" -ne "$PATCH_MAJOR" ] || [ "$BASE_MINOR" -ne "$PATCH_MINOR" ]; then echo "::error::patch_version must share the same major.minor as base_tag (${BASE_MAJOR}.${BASE_MINOR}). Got ${PATCH_MAJOR}.${PATCH_MINOR}" >&2 exit 1 fi EXPECTED_PATCH=$((BASE_PATCH + 1)) if [ "$PATCH_PATCH" -ne "$EXPECTED_PATCH" ]; then echo "::error::patch_version patch component must be base_tag patch + 1 (expected ${EXPECTED_PATCH}, got ${PATCH_PATCH})" >&2 exit 1 fi - name: Fetch all tags and branches run: | git fetch --prune --tags --force origin - name: Checkout base tag (detached HEAD) run: | set -euo pipefail git checkout "${{ inputs.base_tag }}" echo "Checked out base tag: ${{ inputs.base_tag }}" - name: Create release branch via script run: | set -euo pipefail chmod +x scripts/create_release_branch.sh if [ "${{ inputs.dry_run }}" = "true" ]; then echo "[DRY RUN] Would run: ./scripts/create_release_branch.sh ${{ inputs.patch_version }}" else bash scripts/create_release_branch.sh "${{ inputs.patch_version }}" fi - name: Write step summary env: PATCH_VERSION: ${{ inputs.patch_version }} RELEASE_BRANCH: ${{ steps.vars.outputs.release_branch }} BASE_TAG: ${{ inputs.base_tag }} DRY_RUN: ${{ inputs.dry_run }} run: | { echo "## Patch Release Branch Creation Summary"; echo "- Patch version: ${PATCH_VERSION}"; echo "- Release branch: \`${RELEASE_BRANCH}\`"; echo "- Base tag: ${BASE_TAG}"; if [ "${DRY_RUN}" = "true" ]; then echo "- Dry run: true (no branch created)"; fi } >> "$GITHUB_STEP_SUMMARY" - name: Slack notification - branch created if: ${{ success() && inputs.dry_run != true }} env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} REPO: ${{ github.repository }} RELEASE_VERSION: ${{ inputs.patch_version }} RELEASE_BRANCH: ${{ steps.vars.outputs.release_branch }} RUN_ID: ${{ github.run_id }} RELEASE_BASE_REF: ${{ inputs.base_tag }} run: | python scripts/slack_notifications.py release_automation branch_created