snazy commented on code in PR #2383: URL: https://github.com/apache/polaris/pull/2383#discussion_r2538892051
########## .github/workflows/release-2-update-release-candidate.yml: ########## @@ -0,0 +1,261 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: Release - 2 - Update version and Changelog for Release Candidate + +on: + workflow_dispatch: + inputs: + dry_run: + description: 'Dry run mode (check to enable, uncheck to perform actual operations)' + required: false + type: boolean + default: true + +jobs: + update-release-candidate: + name: Release - 2 - Update version and Changelog for Release Candidate + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + with: + # Fetch full history for proper branch operations + fetch-depth: 0 + # Use a token with write permissions + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: Set DRY_RUN environment variable + run: | + if [[ "${{ github.event.inputs.dry_run }}" == "true" ]]; then + echo "DRY_RUN=1" >> $GITHUB_ENV + echo "DRY_RUN mode enabled - no actual changes will be made" + else + echo "DRY_RUN=0" >> $GITHUB_ENV + echo "DRY_RUN mode disabled - actual changes will be made" + fi + + - name: Auto-determine release branch and next RC number + run: | + releasey_dir="$(pwd)/releasey" + LIBS_DIR="${releasey_dir}/libs" + + source "${LIBS_DIR}/_log.sh" + source "${LIBS_DIR}/_constants.sh" + source "${LIBS_DIR}/_version.sh" + + # Get the current branch name + current_branch=$(git branch --show-current) + print_info "Current branch: ${current_branch}" + + # Validate that we're on a release branch + if [[ ! "${current_branch}" =~ ^release/(.+)$ ]]; then + print_error "This workflow must be run from a release branch (release/x.y.z-incubating)" + print_error "Current branch: ${current_branch}" + exit 1 + fi + + # Extract version from release branch name + branch_version="${BASH_REMATCH[1]}" + print_info "Extracted version from branch: ${branch_version}" + + # Validate branch version format and extract components + if ! validate_and_extract_branch_version "${branch_version}"; then + print_error "Invalid release branch version format: ${branch_version}" + print_error "Expected format: x.y.z-incubating" + exit 1 + fi + + print_info "Parsed version components from branch:" + print_info " Major: ${major}" + print_info " Minor: ${minor}" + print_info " Patch: ${patch}" + print_info " Version without RC: ${version_without_rc}" + + # Find the next available RC number by checking existing tags + find_next_rc_number "${version_without_rc}" + print_info "Next RC number: ${rc_number}" + + # Build the new release tag + release_tag="apache-polaris-${version_without_rc}-rc${rc_number}" + + # Export all variables for next steps + echo "release_tag=${release_tag}" >> $GITHUB_ENV + echo "major=${major}" >> $GITHUB_ENV + echo "minor=${minor}" >> $GITHUB_ENV + echo "patch=${patch}" >> $GITHUB_ENV + echo "rc_number=${rc_number}" >> $GITHUB_ENV + echo "version_without_rc=${version_without_rc}" >> $GITHUB_ENV + echo "release_branch=${current_branch}" >> $GITHUB_ENV + + print_success "Determined release candidate details:" + print_info " Release branch: ${current_branch}" + print_info " Release tag: ${release_tag}" + print_info " Version without RC: ${version_without_rc}" + print_info " RC number: ${rc_number}" + + - name: Verify GitHub checks are passing + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + releasey_dir="$(pwd)/releasey" + LIBS_DIR="${releasey_dir}/libs" + + source "${LIBS_DIR}/_log.sh" + source "${LIBS_DIR}/_constants.sh" + source "${LIBS_DIR}/_exec.sh" + source "${LIBS_DIR}/_github.sh" + + # Get the current HEAD commit SHA + current_commit=$(git rev-parse HEAD) + + print_info "Verifying GitHub checks for commit: ${current_commit}" + + # Verify all GitHub checks are passing + if ! check_github_checks_passed "${current_commit}"; then + print_error "GitHub checks are not all passing for commit ${current_commit}" + print_error "Please ensure all checks pass before updating the release candidate" + exit 1 + fi + + print_success "All GitHub checks are passing for commit ${current_commit}" + + - name: Set up Java + uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Update project versions + run: | + releasey_dir="$(pwd)/releasey" + LIBS_DIR="${releasey_dir}/libs" + + source "${LIBS_DIR}/_log.sh" + source "${LIBS_DIR}/_constants.sh" + source "${LIBS_DIR}/_exec.sh" + source "${LIBS_DIR}/_version.sh" + + print_info "Updating project version to ${version_without_rc}" + update_version "${version_without_rc}" + + print_success "Project version updated to ${version_without_rc}" + + - name: Update changelog + run: | + releasey_dir="$(pwd)/releasey" + LIBS_DIR="${releasey_dir}/libs" + + source "${LIBS_DIR}/_log.sh" + source "${LIBS_DIR}/_exec.sh" + + print_info "Updating CHANGELOG.md" + exec_process ./gradlew patchChangelog + + print_success "Changelog updated successfully" + + - name: Commit and push changes + run: | + releasey_dir="$(pwd)/releasey" + LIBS_DIR="${releasey_dir}/libs" + + source "${LIBS_DIR}/_log.sh" + source "${LIBS_DIR}/_constants.sh" + source "${LIBS_DIR}/_exec.sh" + + print_info "Committing version and changelog changes" + + # Commit version files and changelog + exec_process git add "$VERSION_FILE" "$HELM_CHART_YAML_FILE" "$HELM_README_FILE" "$HELM_VALUES_FILE" + exec_process git add "$CHANGELOG_FILE" + exec_process git commit -m "[chore] Bump version to ${version_without_rc} for release candidate ${rc_number}" + + # Push the changes + exec_process git push origin "${release_branch}" + + # Get the new commit SHA after our changes + new_tag_ref=$(git rev-parse HEAD) + echo "new_tag_ref=${new_tag_ref}" >> $GITHUB_ENV + + print_info "Changes committed and pushed. New commit: ${new_tag_ref}" + + - name: Create RC tag at new commit + run: | + releasey_dir="$(pwd)/releasey" + LIBS_DIR="${releasey_dir}/libs" + + source "${LIBS_DIR}/_log.sh" + source "${LIBS_DIR}/_exec.sh" + + print_info "Creating RC tag ${release_tag} at commit ${new_tag_ref}" + + # Create the tag at the new commit + exec_process git tag "${release_tag}" "${new_tag_ref}" + exec_process git push origin "${release_tag}" + + print_success "🎉 RC tag ${release_tag} created successfully at commit ${new_tag_ref}!" + + - name: Create or update GitHub release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + releasey_dir="$(pwd)/releasey" + LIBS_DIR="${releasey_dir}/libs" + + source "${LIBS_DIR}/_log.sh" + source "${LIBS_DIR}/_exec.sh" + + release_title="Release ${version_without_rc}" + + if [[ ${rc_number} -eq 1 ]]; then + print_info "Creating new GitHub release: ${release_title}" + exec_process gh release create "${release_tag}" \ + --title "${release_title}" \ + --prerelease \ + --target "${new_tag_ref}" + + print_success "🎉 GitHub release created: ${release_title}" + else Review Comment: #3080 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
