-
-
Notifications
You must be signed in to change notification settings - Fork 114
223 lines (189 loc) · 8.24 KB
/
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: Release
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release version'
default: 'X.X.X'
required: true
release_branch:
description: 'Release branch'
default: 'main'
required: true
publish_library:
description: 'Publish library'
default: 'Y'
required: true
publish_gradle_plugin:
description: 'Publish Gradle Plugin'
default: 'Y'
required: true
publish_maven_plugin:
description: 'Publish Maven Plugin'
default: 'Y'
required: true
publish_sbt_plugin:
description: 'Publish SBT Plugin'
default: 'Y'
required: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.release_branch }}
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 1.8
distribution: 'adopt'
- name: Gradle cache
uses: actions/cache@v4
with:
path: ~/.gradle
key: gradle
- name: Maven cache
uses: actions/cache@v4
with:
path: ~/.m2
key: m2
- name: Loading ivy cache
uses: actions/cache@v4
with:
path: ~/.ivy2/cache
key: ${{ runner.os }}-ivy-${{ hashFiles('**/*.sbt') }}
restore-keys: |
${{ runner.os }}-ivy-
- name: Set up GPG
run: |
echo ${{ github.workspace }}
# gpg init
mkdir ~/.gnupg && echo use-agent >> ~/.gnupg/gpg.conf
echo pinentry-mode loopback >> ~/.gnupg/gpg.conf
echo allow-loopback-pinentry >> ~/.gnupg/gpg-agent.conf
echo RELOADAGENT | gpg-connect-agent
echo ${SIGNING_KEY} | awk '{gsub(/\\n/,"\n")}1'| gpg --dearmor > ${{ github.workspace }}/secretKeyRingFile.gpg
gpg --import --pinentry-mode loopback --batch --passphrase '${SIGNING_PASSWORD}' ${{ github.workspace }}/secretKeyRingFile.gpg
ls -al ${{ github.workspace }}
ls -al ~/.gnupg/
env:
SIGNING_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
SIGNING_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
- name: Configure Git
run: |
git config --global user.name 'Bogdan Kobylynskyi'
git config --global user.email 'kobylynskyi@users.noreply.github.com'
- name: Update version of Maven plugin sub-project
working-directory: plugins/maven/graphql-java-codegen-maven-plugin
run: mvn versions:set -DnewVersion="${{ github.event.inputs.release_version }}" -DgenerateBackupPoms=false
- name: Update version of Maven example client sub-project
working-directory: plugins/maven/example-client
run: mvn versions:set -DnewVersion="${{ github.event.inputs.release_version }}" -DgenerateBackupPoms=false
- name: Update version of Maven example server sub-project
working-directory: plugins/maven/example-server
run: mvn versions:set -DnewVersion="${{ github.event.inputs.release_version }}" -DgenerateBackupPoms=false
- name: Update versions of all Gradle/SBT sub-projects
run: scripts/update-release-version-in-build-files.sh ${{ github.event.inputs.release_version }}
- name: Update versions in all README files
run: scripts/update-release-version-in-readme.sh ${{ github.event.inputs.release_version }}
#
# VERSIONS UPDATED
# NOW WE ARE READY FOR THE FINAL BUILD
#
- name: Build library
run: ./gradlew build publishToMavenLocal publishAllPublicationsToIvyRepository --warning-mode all
- name: Build maven plugin
if: github.event.inputs.publish_maven_plugin == 'Y'
working-directory: plugins/maven/graphql-java-codegen-maven-plugin
run: mvn install
- name: Build maven example-server
if: github.event.inputs.publish_maven_plugin == 'Y'
working-directory: plugins/maven/example-server
run: mvn package
- name: Build maven example-client
if: github.event.inputs.publish_maven_plugin == 'Y'
working-directory: plugins/maven/example-client
run: mvn package
- name: Build gradle plugin
run: ./gradlew -p plugins/gradle/graphql-java-codegen-gradle-plugin build publishToMavenLocal --warning-mode all
- name: Build gradle example-server
if: github.event.inputs.publish_gradle_plugin == 'Y'
run: ./gradlew -p plugins/gradle/example-server test --warning-mode all
- name: Build gradle example-client
if: github.event.inputs.publish_gradle_plugin == 'Y'
run: ./gradlew -p plugins/gradle/example-client test --warning-mode all
- name: Build gradle example-client-kotlin
if: github.event.inputs.publish_gradle_plugin == 'Y'
run: ./gradlew -p plugins/gradle/example-client-kotlin build --warning-mode all
- name: Build sbt plugin
if: github.event.inputs.publish_sbt_plugin == 'Y'
working-directory: plugins/sbt/graphql-java-codegen-sbt-plugin
run: sbt compile publishLocal --debug
- name: Build sbt test
if: github.event.inputs.publish_sbt_plugin == 'Y'
working-directory: plugins/sbt/graphql-java-codegen-sbt-plugin
run: sbt scripted
#
# BUILD OF RELEASE VERSION COMPLETED
# SO WE CAN COMMIT THEM
#
- name: Update version of Maven plugin to SNAPSHOT (required by publish-plugin)
if: github.event.inputs.publish_maven_plugin == 'Y'
working-directory: plugins/maven/graphql-java-codegen-maven-plugin
run: mvn versions:set -DnewVersion="${{ github.event.inputs.release_version }}-SNAPSHOT" -DgenerateBackupPoms=false
- name: Commit release version
run: git commit -am "Bump version to ${{ github.event.inputs.release_version }}"
#
# VERSIONS ARE IN THE RELEASE STATE AND READY TO PUBLISH
#
- name: Release library
if: github.event.inputs.publish_library == 'Y'
run: |
./gradlew publish \
-Dorg.gradle.internal.publish.checksums.insecure=true \
-PsonatypeUsername=${{ secrets.OSSRH_USERNAME }} \
-PsonatypePassword=${{ secrets.OSSRH_PASSWORD }} \
-Psigning.keyId=${{ secrets.OSSRH_GPG_SECRET_KEY_ID }} \
-Psigning.password=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} \
-Psigning.secretKeyRingFile=${{ github.workspace }}/secretKeyRingFile.gpg
- name: Release Gradle plugin
if: github.event.inputs.publish_gradle_plugin == 'Y'
run: |
./gradlew -p plugins/gradle/graphql-java-codegen-gradle-plugin publishPlugins \
-Dorg.gradle.internal.publish.checksums.insecure=true \
-Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY}} \
-Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}
- name: Release Maven plugin
if: github.event.inputs.publish_maven_plugin == 'Y'
working-directory: plugins/maven/graphql-java-codegen-maven-plugin
run: |
mvn \
--settings .maven.xml \
--no-transfer-progress \
--batch-mode \
-Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} \
release:clean release:prepare release:perform
env:
GPG_EXECUTABLE: gpg
GPG_SECRET_KEYS: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
SONATYPE_USER: ${{ secrets.OSSRH_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
- name: Release SBT plugin
if: github.event.inputs.publish_sbt_plugin == 'Y'
working-directory: plugins/sbt/graphql-java-codegen-sbt-plugin
run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
#
# PUBLISH OF RELEASE VERSION COMPLETED
# NOW PUSHING THE RELEASE VERSION BACK TO THE REPOSITORY
#
- name: Push release version
run: |
git push
git push --tags