-
-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (127 loc) · 4.4 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
name: Build
on:
push:
branches:
- main
tags:
- v*
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
dependency-graph: generate-and-submit
artifact-retention-days: 1
- name: Set Gradle Wrapper Executable
run: chmod +x gradlew
- name: Build and Test
run: ./gradlew build test spotlessCheck
publish:
name: Publish
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'wanderia/netlib'
needs:
- build
permissions:
contents: write
pull-requests: write
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Set Gradle Wrapper Executable
run: chmod +x gradlew
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Prepare Changelog
id: changelog
run: |
CHANGELOG=$(./gradlew getChangelog --console=plain -q --no-header --no-summary --unreleased --no-empty-sections)
CHANGELOG="${CHANGELOG//$'\n'/'\\n'}"
CHANGELOG="${CHANGELOG//$'\r'/''}"
CHANGELOG=$(sed -E 's/Downloading https:\/\/services\.gradle\.org\/distributions\/gradle-[0-9\\.]*-bin\.zip\\\\n[\\.0-9%]*\\\\n//' <<< $CHANGELOG)
echo "changelog=$CHANGELOG" >> "$GITHUB_OUTPUT"
echo "# Changelog" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "$CHANGELOG" >> "$GITHUB_STEP_SUMMARY"
- name: Publish to Modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: ./gradlew modrinth modrinthSyncBody
- name: Publish to GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CHANGELOG="${{ steps.changelog.outputs.changelog }}"
NL=$'\n'
CHANGELOG=${CHANGELOG//$'\\n'/"${NL}"}
echo "$CHANGELOG" >> "notes.txt"
gh release create ${{ github.ref_name }} **/build/libs/**.jar --notes-file notes.txt
- name: Patch Changelog
run: ./gradlew patchChangelog
- name: Create Patched Changelog Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ github.ref_name }}"
BRANCH="changelog-patch/$VERSION"
git config user.email "github-actions@github.com"
git config user.name "github-actions"
git checkout -b $BRANCH
git add CHANGELOG.md
git commit -m "docs(changelog): patch changelog for $VERSION"
git push -u origin $BRANCH
gh pr create \
--title "docs(changelog): patch changelog for $VERSION" \
--body-file notes.txt \
--base main \
--head "$BRANCH"
- name: Build Documentation (DokkaHtml)
run: ./gradlew dokkaHtml
- name: Create Documentation Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ github.ref_name }}"
BRANCH="documentation-patch/$VERSION"
git config user.email "github-actions@github.com"
git config user.name "github-actions"
git checkout -b $BRANCH
git add docs/
git commit -m "docs(dokka): patch docs for $VERSION"
git push -u origin $BRANCH
gh pr create \
--title "docs(dokka): patch docs for $VERSION" \
--body "Adds published documentation for $VERSION" \
--base main \
--head "$BRANCH"
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload Dokka Artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs-publishing/
- name: Deploy Dokka Artifact to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4