Skip to content

Commit a64269e

Browse files
committed
Rework release
1 parent 70971dd commit a64269e

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

.github/workflows/release.yml

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
name: Publish to the Maven Central Repository
22

33
on:
4-
release:
5-
types: [published]
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: Version to be released
8+
required: true
69

710
jobs:
811
publish:
@@ -11,6 +14,25 @@ jobs:
1114

1215
- uses: actions/checkout@v3
1316

17+
- name: Validate ${{ github.event.inputs.version }} release exists
18+
uses: actions/github-script@v2
19+
with:
20+
github-token: ${{secrets.GITHUB_TOKEN}}
21+
script: |
22+
const response = await github.repos.listReleases({
23+
owner: context.repo.owner,
24+
repo: context.repo.repo
25+
});
26+
if (!response) {
27+
throw new Error(`There are no available releases`);
28+
}
29+
for (const release of response.data) {
30+
if (release.name === "${{ github.event.inputs.version }}") {
31+
return
32+
}
33+
}
34+
throw new Error(`Release ${{ github.event.inputs.version }} is not available`);
35+
1436
- name: Set up JDK
1537
uses: actions/setup-java@v3
1638
with:
@@ -22,12 +44,23 @@ jobs:
2244
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
2345
gpg-passphrase: MAVEN_GPG_PASSPHRASE
2446

25-
# - name: Update version
26-
# run: ./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.release.tag_name }}
47+
- name: Update version
48+
run: |
49+
./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.version }} versions:commit
50+
git config user.name "GitHub Action"
51+
git config user.email "[email protected]"
52+
git commit -m "Release ${{ github.event.inputs.version }}"
53+
git push
2754
2855
- name: Publish to the Maven Central Repository
2956
run: ./mvnw --batch-mode --no-transfer-progress -Dgib.disable=true -Ddocker.cleanup.skip=true -P ossrh -DskipTests deploy
3057
env:
3158
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
3259
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
33-
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
60+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
61+
62+
- name: Publish release on GitHub
63+
uses: test-room-7/action-publish-release-drafts@v0
64+
with:
65+
github-token: ${{ secrets.GITHUB_TOKEN }}
66+
tag-name: ${{ github.event.inputs.version }}

0 commit comments

Comments
 (0)