-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (130 loc) · 3.57 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
name: Build
'on':
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
- release/**
permissions:
contents: write
jobs:
version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
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]}
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
else
echo Zoinks Scoob!
exit 1;
fi
build:
needs:
- version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: temurin
- name: Setup gradle
uses: gradle/actions/setup-gradle@v3
- name: Build with Gradle
run: ./gradlew build
- name: Rename AAR
run: mv ./build/libs/jlemmy-${{ needs.version.outputs.version }}.jar ./jlemmy.jar
- uses: actions/upload-artifact@v4
with:
name: jlemmy-jar
path: ./jlemmy.jar
release:
permissions:
contents: write
needs:
- version
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}}
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create tag for release
uses: rickstaa/action-create-tag@v1
with:
tag: v${{ needs.version.outputs.version }}
- 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@v4
with:
name: jlemmy-jar
path: ./
- name: Upload Artifact to Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: shogo82148/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@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: temurin
- name: Setup gradle
uses: gradle/actions/setup-gradle@v3
- name: Build with Gradle
run: |-
./gradlew -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