Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions .github/workflows/presto-release-prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Presto Stable Release - Prepare

on:
workflow_dispatch:
inputs:
prepare_release:
description: 'Prepare release branch and tag'
type: boolean
default: true
required: false
prepare_release_notes:
description: 'Prepare release notes pull request'
type: boolean
default: true
required: false

env:
JAVA_VERSION: '11'
JAVA_DISTRIBUTION: 'temurin'

jobs:
prepare-release-branch:
if: ${{ inputs.prepare_release }}
runs-on: ubuntu-latest
environment: release
permissions:
contents: write

steps:
- name: Check for master branch
if: ${{ github.ref != 'refs/heads/master' }}
run: echo "Invalid branch. This action can only be run on the master branch." && exit 1

- name: Checkout presto source
uses: actions/checkout@v4
with:
token: ${{ secrets.PRESTODB_CI_TOKEN }}
ref: master
show-progress: false
fetch-depth: 5

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}

- name: Configure git
run: |
git config --global --add safe.directory ${{github.workspace}}
git config --global user.email "[email protected]"
git config --global user.name "prestodb-ci"
git config --global alias.ls 'log --pretty=format:"%cd %h %ce: %s" --date=short --no-merges'
git config pull.rebase false

- name: Set presto release version
run: |
unset MAVEN_CONFIG && ./mvnw versions:set -DremoveSnapshot -ntp

- name: Get presto release version
id: get-version
run: |
PRESTO_RELEASE_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
-Dexpression=project.version -q -ntp -DforceStdout | tail -n 1)
echo "PRESTO_RELEASE_VERSION=$PRESTO_RELEASE_VERSION" >> $GITHUB_ENV
echo "PRESTO_RELEASE_VERSION=$PRESTO_RELEASE_VERSION"

- name: Prepare release tag and commits
run: |
git reset --hard
unset MAVEN_CONFIG && ./mvnw release:prepare --batch-mode \
-DskipTests \
-DautoVersionSubmodules \
-DdevelopmentVersion=${{ env.PRESTO_RELEASE_VERSION }} \
-DreleaseVersion=${{ env.PRESTO_RELEASE_VERSION }}
grep -m 2 "<version>" pom.xml
echo "commits on master branch"
git ls -5

- name: Push release tag, branch and commits
run: |
echo "In case this job failed, please delete the tag ${{ env.PRESTO_RELEASE_VERSION }} and the branch release-${{ env.PRESTO_RELEASE_VERSION }}, and re-run the job"
git checkout ${{ env.PRESTO_RELEASE_VERSION }}
git switch -c release-${{ env.PRESTO_RELEASE_VERSION }}
echo "Pushing release branch release-${{ env.PRESTO_RELEASE_VERSION }} and tag ${{ env.PRESTO_RELEASE_VERSION }}"

echo "commits on release-${{ env.PRESTO_RELEASE_VERSION }} branch"
git ls -4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: for consistence use 5 here? Before and after this 5 is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@czentgr The reason the number changes between 4 and 5 is that I want to keep the logs containing the last 3 commits that were not generated by the Maven release plugin

Take 0.291 for example, in the branch release-0.291 and tag 0.291, the command git ls -4 will display the 4 commits as follows:

image

In the master branch, the comand git ls -5 will display the last 5 commits, which has the same 3 commits in the release branch
image

But it's also fine to keep 5 commits in both situations. We only use the logs to verify that the release branch was created correctly.

git push origin release-${{ env.PRESTO_RELEASE_VERSION }} --tags
echo -e "\nPushed release tag to: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ env.PRESTO_RELEASE_VERSION }}"
echo "Pushed release branch to: ${{ github.server_url }}/${{ github.repository }}/tree/release-${{ env.PRESTO_RELEASE_VERSION }}"

echo "Pushing master branch"
git checkout master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to checkout the master branch and push it?
We pushed the new release branch above but why do we need to do this. It doesn't look like this changes anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to checkout the master branch and push it? We pushed the new release branch above but why do we need to do this. It doesn't look like this changes anything.

Because mvn release:prepare will create 2 commits on master branch like below and also a tag for each release

2025-01-27 943868a918 (oss-release-bot): [maven-release-plugin] prepare for next development iteration
2025-01-27 3374f1b274 (oss-release-bot): [maven-release-plugin] prepare release 0.291  <tag: 0.291> 

