Skip to content

Commit e4ff985

Browse files
committed
update workflow
1 parent 82a5b82 commit e4ff985

3 files changed

Lines changed: 194 additions & 38 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write # needed for release + deleting branches
14+
pages: write # needed to publish to GitHub Pages
15+
id-token: write # required for GitHub Pages deployment
16+
packages: write # needed for Maven Central deploy
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Java
23+
uses: actions/setup-java@v4
24+
with:
25+
distribution: temurin
26+
java-version: 17
27+
cache: maven
28+
server-id: central
29+
server-username: MAVEN_USERNAME
30+
server-password: MAVEN_PASSWORD
31+
32+
- name: Import GPG key
33+
run: |
34+
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
35+
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg.conf
36+
env:
37+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
38+
39+
- name: Set GPG passphrase
40+
run: |
41+
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
42+
env:
43+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
44+
45+
- name: Deploy to Maven Central (signed)
46+
run: mvn -B clean deploy -Pcentral -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Dgpg.executable=gpg
47+
48+
- name: Build fat jar
49+
run: mvn -B clean package -Pall
50+
51+
- name: Get project version
52+
id: get-version
53+
run: |
54+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
55+
echo "VERSION=$VERSION" >> $GITHUB_ENV
56+
echo "Detected version: $VERSION"
57+
58+
- name: Create GitHub Release
59+
uses: softprops/action-gh-release@v2
60+
with:
61+
tag_name: v${{ env.VERSION }}
62+
name: Release v${{ env.VERSION }}
63+
body: "Automated release of version ${{ env.VERSION }}"
64+
files: |
65+
target/*-all.jar
66+
67+
- name: Generate Javadocs
68+
run: mvn -B javadoc:javadoc
69+
70+
- name: Setup Pages
71+
uses: actions/configure-pages@v5
72+
73+
- name: Upload Javadocs artifact
74+
uses: actions/upload-pages-artifact@v3
75+
with:
76+
path: target/site/apidocs
77+
78+
- name: Deploy Javadocs to GitHub Pages
79+
id: deployment
80+
uses: actions/deploy-pages@v4
81+
82+
- name: Delete changeset branch
83+
run: |
84+
echo "Deleting branch 'changeset'"
85+
git push origin --delete changeset || true
86+

.github/workflows/version.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Version Bump
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- ".changesets/**"
9+
10+
jobs:
11+
bump-version:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Java
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: temurin
22+
java-version: 17
23+
24+
- name: Detect change types and build PR body
25+
id: detect
26+
run: |
27+
FILES=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep '.changesets/' || true)
28+
if [ -z "$FILES" ]; then
29+
echo "No changeset files found"
30+
exit 0
31+
fi
32+
33+
# Initialize variables
34+
TYPE_PRIORITY=0
35+
BODY=""
36+
37+
for FILE in $FILES; do
38+
echo "Processing $FILE"
39+
40+
FILE_TYPE=$(grep '^type:' "$FILE" | awk '{print $2}')
41+
case "$FILE_TYPE" in
42+
patch) PRIORITY=1 ;;
43+
minor) PRIORITY=2 ;;
44+
major) PRIORITY=3 ;;
45+
*) echo "Unknown type: $FILE_TYPE"; exit 1 ;;
46+
esac
47+
48+
if [ $PRIORITY -gt $TYPE_PRIORITY ]; then
49+
TYPE_PRIORITY=$PRIORITY
50+
TYPE=$FILE_TYPE
51+
fi
52+
53+
CONTENT=$(sed '/^type:/d' "$FILE" | sed '/^---$/d')
54+
BODY="$BODY\n\n$CONTENT"
55+
done
56+
57+
echo "TYPE=$TYPE" >> $GITHUB_ENV
58+
echo "BODY<<EOF" >> $GITHUB_ENV
59+
echo -e "$BODY" >> $GITHUB_ENV
60+
echo "EOF" >> $GITHUB_ENV
61+
62+
echo "Final detected type: $TYPE"
63+
echo "PR body:"
64+
echo -e "$BODY"
65+
66+
- name: Bump version
67+
run: |
68+
case "$TYPE" in
69+
patch) mvn versions:set -DnextSnapshot=true -DgenerateBackupPoms=false ;;
70+
minor) mvn build-helper:parse-version versions:set \
71+
-DnewVersion=\${parsedVersion.majorVersion}.\$((parsedVersion.minorVersion+1)).0-SNAPSHOT \
72+
-DgenerateBackupPoms=false ;;
73+
major) mvn build-helper:parse-version versions:set \
74+
-DnewVersion=\$((parsedVersion.majorVersion+1)).0.0-SNAPSHOT \
75+
-DgenerateBackupPoms=false ;;
76+
*) echo "Unknown type: $TYPE"; exit 1 ;;
77+
esac
78+
mvn versions:commit
79+
80+
- name: Get new project version
81+
id: get-version
82+
run: |
83+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
84+
echo "VERSION=$VERSION" >> $GITHUB_ENV
85+
echo "New version: $VERSION"
86+
87+
- name: Delete changeset files
88+
run: |
89+
rm -f .changesets/*
90+
echo "Removed processed changeset files."
91+
92+
- name: Commit and push changes
93+
run: |
94+
git config user.name "github-actions[bot]"
95+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
96+
git checkout -B changeset
97+
git add pom.xml .changesets
98+
git commit -m "chore: release v${{ env.VERSION }}"
99+
git push origin changeset --force
100+
101+
- name: Create Pull Request
102+
uses: peter-evans/create-pull-request@v6
103+
with:
104+
commit-message: "chore: release v${{ env.VERSION }}"
105+
branch: changeset
106+
title: "Release v${{ env.VERSION }}"
107+
body: ${{ env.BODY }}
108+
labels: version

0 commit comments

Comments
 (0)