-
Notifications
You must be signed in to change notification settings - Fork 25
184 lines (152 loc) · 5.83 KB
/
publish-release.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# This workflow will publish the release to Maven Central Repository
name: Publish Release
on:
release:
types: [published]
jobs:
build:
name: 🏗️ Build Release
permissions:
contents: write
runs-on: ubuntu-latest
if: github.repository == 'w3stling/rssreader'
steps:
- name: Checkout repository ⚙️
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Setup Java 17 ⚙️
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle dependencies cache ⚙️
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts') }}
- name: Setup Gradle wrapper cache ⚙️
uses: actions/cache@v4
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Validate Gradle wrapper ⚙️
uses: gradle/actions/wrapper-validation@v4
- name: Version number 🔢
run: |
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3 | cut -c2-)
echo "New version: ${NEW_VERSION}"
echo "new_version=${NEW_VERSION}" >> $GITHUB_ENV
echo "year=$(date +%Y)" >> $GITHUB_ENV
- name: Update README.md 📝
uses: bluwy/substitute-string-action@v3
with:
_input-file: './.github/README-template.md'
_output-file: ./README.md
_format-key: '%%key%%'
env:
INPUT_VERSION: ${{ env.new_version }}
INPUT_YEAR: ${{ env.year }}
- name: Commit README.md
uses: stefanzweifel/git-auto-commit-action@v5
id: auto-commit-action-readme
with:
commit_message: Update version to ${{ env.new_version }}
file_pattern: README.md
branch: master
- name: "README.md - changes have been detected 🔍"
if: steps.auto-commit-action-readme.outputs.changes_detected == 'true'
run: echo "Updated README.md with release version ${{ env.new_version }} ✅"
- name: Build release 🏗️
run: ./gradlew clean build javadoc -x test
documentation:
name: 📚 Publish Javadoc
needs: [build]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository ⚙️
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Setup Java 17 ⚙️
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle dependencies cache ⚙️
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts') }}
- name: Setup Gradle wrapper cache ⚙️
uses: actions/cache@v4
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Validate Gradle wrapper ⚙️
uses: gradle/actions/wrapper-validation@v4
- name: Version number 🔢
run: |
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3 | cut -c2-)
echo "New version: ${NEW_VERSION}"
echo "new_version=${NEW_VERSION}" >> $GITHUB_ENV
echo "year=$(date +%Y)" >> $GITHUB_ENV
- name: Generate Javadoc 📝
run: ./gradlew javadoc
- name: Deploy Javadoc 📚
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: build/docs/javadoc
target-folder: javadoc/${{ env.new_version }}
commit-message: Publishing javadoc
clean: true
dry-run: false
publish-release:
needs: [build]
name: 🚀 Publish Release
permissions:
contents: write
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout repository ⚙️
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Setup Java 17 ⚙️
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle dependencies cache ⚙️
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle', '**/*.gradle.kts') }}
- name: Setup Gradle wrapper cache ⚙️
uses: actions/cache@v4
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Validate Gradle wrapper ⚙️
uses: gradle/actions/wrapper-validation@v4
- name: Version number 🔢
run: |
NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3 | cut -c2-)
echo "New version: ${NEW_VERSION}"
echo "new_version=${NEW_VERSION}" >> $GITHUB_ENV
echo "year=$(date +%Y)" >> $GITHUB_ENV
- name: Publish release build 🚀
env:
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PGP_SECRET }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.PGP_PASSPHRASE }}
run: |
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Pversion=${{ env.new_version }}