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