Skip to content

Commit 8213c4b

Browse files
authored
Merge pull request #5 from protegeproject/update_github_workflows
update github workflows
2 parents 37ed998 + b811588 commit 8213c4b

File tree

2 files changed

+87
-4
lines changed

2 files changed

+87
-4
lines changed

.github/workflows/ci.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
name: Java CI
1+
name: Verify
22

3-
on: [push]
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
47

58
jobs:
69
build:
710
runs-on: ubuntu-latest
811

912
steps:
1013
- uses: actions/checkout@v3
14+
with:
15+
token: ${{ secrets.GITHUB_TOKEN }}
1116
- name: Set up JDK 17
1217
uses: actions/setup-java@v3
1318
with:
1419
java-version: '17'
15-
distribution: 'temurin'
20+
distribution: 'adopt'
1621
- name: Build with Maven
17-
run: mvn --batch-mode --update-snapshots package
22+
run: mvn --batch-mode package

.github/workflows/release.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor != 'protegeproject-bot[bot]' }}
12+
steps:
13+
- uses: actions/create-github-app-token@v1
14+
id: app-token
15+
with:
16+
app-id: ${{ vars.PROTEGEPROJECT_BOT_APP_ID }}
17+
private-key: ${{ secrets.PROTEGEPROJECT_BOT_APP_PRIVATE_KEY }}
18+
- uses: actions/checkout@v4
19+
with:
20+
token: ${{ steps.app-token.outputs.token }}
21+
ref: ${{ github.head_ref }}
22+
- name: Set up JDK 17
23+
uses: actions/setup-java@v3
24+
with:
25+
java-version: '17'
26+
distribution: 'adopt'
27+
server-id: ossrh
28+
server-username: OSSRH_USERNAME
29+
server-password: OSSRH_TOKEN
30+
gpg-private-key: ${{secrets.GPG_PRIVATE_KEY}}
31+
gpg-passphrase: GPG_PASSPHRASE
32+
- name: Get current version
33+
id: get-version
34+
run: |
35+
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
36+
echo "Current version: $current_version"
37+
echo "::set-output name=current_version::$current_version"
38+
- name: Bump version
39+
id: bump
40+
run: |
41+
current_version=${{ steps.get-version.outputs.current_version }}
42+
branch=${GITHUB_REF##*/}
43+
echo "Current branch: $branch"
44+
45+
# Extract the base version without suffix
46+
base_version=$(echo $current_version | sed -E 's/(-.*)?$//')
47+
48+
# Increment the base version (assuming semantic versioning)
49+
IFS='.' read -r -a version_parts <<< "$base_version"
50+
version_parts[2]=$((version_parts[2] + 1))
51+
new_base_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
52+
53+
echo "New version: $new_version"
54+
mvn versions:set -DnewVersion=$new_version -DgenerateBackupPoms=false
55+
echo "::set-output name=new_version::$new_version"
56+
- name: Commit new version
57+
run: |
58+
git config --global user.name "github-actions[bot]"
59+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
60+
git add pom.xml
61+
git commit -m "Bump version to ${{ steps.bump.outputs.new_version }}"
62+
git tag ${{ steps.bump.outputs.new_version }}
63+
git push origin HEAD:${GITHUB_REF##*/}
64+
git push origin ${{ steps.bump.outputs.new_version }}
65+
- name: Build with Maven
66+
run: mvn --batch-mode -Prelease deploy
67+
- name: Release
68+
uses: softprops/action-gh-release@v1
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
with:
72+
tag_name: ${{ steps.bump.outputs.new_version }}
73+
generate_release_notes: true
74+
75+
env:
76+
GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}}
77+
OSSRH_USERNAME: ${{secrets.OSSRH_USERNAME}}
78+
OSSRH_TOKEN: ${{secrets.OSSRH_TOKEN}}

0 commit comments

Comments
 (0)