Skip to content

Commit a0056b2

Browse files
authored
release workflow (#310)
1 parent c8043b8 commit a0056b2

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release PR auto-merge
2+
on: pull_request
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'github-actions[bot]'}}
12+
steps:
13+
- name: Check PR Title
14+
run: |
15+
PR_TITLE="${{ github.event.pull_request.title }}"
16+
REQUIRED_PREFIX="Release: Bump version to"
17+
18+
if [[ ! "$PR_TITLE" == "$REQUIRED_PREFIX"* ]]; then
19+
echo "::error::PR title does not start with \"$REQUIRED_PREFIX\""
20+
echo "Current PR title: \"$PR_TITLE\""
21+
exit 1
22+
fi
23+
echo "PR title check passed."
24+
- name: Approve a PR
25+
run: gh pr review --approve "$PR_URL"
26+
env:
27+
PR_URL: ${{github.event.pull_request.html_url}}
28+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
29+
# Enable for automerge
30+
- name: Enable auto-merge for Dependabot PRs
31+
run: gh pr merge --auto --merge "$PR_URL"
32+
env:
33+
PR_URL: ${{github.event.pull_request.html_url}}
34+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release Workflow
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
new_version:
7+
description: 'New version to set (e.g., 1.0-RC1, 1.0)'
8+
default: 2.11
9+
required: true
10+
type: string
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
# Protection rules for this environment are set in the repository settings.
20+
environment: maven
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Java and Maven
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: '17'
27+
distribution: 'zulu'
28+
server-id: central
29+
server-username: ${{ secrets.MAVEN_USERNAME }}
30+
server-password: ${{ secrets.MAVEN_PASSWORD }}
31+
# GPG Key setup for signing artifacts
32+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
33+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
34+
35+
- name: Maven cache
36+
uses: actions/cache@v4
37+
env:
38+
cache-name: maven-cache
39+
with:
40+
path: ~/.m2
41+
key: build-${{ env.cache-name }}
42+
43+
- name: Bump version in pom.xml
44+
run: mvn versions:set -DnewVersion=${{ github.event.inputs.new_version }} -DgenerateBackupPoms=false
45+
46+
- name: Deploy JAR to Maven Central
47+
run: mvn clean deploy -Pcentral
48+
49+
- name: Create Pull Request for Version Bump
50+
uses: peter-evans/create-pull-request@v6
51+
with:
52+
token: ${{ secrets.GITHUB_TOKEN }}
53+
commit-message: "Version ${{ github.event.inputs.new_version }}"
54+
branch: "release/${{ github.event.inputs.new_version }}"
55+
title: "Release: Version ${{ github.event.inputs.new_version }}"
56+
body: |
57+
Release version `${{ github.event.inputs.new_version }}` to be deployed.
58+
base: main

0 commit comments

Comments
 (0)