-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (157 loc) · 4.64 KB
/
build.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
name: Build
'on':
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
- release/**
permissions:
contents: write
jobs:
version:
needs:
- read-lemmy-version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.6
with:
versionSpec: 5.x
- id: gitversion
name: Use GitVersion
uses: gittools/actions/gitversion/execute@v0.9.6
with:
useConfigFile: true
configFilePath: ./gitversion.yml
- id: version
run: version=${{ needs.read-lemmy-version.outputs.lemmyVersion }}-${{ steps.gitversion.outputs.semVer }} >> $GITHUB_ENV
- name: Display SemVer
run: 'echo "SemVer: ${{ needs.read-lemmy-version.outputs.lemmyVersion }}-${{ steps.gitversion.outputs.semVer }}"'
build:
needs:
- version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: temurin
- name: Build with Gradle
env:
ORG_GRADLE_PROJECT_version: ${{ needs.version.outputs.version }}
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build
- name: Rename AAR
run: mv ./build/libs/jlemmy-${{ needs.version.outputs.version }}.jar ./jlemmy.jar
- uses: actions/upload-artifact@master
with:
name: jlemmy-jar
path: ./jlemmy.jar
release:
permissions:
contents: write
needs:
- version
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: create_release
name: Create Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: v${{ needs.version.outputs.version }}
name: Release ${{ needs.version.outputs.version }}
draft: false
prerelease: ${{ github.ref != 'refs/heads/main' }}
publish-release:
needs:
- version
- release
- build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@master
with:
name: jlemmy-jar
path: ./
- name: Upload Artifact to Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./jlemmy.jar
asset_name: jlemmy-v${{ needs.version.outputs.version }}.jar
asset_content_type: application/zip
publish-sonatype:
permissions:
contents: read
needs:
- version
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: temurin
- name: Build with Gradle
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 }}
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: |-
-Pversion=${{ needs.version.outputs.version }}
-Ppom.url="https://github.com/${{ github.repository }}"
-Ppom.scm.connection="scm:git:git://github.com/${{ github.repository }}"
-Ppom.scm.developerConnection="scm:git:ssh://github.com/${{ github.repository }}"
-Ppom.scm.url="https://github.com/${{ github.repository }}"
publishToCentralPortal --no-daemon
read-lemmy-version:
runs-on: ubuntu-latest
outputs:
lemmyVersion: ${{ steps.version.outputs.lemmyVersion }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true
- id: version
run: |-
regex='"version": "(.*)",'
contents="$(cat ./type-generator/lemmy-js-client/package.json | grep "version")"
if [[ $contents =~ $regex ]]
then
echo ${BASH_REMATCH[1]}
lemmyVersion=${BASH_REMATCH[1]} >> $GITHUB_ENV
else
echo Zoinks Scoob!
exit 1;
fi