|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + version: |
| 6 | + description: 'Community Edition version (e.g. 1.0.0)' |
| 7 | + required: true |
| 8 | + pythonVersionSuffix: |
| 9 | + description: 'What suffix to append to the Python version (ex: a0 for alpha release)' |
| 10 | + required: true |
| 11 | + default: a0 |
| 12 | + sourceBranch: |
| 13 | + description: 'Branch to cut the release from' |
| 14 | + default: main |
| 15 | + required: true |
| 16 | + releaseBranch: |
| 17 | + description: 'Release branch to create (e.g. 1.0.x for version 1.0.0; once created, branch protection rules apply)' |
| 18 | + default: dry_run |
| 19 | + required: true |
| 20 | + dryRun: |
| 21 | + description: 'Do a dry run? (true or false)' |
| 22 | + default: true |
| 23 | + required: true |
| 24 | +jobs: |
| 25 | + build: |
| 26 | + env: |
| 27 | + MAVEN_ARGS: "--no-transfer-progress --batch-mode" |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - name: Print inputs to the release workflow |
| 31 | + run: echo "${{ toJSON(github.event.inputs) }}" |
| 32 | + - name: Checkout the relevant timefold-solver tag |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + repository: "TimefoldAI/timefold-solver" |
| 36 | + path: "./timefold-solver" |
| 37 | + fetch-depth: 0 |
| 38 | + ref: v${{ github.event.inputs.version }} |
| 39 | + |
| 40 | + - uses: actions/setup-java@v4 |
| 41 | + with: |
| 42 | + java-version: '17' |
| 43 | + distribution: 'temurin' |
| 44 | + cache: 'maven' |
| 45 | + |
| 46 | + - name: Set up Maven |
| 47 | + uses: stCarolas/setup-maven@v5 |
| 48 | + with: |
| 49 | + maven-version: 3.9.3 |
| 50 | + |
| 51 | + - name: Python 3.12 Setup |
| 52 | + uses: actions/setup-python@v4 |
| 53 | + with: |
| 54 | + python-version: 3.12 |
| 55 | + |
| 56 | + - name: Install Pip and build |
| 57 | + run: |
| 58 | + python -m pip install --upgrade pip |
| 59 | + pip install build |
| 60 | + |
| 61 | + - name: Checkout timefold-solver-python |
| 62 | + uses: actions/checkout@v4 |
| 63 | + with: |
| 64 | + fetch-depth: 0 |
| 65 | + ref: ${{ github.event.inputs.sourceBranch }} |
| 66 | + |
| 67 | + - name: Create release branch and switch to it |
| 68 | + run: | |
| 69 | + git config user.name "Timefold Release Bot" |
| 70 | + git config user.email "release@timefold.ai" |
| 71 | + git checkout -b ${{ github.event.inputs.releaseBranch }} |
| 72 | +
|
| 73 | + # We skip tests in dry run, to make the process faster. |
| 74 | + # Technically, this goes against the main reason for doing a dry run; to eliminate potential problems. |
| 75 | + # But unless something catastrophic happened, PR checks on source branch already ensured that all tests pass. |
| 76 | + # We also do not use versions:set, because we'd have to have the SNAPSHOT version built from somewhere, |
| 77 | + # and at this point in the release, there is no upstream branch anywhere that would have this version anymore. |
| 78 | + - name: Set release version and build release |
| 79 | + run: | |
| 80 | + export NEW_VERSION=${{ github.event.inputs.version }} |
| 81 | + export NEW_VERSION_PYTHON=${{ github.event.inputs.version }}${{ github.event.inputs.pythonVersionSuffix }} |
| 82 | + .github/scripts/change_versions.sh |
| 83 | + python -m build |
| 84 | +
|
| 85 | + # JReleaser requires the release branch to exist, so we need to push it before releasing. |
| 86 | + # Once this is pushed, branch protection rules apply. |
| 87 | + # So if any of the subsequent steps should fail, the release branch is there to stay; cannot be deleted. |
| 88 | + # To minimize that chance, do a dry run first, with a branch named in a way that the protection rules don't apply. |
| 89 | + - name: Push release branch to Git |
| 90 | + run: | |
| 91 | + git push origin ${{ github.event.inputs.releaseBranch }} |
| 92 | +
|
| 93 | + - name: Run JReleaser |
| 94 | + uses: jreleaser/release-action@v2 |
| 95 | + env: |
| 96 | + JRELEASER_DRY_RUN: ${{ github.event.inputs.dryRun }} |
| 97 | + JRELEASER_PROJECT_VERSION: ${{ github.event.inputs.version }}${{ github.event.inputs.pythonVersionSuffix }} |
| 98 | + JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }} |
| 99 | + JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} |
| 100 | + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} |
| 101 | + JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} |
| 102 | + |
| 103 | + - name: JReleaser release output |
| 104 | + uses: actions/upload-artifact@v4 |
| 105 | + if: always() |
| 106 | + with: |
| 107 | + name: jreleaser-release |
| 108 | + path: | |
| 109 | + out/jreleaser/trace.log |
| 110 | + out/jreleaser/output.properties |
| 111 | +
|
| 112 | + # TODO: Use https://github.com/marketplace/actions/pypi-publish to publish to PyPI here |
| 113 | + |
| 114 | + # Pull Request will be created with the changes and a summary of next steps. |
| 115 | + - name: Put back the 999-SNAPSHOT version on the release branch |
| 116 | + run: | |
| 117 | + git checkout -B ${{ github.event.inputs.releaseBranch }}-put-back-999-snapshot |
| 118 | + export NEW_VERSION="999-SNAPSHOT" |
| 119 | + export NEW_VERSION_PYTHON="999-dev0" |
| 120 | + .github/scripts/change_versions.sh |
| 121 | + git push origin ${{ github.event.inputs.releaseBranch }}-put-back-999-snapshot |
| 122 | + gh pr create --reviewer triceo,Christopher-Chianelli --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 |
| 123 | + env: |
| 124 | + GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }} |
0 commit comments