-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (72 loc) · 2.94 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Publish
on:
pull_request:
branches: [ "main" ]
types: [ "closed" ]
jobs:
deploy:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- uses: actions/checkout@v3
- name: Cache gradle
uses: gradle/gradle-build-action@v2
- name: Get release-label
id: release-label
uses: actions-ecosystem/action-release-label@v1
with:
label_prefix: release/
- name: Get latest tag
id: get-latest-tag
if: ${{ steps.release-label.outputs.level != null }}
uses: actions-ecosystem/action-get-latest-tag@v1
with:
semver_only: true
- name: Bump semver
id: bump-semver
if: ${{ steps.release-label.outputs.level != null }}
uses: actions-ecosystem/action-bump-semver@v1
with:
current_version: ${{ steps.get-latest-tag.outputs.tag }}
level: ${{ steps.release-label.outputs.level }}
- name: Setup JDK 17
uses: graalvm/setup-graalvm@v1
with:
version: "latest"
java-version: "17"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish
if: ${{ steps.bump-semver.outputs.new_version != null }}
id: publish
run: |
SEMANTIC_NEW_VERSION=$(echo ${{ steps.bump-semver.outputs.new_version }} | sed -e 's/^v//')
./gradlew -Pmcorouhlin.version=$SEMANTIC_NEW_VERSION publishToSonatype closeAndReleaseSonatypeStagingRepository
echo "::set-output name=new_semantic_version::${SEMANTIC_NEW_VERSION}"
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
- name: Push tag
if: ${{ steps.bump-semver.outputs.new_version != null }}
uses: actions-ecosystem/action-push-tag@v1
with:
tag: ${{ steps.bump-semver.outputs.new_version }}
message: '${{ steps.bump-semver.outputs.new_version }}(PR #${{ github.event.pull_request.number }}): ${{ github.event.pull_request.title }}'
- name: Comment new version to PR
if: ${{ steps.bump-semver.outputs.new_version != null }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
URL: ${{ github.event.pull_request.html_url }}
VERSION: ${{ steps.publish.outputs.new_semantic_version }}
run: |
cat << EOS > comments
## v${VERSION} is now available!
To use this version, please write dependencies in \`build.gradle.kts\` as
\`\`\`
implementation("land.vani.mcorouhlin:mcorouhlin-api:${VERSION}")
implementation("land.vani.mcorouhlin:mcorouhlin-paper:${VERSION}")
\`\`\`
EOS
gh pr comment "${URL}" --body-file ./comments