Skip to content

Commit 8e5662a

Browse files
committed
feat: added releasing to maven central
1 parent bed0e32 commit 8e5662a

2 files changed

Lines changed: 261 additions & 66 deletions

File tree

.github/workflows/release.yml

Lines changed: 103 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6-
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
7-
8-
name: Parsek i18n Plugin Release
1+
name: Parsek Plugin Release
92

103
on:
114
push:
@@ -18,10 +11,10 @@ jobs:
1811
get-next-version:
1912
runs-on: ubuntu-latest
2013
permissions:
21-
contents: write # to be able to publish a GitHub release
22-
issues: write # to be able to comment on released issues
23-
pull-requests: write # to be able to comment on released pull requests
24-
id-token: write # to enable use of OIDC for npm provenance
14+
contents: write
15+
issues: write
16+
pull-requests: write
17+
id-token: write
2518
steps:
2619
- uses: actions/checkout@v4
2720

@@ -37,45 +30,125 @@ jobs:
3730
env:
3831
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
3932

40-
- name: Echo new_tag_version
41-
run: |
42-
echo "Extracted Tag Version: ${{ steps.get-next-version.outputs.new_tag_version }}"
43-
env:
44-
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
4533
outputs:
4634
new_tag_version: ${{ steps.get-next-version.outputs.new_tag_version }}
4735

48-
build-and-release:
36+
build:
4937
runs-on: ubuntu-latest
5038
needs: get-next-version
51-
if: ${{needs.get-next-version.outputs.new_tag_version != ''}}
39+
if: ${{ needs.get-next-version.outputs.new_tag_version != '' }}
5240
permissions:
53-
contents: write # to be able to publish a GitHub release
54-
issues: write # to be able to comment on released issues
55-
pull-requests: write # to be able to comment on released pull requests
56-
id-token: write # to enable use of OIDC for npm provenance
41+
contents: write
5742
steps:
5843
- uses: actions/checkout@v4
5944

60-
- uses: actions/setup-java@v3
45+
- uses: actions/setup-java@v4
6146
with:
6247
distribution: temurin
6348
java-version: 21
6449

50+
- name: Setup Gradle
51+
uses: gradle/actions/setup-gradle@v4
52+
6553
- name: Build with Gradle
66-
uses: gradle/actions/setup-gradle@v3
54+
run: |
55+
./gradlew build -Pversion=${{ needs.get-next-version.outputs.new_tag_version }}
56+
57+
- name: Upload build artifacts
58+
uses: actions/upload-artifact@v4
6759
with:
68-
arguments: |
69-
build
70-
-Pversion=${{ needs.get-next-version.outputs.new_tag_version }}
71-
-PtimeStamp=${{ steps.time.outputs.time }}
60+
name: build-artifacts
61+
path: build/libs/
62+
63+
gh-release:
64+
name: GH Release
65+
runs-on: ubuntu-latest
66+
needs: build
67+
if: ${{ needs.get-next-version.outputs.new_tag_version != '' }}
68+
permissions:
69+
contents: write
70+
issues: write
71+
pull-requests: write
72+
id-token: write
73+
steps:
74+
- uses: actions/checkout@v4
7275

7376
- name: Setup Node.js
7477
uses: actions/setup-node@v3
7578
with:
7679
node-version: "lts/*"
7780

78-
- name: Release
81+
- name: Download build artifacts
82+
uses: actions/download-artifact@v4
83+
with:
84+
name: build-artifacts
85+
path: build/libs/
86+
87+
- name: Verify downloaded artifacts
88+
run: |
89+
echo "Contents of build/libs:"
90+
ls -la build/libs || true
91+
92+
- name: Create GitHub Release with semantic-release
7993
env:
8094
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
8195
run: npx semantic-release
96+
97+
maven-central-deploy:
98+
name: Maven Central Deploy
99+
runs-on: ubuntu-latest
100+
needs: [ get-next-version, build, gh-release ]
101+
if: ${{ needs.get-next-version.outputs.new_tag_version != '' }}
102+
permissions:
103+
contents: write
104+
issues: write
105+
pull-requests: write
106+
id-token: write
107+
steps:
108+
- uses: actions/checkout@v4
109+
110+
- uses: actions/setup-java@v4
111+
with:
112+
distribution: temurin
113+
java-version: 21
114+
115+
- name: Setup Gradle
116+
uses: gradle/actions/setup-gradle@v4
117+
118+
- name: Download build artifacts
119+
uses: actions/download-artifact@v4
120+
with:
121+
name: build-artifacts
122+
path: build/libs/
123+
124+
- name: Verify downloaded artifacts
125+
run: ls -R build/libs
126+
127+
- name: Publish to Maven Central with JReleaser
128+
run: |
129+
./gradlew -Pversion=${{ needs.get-next-version.outputs.new_tag_version }} publish
130+
env:
131+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
132+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
133+
134+
135+
- name: Deploy to Maven Central with JReleaser
136+
id: jreleaser
137+
run: |
138+
./gradlew -Pversion=${{ needs.get-next-version.outputs.new_tag_version }} jreleaserDeploy
139+
env:
140+
JRELEASER_GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
141+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
142+
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.MAVENCENTRAL_TOKEN }}
143+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
144+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
145+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
146+
147+
- name: Upload JReleaser logs
148+
if: always()
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: jreleaser-logs
152+
path: |
153+
build/jreleaser/trace.log
154+
build/jreleaser/output.properties

0 commit comments

Comments
 (0)