Next we will create a release branch based on the tag for the next publish action

To make it easy to revert, I will first push the release branch and tag, then push the master branch.

In case anything failed during release, we just need to delete the branch and tag without reverting any commits on master branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My opinion is to stick with maven as much as possible, even it means to revert master branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My opinion is to stick with maven as much as possible, even it means to revert master branch.

@wanglinsong I think in most of the cases, it should be fine with both pushing order since they all do the same thing - pushing the release branch & tag, and commits to master branch. For the failed cases, let me explain it in detail.

With the order as you suggested ( push the master branch & tag, then the release branch):

  • When failed to push to the master branch, just delete the tag and re-run the job
  • When successfully pushed to master but failed to push the release tag, need reset master branch to remove the commits, then re-run the failed job
  • When failed to push the release branch, need reset master branch to remove the commits, delete the tag and try again.

With the order I used( push the release branch & tag, then master branch)

  • When push to release branch & tag failed, just delete the branch & tag(if exists), and re-run the job
  • When push to master failed, just delete the release branch & tag(since they are newly created, no one is working on it)

Because reset the commits on master branch will have impact on the open PRs which has greater risk than delete the newly created branch and tag, that why I think it's better to keep the pushing order in my PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining. I agree that we wouldn't want to reset the master branch if we can avoid it.

Do we need to generally worry about race conditions if a committer merges a PR while the running. I suspect in that case we would fail the push to master because the master branch base is different and it can't push the maven commits.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to generally worry about race conditions if a committer merges a PR while the running. I suspect in that case we would fail the push to master because the master branch base is different and it can't push the maven commits.

Because there is a special settings to let the user prestodb-ci by pass the PR rules, this user can push commits directly on master branch. Also about the race conditions, I think it follows the git pushing rules, the worse case is that some PRs merged during the action, which will cause it failed to push the commits to master branch. In this case, we can delete the branch and tag, then try the action again without any impact on all the open PRs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My opinion is to stick with maven as much as possible, even it means to revert master branch.

@wanglinsong I think in most of the cases, it should be fine with both pushing order since they all do the same thing - pushing the release branch & tag, and commits to master branch. For the failed cases, let me explain it in detail.

With the order as you suggested ( push the master branch & tag, then the release branch):

  • When failed to push to the master branch, just delete the tag and re-run the job
  • When successfully pushed to master but failed to push the release tag, need reset master branch to remove the commits, then re-run the failed job
  • When failed to push the release branch, need reset master branch to remove the commits, delete the tag and try again.

With the order I used( push the release branch & tag, then master branch)

  • When push to release branch & tag failed, just delete the branch & tag(if exists), and re-run the job
  • When push to master failed, just delete the release branch & tag(since they are newly created, no one is working on it)

Because reset the commits on master branch will have impact on the open PRs which has greater risk than delete the newly created branch and tag, that why I think it's better to keep the pushing order in my PR.

This is no reason of failing to push the release branch, which is a new branch, no any conflicts possible at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no reason of failing to push the release branch, which is a new branch, no any conflicts possible at all.±

Yes, but if the release needs to be reverted for some reason, the release branch and tag might be forgotten to be deleted.

echo "commits on master branch"
git ls -5
git push origin master

prepare-release-notes:
needs: prepare-release-branch
if: ${{ inputs.prepare_release_notes && always() && (needs.prepare-release-branch.result == 'success' || !inputs.prepare_release) }}
runs-on: ubuntu-latest
environment: release
permissions:
contents: write

steps:
- name: Checkout presto source
uses: actions/checkout@v4
with:
ref: master
show-progress: false

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}

- name: Configure git
run: |
git config --global --add safe.directory ${{github.workspace}}
git config --global user.email "[email protected]"
git config --global user.name "prestodb-ci"
git config pull.rebase false

- name: Add git upstream
run: |
git remote add upstream ${{ github.server_url }}/${{ github.repository }}.git
git fetch upstream --tags
git remote -v

- name: Create release notes pull request
run: |
echo "In case this job failed, please delete the release notes branch(e.g. release-notes-0.292) in repository ${{ github.repository }}, and re-run the job"
./src/release/release-notes.sh ${{ github.repository_owner }} ${{ secrets.PRESTODB_CI_TOKEN }}
70 changes: 0 additions & 70 deletions .github/workflows/presto-stable-release.yml

This file was deleted.

Loading