Skip to content

Commit

Permalink
ci: introduce release CI (TimefoldAI#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
triceo authored Jun 26, 2023
1 parent 232728a commit e9ae26a
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/scripts/change_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Expects the following environment variables to be set:
# $NEW_VERSION (Example: "1.2.0")

mvn versions:set-property -Dproperty=version.ai.timefold.solver -DnewVersion=$NEW_VERSION
find . -name build.gradle -exec sed -i -E 's/def optaplannerVersion = \"[^\"\\s]+\"/def optaplannerVersion = \"$NEW_VERSION\"/' {} \;
find . -name pom.xml | xargs git add
find . -name build.gradle | xargs git add
git commit -m "chore: switch to version $NEW_VERSION"
3 changes: 3 additions & 0 deletions .github/workflows/release-pr-body-development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Review and merge this PR to move `development` branch to a new SNAPSHOT version.
Afterward, delete the branch that this PR is based on.
(Typically a button appears on this page once the PR is merged.)
10 changes: 10 additions & 0 deletions .github/workflows/release-pr-body-stable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
At this point, the release of _Timefold Quickstarts_ is ready to be published.

- Release branch has been created.
- Git tag has been published.
- PR has been prepared to switch `development` branch to a new SNAPSHOT version.

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.
(Typically a button appears on this page once the PR is merged.)
98 changes: 98 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Community Edition version (e.g. 1.0.0)'
required: true
developmentBranch:
description: 'Development branch to cut the release from'
default: development
required: true
stableBranch:
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
nextVersion:
description: 'Next version after release (e.g. 1.1.0, -SNAPSHOT will be added automatically)'
required: true
nextMicroVersion:
description: 'Next version after release for release branch (e.g. 1.0.1, -SNAPSHOT will be added automatically)'
required: true
jobs:
build:
env:
MAVEN_ARGS: "--no-transfer-progress --batch-mode"
runs-on: ubuntu-latest
steps:
- name: Checkout the relevant timefold-solver tag
uses: actions/checkout@v3
with:
repository: "TimefoldAI/timefold-solver"
path: "./timefold-solver"
fetch-depth: 0
ref: v${{ github.event.inputs.version }}

- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'

# No need to wait for the upstream release to show up in Maven Central.
- name: Build the upstream release tag
working-directory: "./timefold-solver"
run: |
mvn -Dquickly install
cd ..
rm -rf timefold-solver
- name: Checkout timefold-quickstarts
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create release branch and build release
run: |
git config user.name "Timefold Release Bot"
git config user.email "[email protected]"
git checkout -B ${{ github.event.inputs.releaseBranch }}
export NEW_VERSION="${{ github.event.inputs.version }}"
.github/scripts/change_versions.sh
git tag "v${{ github.event.inputs.version }}" -a "Release version ${{ github.event.inputs.version }}"
# 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 merge -X theirs --squash ${{ github.event.inputs.releaseBranch }}
git commit -m "chore: release version ${{ github.event.inputs.version }}"
git push origin ${{ github.event.inputs.releaseBranch }}-bump
gh pr create --reviewer triceo,ge0ffrey --base ${{ github.event.inputs.stableBranch }} --head ${{ github.event.inputs.releaseBranch }}-bump --title "chore: release version ${{ github.event.inputs.version }}" --body-file .github/workflows/release-pr-body-stable.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set micro snapshot version on the release branch
run: |
git checkout ${{ github.event.inputs.releaseBranch }}
export NEW_VERSION="${{ github.event.inputs.nextMicroVersion }}-SNAPSHOT"
.github/scripts/change_versions.sh
git push origin ${{ github.event.inputs.releaseBranch }}
- name: Switch development branch to next version and prepare PR
run: |
git checkout ${{ github.event.inputs.developmentBranch }}
git checkout -B ${{ github.event.inputs.releaseBranch }}-bump2
export NEW_VERSION="${{ github.event.inputs.nextVersion }}-SNAPSHOT"
.github/scripts/change_versions.sh
git push origin ${{ github.event.inputs.releaseBranch }}-bump2
gh pr create --reviewer triceo,ge0ffrey --base ${{ github.event.inputs.developmentBranch }} --head ${{ github.event.inputs.releaseBranch }}-bump2 --title "chore: move to ${{ github.event.inputs.nextVersion }}-SNAPSHOT" --body-file .github/workflows/release-pr-body-development.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit e9ae26a

Please sign in to comment.