-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add github action to prepare stable release #24697
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
df0016d
0ac5884
1208fc7
b765487
7071c51
2e559f1
48cd22d
1af71da
8f65087
3f566b8
550a5ce
f9a9ded
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,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 | ||
| 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 | ||
|
Contributor
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. Why do we need to checkout the master branch and push it?
Contributor
Author
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.
Because mvn release:prepare will create 2 commits on master branch like below and also a tag for each release 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.
Member
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. My opinion is to stick with maven as much as possible, even it means to revert master branch.
Contributor
Author
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.
@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):
With the order I used( push the release branch & tag, then master branch)
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.
Contributor
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. 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.
Contributor
Author
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.
Because there is a special settings to let the user
Member
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.
This is no reason of failing to push the release branch, which is a new branch, no any conflicts possible at all.
Contributor
Author
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.
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 | ||
czentgr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - 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 }} | ||
This file was deleted.
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.
Nit: for consistence use 5 here? Before and after this 5 is used.
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.
@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 -4will display the 4 commits as follows:In the master branch, the comand

git ls -5will display the last 5 commits, which has the same 3 commits in the release branchBut 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.