Skip to content

Commit

Permalink
chore: fix release CI (#553)
Browse files Browse the repository at this point in the history
This pull request addresses issues with the Release CI job.
  • Loading branch information
zepfred authored Aug 26, 2024
1 parent a4c401b commit 0d9efd1
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-pr-body.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ At this point, the release of _Timefold Quickstarts_ is ready to be published.

To finish the release of _Timefold Quickstarts_,
review and merge this PR to update the `stable` branch with new code.
Afterward, delete the branch that this PR is based on.
Afterward, delete the branch that this PR is based on.
(Typically a button appears on this page once the PR is merged.)
92 changes: 58 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ name: Release
on:
workflow_dispatch:
inputs:
java-version:
javaVersion:
description: 'Community Edition version (e.g. 1.0.0)'
required: true
python-version:
description: 'Python Community Edition version (e.g. 1.0.0b0)'
pythonVersionSuffix:
description: 'What suffix to append to the Python version (ex: b0 for beta release)'
required: true
default: b0
developmentBranch:
description: 'Development branch to cut the release from'
default: development
Expand All @@ -16,20 +17,27 @@ on:
description: 'Stable branch to merge the development branch into'
default: stable
required: true
releaseBranch:
description: 'Release branch to create (e.g. 1.0.x for version 1.0.0; once created, branch protection rules apply)'
default: dry_run
required: true
jobs:
build:
env:
MAVEN_ARGS: "--no-transfer-progress --batch-mode"
RELEASE_BRANCH_NAME: "release_branch_${{ github.event.inputs.javaVersion }}"
runs-on: ubuntu-latest
steps:
- name: Checkout timefold-quickstarts
uses: actions/checkout@v4
with:
path: ./timefold-quickstarts
ref: ${{ github.event.inputs.developmentBranch }}
fetch-depth: 0 # Otherwise merge will fail on account of not having history.

- name: Checkout timefold-solver
uses: actions/checkout@v4
with:
repository: TimefoldAI/timefold-solver
path: ./timefold-solver
fetch-depth: 0
ref: v${{ github.event.inputs.javaVersion }}

- uses: actions/setup-java@v3
with:
Expand All @@ -42,46 +50,62 @@ jobs:
with:
maven-version: 3.9.3

# This step will fail if the Solver binaries aren't already on Maven Central.
- name: Create release branch and build release
- name: Python 3.12 Setup
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Pip and build
working-directory: ./timefold-solver
run: |
mvn -Dfull versions:set -DnewVersion=${{ github.event.inputs.javaVersion }}
sed -i "s/^timefold_solver_python_version.*=.*/timefold_solver_python_version = '${{ github.event.inputs.javaVersion }}${{ github.event.inputs.pythonVersionSuffix }}'/" setup.py
python -m pip install --upgrade pip
pip install build
python -m build
- name: Update version
working-directory: ./timefold-quickstarts
run: |
git config user.name "Timefold Release Bot"
git config user.email "[email protected]"
git checkout -B ${{ github.event.inputs.releaseBranch }}
git checkout -B $RELEASE_BRANCH_NAME
export OLD_JAVA_VERSION="$(find . -name pom.xml -exec grep '<version.ai.timefold.solver>' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)"
export NEW_JAVA_VERSION="${{ github.event.inputs.java-version }}"
export NEW_JAVA_VERSION="${{ github.event.inputs.javaVersion }}"
export OLD_PYTHON_VERSION="$(find . -name pyproject.toml -exec grep 'timefold ==' {} \;|tail -n 1|cut -d\' -f1 --complement|cut -d\= -f3|cut -d\' -f1|xargs)"
export NEW_PYTHON_VERSION="${{ github.event.inputs.python-version }}"
export NEW_PYTHON_VERSION="${{ github.event.inputs.javaVersion }}${{ github.event.inputs.pythonVersionSuffix }}"
.github/scripts/change_versions.sh
- name: Build and test Python
working-directory: ./timefold-quickstarts
env:
TIMEFOLD_SOLVER_PYTHON_DIST: "${{ github.workspace }}/timefold-solver/dist"
run: .github/scripts/run_python_tests.sh

# This step will fail if the Solver binaries aren't already on Maven Central.
- name: Create release branch and build release
working-directory: ./timefold-quickstarts
run: |
mvn verify
git commit -am "build: switch to version $NEW_VERSION"
git tag -a "v${{ github.event.inputs.java-version }}" -m "Release version ${{ github.event.inputs.java-version }}"
git commit -am "build: switch to version ${{ github.event.inputs.javaVersion }}"
git tag -a "v${{ github.event.inputs.javaVersion }}" -m "Release version ${{ github.event.inputs.javaVersion }}"
git push --tags
# Merge the release branch into the stable branch.
# While merging, resolve conflicts by using everything from the release branch.
# (Stable branch becomes the same as the release branch.)
- name: Merge release branch into stable and prepare PR
run: |
git checkout ${{ github.event.inputs.stableBranch }}
git checkout -B ${{ github.event.inputs.releaseBranch }}-bump
git checkout ${{ github.event.inputs.releaseBranch }}
git merge -s ours --no-edit ${{ github.event.inputs.stableBranch }}
git checkout ${{ github.event.inputs.releaseBranch }}-bump
git merge --squash ${{ github.event.inputs.releaseBranch }}
git commit -m "build: release version ${{ github.event.inputs.java-version }}"
git push origin ${{ github.event.inputs.releaseBranch }}-bump
gh pr create --reviewer triceo --base ${{ github.event.inputs.stableBranch }} --head ${{ github.event.inputs.releaseBranch }}-bump --title "build: release version ${{ github.event.inputs.java-version }}" --body-file .github/workflows/release-pr-body.md
working-directory: ./timefold-quickstarts
env:
GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }}

- name: Put back the 999-SNAPSHOT version on the release branch
run: |
git checkout ${{ github.event.inputs.releaseBranch }}
export OLD_JAVA_VERSION="$(find . -name pom.xml -exec grep '<version.ai.timefold.solver>' {} \;|tail -n 1|cut -d\> -f1 --complement|cut -d\< -f1)"
export NEW_JAVA_VERSION="999-SNAPSHOT"
export OLD_PYTHON_VERSION="$(find . -name pyproject.toml -exec grep 'timefold ==' {} \;|tail -n 1|cut -d\' -f1 --complement|cut -d\= -f3|cut -d\' -f1|xargs)"
export NEW_PYTHON_VERSION="999-dev0"
.github/scripts/change_versions.sh
git commit -am "build: move back to version $NEW_VERSION"
git push origin ${{ github.event.inputs.releaseBranch }}
git checkout ${{ github.event.inputs.stableBranch }}
git checkout -B $RELEASE_BRANCH_NAME-bump
git checkout $RELEASE_BRANCH_NAME
git merge -s ours --no-edit ${{ github.event.inputs.stableBranch }}
git checkout $RELEASE_BRANCH_NAME-bump
git merge --squash $RELEASE_BRANCH_NAME
git commit -m "build: release version ${{ github.event.inputs.javaVersion }}"
git push origin $RELEASE_BRANCH_NAME-bump
git branch -d $RELEASE_BRANCH_NAME
gh pr create --reviewer triceo --base ${{ github.event.inputs.stableBranch }} --head $RELEASE_BRANCH_NAME-bump --title "build: release version ${{ github.event.inputs.javaVersion }}" --body-file .github/workflows/release-pr-body.md

0 comments on commit 0d9efd1

Please sign in to comment.