-
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (115 loc) · 3.99 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
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@v4
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 koverXmlReport
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@v4
- name: Prepare Changelog
id: changelog
run: |
CHANGELOG=$(./gradlew getChangelog --console=plain -q --no-header --no-summary --unreleased --no-empty-sections)
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" >> "$GITHUB_STEP_SUMMARY"
CHANGELOG="${CHANGELOG//$'\n'/'\\n'}"
echo "changelog=$CHANGELOG" >> "$GITHUB_OUTPUT"
- name: Publish to Modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: ./gradlew :modrinthSyncBody :mod:fabric:modrinth :mod:neoforge:modrinth
- name: Publish to GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew copySubJars
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: Publish to Maven
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: ./gradlew publish
- name: Patch Changelog
run: ./gradlew patchChangelog
- name: Build Documentation (Dokka)
run: ./gradlew dokkaGenerate
- 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 CHANGELOG.md
git add docs/
git commit -m "docs: patch docs and changelog for $VERSION"
git push -u origin $BRANCH
gh pr create \
--title "docs(dokka): patch docs and changelog for $VERSION" \
--body "Adds published documentation and changelog 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