This repository was archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
233 lines (200 loc) · 7.9 KB
/
release.yml
File metadata and controls
233 lines (200 loc) · 7.9 KB
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
224
225
226
227
228
229
230
231
232
233
name: Release
on:
push:
branches: [ master ]
permissions:
contents: write
pull-requests: write
jobs:
check_code: # Validates the code (see checkBuild.yml)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
server-id: proprietary-xdev-dependencies
server-username: GH_PACKAGES_READ_USERNAME # env variable name for username of Artifactory server
server-password: GH_PACKAGES_READ_TOKEN # env variable name for Artifactory access token
- name: Build with Maven
run: mvn -B clean verify
env:
GH_PACKAGES_READ_USERNAME: ${{ secrets.GH_PACKAGES_READ_USERNAME }}
GH_PACKAGES_READ_TOKEN: ${{ secrets.GH_PACKAGES_READ_TOKEN }}
- name: Check for uncommited changes
run: |
if [[ "$(git status --porcelain)" != "" ]]; then
echo ----------------------------------------
echo git status
echo ----------------------------------------
git status
echo ----------------------------------------
echo git diff
echo ----------------------------------------
git diff
echo ----------------------------------------
echo Troubleshooting
echo ----------------------------------------
echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && mvn -B clean verify"
exit 1
fi
prepare_release:
runs-on: ubuntu-latest
needs: [check_code]
outputs:
upload_url: ${{ steps.create_draft.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- name: Configure Git
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
- name: Un-SNAP
run: mvn -B versions:set -DremoveSnapshot -DgenerateBackupPoms=false
- name: Get version
id: version
run: |
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "release=$version" >> $GITHUB_OUTPUT
echo "releasenumber=${version//[!0-9]/}" >> $GITHUB_OUTPUT
- name: Commit and Push
run: |
git add -A
git commit -m "Release ${{ steps.version.outputs.release }}"
git push origin
git tag v${{ steps.version.outputs.release }}
git push origin --tags
- name: Create Release
id: create_release
uses: shogo82148/actions-create-release@v1
with:
tag_name: v${{ steps.version.outputs.release }}
release_name: v${{ steps.version.outputs.release }}
commitish: master
body: |
## [Changelog](https://github.com/xdev-software/${{ github.event.repository.name }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }})
See [Changelog#v${{ steps.version.outputs.release }}](https://github.com/xdev-software/${{ github.event.repository.name }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) for more information.
## Installation
Add the following lines to your pom:
```XML
<dependency>
<groupId>com.xdev-software</groupId>
<artifactId>${{ github.event.repository.name }}</artifactId>
<version>${{ steps.version.outputs.release }}</version>
</dependency>
```
publish_central: # Publish the code to central
runs-on: ubuntu-latest
needs: [prepare_release]
steps:
- uses: actions/checkout@v4
- name: Init Git and pull
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git pull
- name: Set up JDK OSSRH
uses: actions/setup-java@v4
with: # running setup-java again overwrites the settings.xml
distribution: 'temurin'
java-version: '8'
# server-id: ossrh
# server-username: MAVEN_CENTRAL_USERNAME
# server-password: MAVEN_CENTRAL_TOKEN
# gpg-passphrase: MAVEN_GPG_PASSPHRASE
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
# Due to https://github.com/actions/setup-java/issues/85 we can only
# add ONE server using setup-java...
overwrite-settings: false
# ... so let's simply copy a predefined settings.xml file into the m2 folder
# until GH makes it work
- name: Copy predefined settings into home m2 folder
run: |
mkdir -p ~/.m2/
cp .github/workflows/maven/m2-settings-release.xml ~/.m2/settings.xml
- name: Publish to OSSRH
run: mvn -B deploy -Pxdev-build,ossrh
env:
GH_PACKAGES_READ_USERNAME: ${{ secrets.GH_PACKAGES_READ_USERNAME }}
GH_PACKAGES_READ_TOKEN: ${{ secrets.GH_PACKAGES_READ_TOKEN }}
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
publish-pages:
name: Publish dependencies and licenses to github pages
runs-on: ubuntu-latest
needs: [prepare_release]
steps:
- uses: actions/checkout@v4
- name: Init Git and pull
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git pull
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
server-id: proprietary-xdev-dependencies
server-username: GH_PACKAGES_READ_USERNAME # env variable name for username of Artifactory server
server-password: GH_PACKAGES_READ_TOKEN # env variable name for Artifactory access token
- name: Build dependencies/licenses files
run: mvn -B project-info-reports:dependencies
env:
GH_PACKAGES_READ_USERNAME: ${{ secrets.GH_PACKAGES_READ_USERNAME }}
GH_PACKAGES_READ_TOKEN: ${{ secrets.GH_PACKAGES_READ_TOKEN }}
- name: Upload licenses - Upload Artifact
uses: actions/upload-artifact@v3
with:
name: dependencies-licenses
path: target/site
- name: Generate docs/dependencies dir
run: mkdir -p docs/dependencies
- name: Move built files into docs/dependencies
run: mv target/site/* docs/dependencies
- name: Rename dependencies.html to index.html
working-directory: docs/dependencies
run: mv dependencies.html index.html
- name: Copy Readme into docs (as index.md)
run: cp README.md docs/index.md
- name: Configure Pages
working-directory: docs
run: |-
echo "theme: jekyll-theme-tactile" > _config.yml
- name: Deploy to Github pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
enable_jekyll: true
after_release:
runs-on: ubuntu-latest
needs: [publish_central]
steps:
- uses: actions/checkout@v4
- name: Init Git and pull
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git pull
- name: Inc Version and SNAP root
run: mvn -B build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DgenerateBackupPoms=false -DnextSnapshot=true
- name: Git Commit and Push
run: |
git add -A
git commit -m "Preparing for next development iteration"
git push origin
- name: pull-request
env:
GH_TOKEN: ${{ github.token }}
run: |
gh_pr_up() {
gh pr create "$@" || gh pr edit "$@"
}
gh_pr_up -B "develop" \
--title "Sync back" \
--body "An automated PR to sync changes back"