Skip to content

Commit

Permalink
chore: improve release CI
Browse files Browse the repository at this point in the history
  • Loading branch information
zepfred committed Aug 30, 2024
1 parent ff6ae02 commit 1c32a3d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 41 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/finish_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Finish Release

on:
release:
types: [published]

jobs:
build:
env:
RELEASE_BRANCH_NAME: "__timefold_release_branch__"
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Checkout timefold-solver
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0 # Otherwise merge will fail on account of not having history.

- name: Update release branch
shell: bash
run: |
tag=${{ github.ref }}
tag_version=${tag##*/}
version=${tag_version%.*}
version="${version:1}.x"
echo $version
exists="$(git branch -a | grep -w $version || true)"
echo "branch $exists"
if [ -n "$exists" ]; then
git checkout $RELEASE_BRANCH_NAME
git checkout $version
git merge -Xtheirs --no-edit --squash -m "build: release version $tag_version" $RELEASE_BRANCH_NAME
git push origin $version
git push -d origin $RELEASE_BRANCH_NAME
else
git checkout $RELEASE_BRANCH_NAME
git branch -m $RELEASE_BRANCH_NAME $version
git push origin -u $version
git push -d origin $RELEASE_BRANCH_NAME
fi
22 changes: 0 additions & 22 deletions .github/workflows/release-pr-body.md

This file was deleted.

27 changes: 8 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ on:
description: 'Branch to cut the release from'
default: main
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
dryRun:
description: 'Do a dry run? (true or false)'
default: true
Expand All @@ -36,6 +32,7 @@ jobs:
build:
env:
MAVEN_ARGS: "--no-transfer-progress --batch-mode"
RELEASE_BRANCH_NAME: "__timefold_release_branch__"
runs-on: ubuntu-latest
environment:
name: pypi
Expand All @@ -51,11 +48,15 @@ jobs:
fetch-depth: 0
ref: ${{ github.event.inputs.sourceBranch }}

- name: Init release branch
continue-on-error: true
run: git push -d origin $RELEASE_BRANCH_NAME

- name: Create release branch and switch to it
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
- uses: actions/setup-java@v4
with:
Expand Down Expand Up @@ -92,7 +93,7 @@ jobs:
git add docs/src/antora.yml
find . -name 'pom.xml' | xargs git add
git commit -m "build: release version ${{ github.event.inputs.version }}"
git push origin ${{ github.event.inputs.releaseBranch }}
git push origin $RELEASE_BRANCH_NAME
- name: Run JReleaser
uses: jreleaser/release-action@v2
Expand All @@ -117,16 +118,4 @@ jobs:
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ github.event.inputs.dryRun == 'false' }}

# Pull Request will be created with the changes and a summary of next steps.
- name: Put back the 999-SNAPSHOT version on the release branch
run: |
git checkout -B ${{ github.event.inputs.releaseBranch }}-put-back-999-snapshot
mvn -Dfull versions:set -DnewVersion=999-SNAPSHOT
sed -i "s/^timefold_solver_python_version.*=.*/timefold_solver_python_version = '999-dev0'/" setup.py
git commit -am "build: move back to 999-SNAPSHOT"
git push origin ${{ github.event.inputs.releaseBranch }}-put-back-999-snapshot
gh pr create --reviewer triceo --base ${{ github.event.inputs.releaseBranch }} --head ${{ github.event.inputs.releaseBranch }}-put-back-999-snapshot --title "build: move back to 999-SNAPSHOT" --body-file .github/workflows/release-pr-body.md
env:
GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }}
if: ${{ github.event.inputs.dryRun == 'false' }}

0 comments on commit 1c32a3d

Please sign in to comment.