Skip to content

Commit b726422

Browse files
chore: readd 1.x release workflow (#2344)
Co-authored-by: Timefold Release Bot <release@timefold.ai>
1 parent 24df036 commit b726422

1 file changed

Lines changed: 110 additions & 0 deletions

File tree

.github/workflows/release-1.x.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Axioms of the release pipeline:
2+
# - Each release starts from timefold-solver by running this GitHub Action.
3+
# - Each individual repository can only start its own release when its dependencies are fully released.
4+
# timefold-solver-enterprise depends on timefold-solver
5+
# timefold-quickstarts depends on timefold-solver
6+
# timefold-website releases last
7+
# - Each individual repository uses 999-SNAPSHOT as its development version, even on micro branches.
8+
#
9+
# Should any of these axioms change, the release pipeline will need to be (significantly) refactored.
10+
# 0.8.x releases existed before this pipeline; they are done differently, similarities are coincidental.
11+
12+
name: Release Community 1.x to Maven Central
13+
on:
14+
workflow_dispatch:
15+
inputs:
16+
version:
17+
description: 'Release version (e.g. 1.31.0)'
18+
required: true
19+
sourceBranch:
20+
description: 'Branch to cut the release from'
21+
default: 1.x
22+
required: true
23+
dryRun:
24+
description: 'Do a dry run?'
25+
default: true
26+
required: true
27+
type: boolean
28+
jobs:
29+
build:
30+
env:
31+
MAVEN_ARGS: "--no-transfer-progress --batch-mode"
32+
RELEASE_BRANCH_NAME: "__timefold_release_branch__"
33+
runs-on: self-hosted
34+
permissions:
35+
contents: write # IMPORTANT: required for action to create release branch
36+
id-token: write # IMPORTANT: mandatory for trusted publishing
37+
attestations: write # IMPORTANT: mandatory for attestations
38+
steps:
39+
- name: Print inputs to the release workflow
40+
run: echo "${{ toJSON(github.event.inputs) }}"
41+
42+
- name: Validate the version
43+
shell: bash
44+
env:
45+
VERSION: ${{ github.event.inputs.version }}
46+
run: |
47+
version="$VERSION"
48+
if [[ "$version" != 1.* ]]; then
49+
echo "The version input '$version' is invalid. This workflow only supports versions starting with '1.'."
50+
exit 1
51+
fi
52+
53+
- name: Checkout timefold-solver
54+
uses: actions/checkout@v6
55+
with:
56+
fetch-depth: 0
57+
ref: ${{ github.event.inputs.sourceBranch }}
58+
59+
- name: Delete release branch (if exists)
60+
continue-on-error: true
61+
run: git push -d origin $RELEASE_BRANCH_NAME
62+
63+
- name: Create release branch and switch to it
64+
run: |
65+
git config user.name "Timefold Release Bot"
66+
git config user.email "release@timefold.ai"
67+
git checkout -b $RELEASE_BRANCH_NAME
68+
69+
- uses: actions/setup-java@v5
70+
with:
71+
java-version: '17'
72+
distribution: 'temurin'
73+
cache: 'maven'
74+
75+
# We skip tests in dry run, to make the process faster.
76+
# Technically, this goes against the main reason for doing a dry run; to eliminate potential problems.
77+
# But unless something catastrophic happened, PR checks on source branch already ensured that all tests pass.
78+
- name: Set release version and build release
79+
env:
80+
NEW_VERSION: ${{ inputs.version }}
81+
DRY_RUN: ${{ inputs.dryRun }}
82+
run: |
83+
./mvnw -Dfull versions:set -DnewVersion="$NEW_VERSION" -DgenerateBackupPoms=false
84+
./mvnw -Dfull deploy -DskipTests=$DRY_RUN -DaltDeploymentRepository=local::default::file://`pwd`/target/staging-deploy
85+
cp docs/target/antora.yml docs/src/antora.yml
86+
git add docs/src/antora.yml
87+
find . -name 'pom.xml' | xargs git add
88+
git commit -m "build: release version ${{ github.event.inputs.version }}"
89+
git push origin $RELEASE_BRANCH_NAME
90+
91+
- name: Run JReleaser
92+
uses: jreleaser/release-action@80ffb38fa759704eed4db5c7fcaae3ac1079473e # v2
93+
env:
94+
JRELEASER_DRY_RUN: ${{ github.event.inputs.dryRun }}
95+
JRELEASER_PROJECT_VERSION: ${{ github.event.inputs.version }}
96+
JRELEASER_GITHUB_TOKEN: ${{ secrets.JRELEASER_GITHUB_TOKEN }}
97+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
98+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}
99+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
100+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVEN_CENTRAL_TOKEN_USER }}
101+
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.JRELEASER_MAVEN_CENTRAL_TOKEN }}
102+
103+
- name: JReleaser release output
104+
uses: actions/upload-artifact@v7
105+
if: always()
106+
with:
107+
name: jreleaser-release
108+
path: |
109+
out/jreleaser/trace.log
110+
out/jreleaser/output.properties

0 commit comments

Comments
 (0)