Skip to content

Commit df60ff8

Browse files
committed
Add github workflows
1 parent dff3565 commit df60ff8

3 files changed

Lines changed: 218 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: build
2+
3+
on: [ pull_request, push ]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
java: [
10+
21 # Current LTS
11+
]
12+
os: [ ubuntu-latest ]
13+
runs-on: ${{ matrix.os }}
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
- name: Validate Gradle Wrapper
18+
uses: gradle/actions/wrapper-validation@v3
19+
- name: Gradle Cache
20+
uses: actions/cache@v4
21+
with:
22+
path: |
23+
~/.gradle/caches
24+
~/.gradle/wrapper
25+
.gradle/loom-cache
26+
build/
27+
*/build/
28+
*/*/build/
29+
key: ${{ runner.os }}-jdk${{ matrix.java }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle.properties', '**/gradle-wrapper.properties', '.github/workflows/build.yml') }}
30+
- name: Setup JDK ${{ matrix.java }}
31+
uses: actions/setup-java@v4
32+
with:
33+
distribution: 'temurin'
34+
java-version: ${{ matrix.java }}
35+
- name: Make Gradle Wrapper Executable
36+
if: ${{ runner.os != 'Windows' }}
37+
run: chmod +x ./gradlew
38+
- name: Build
39+
run: ./gradlew build --no-daemon
40+
env:
41+
JAVA_VERSION: ${{ matrix.java }} # override default toolchain version
42+
- name: Capture Build Artifacts
43+
if: ${{ runner.os == 'Linux' && matrix.java == '21' }}
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: Artifacts
47+
path: build/libs/

.github/workflows/prerelease.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: prerelease
2+
3+
env:
4+
PROJECT_NAME: GraphLib
5+
JAVADOC_DIR: com/kneelawk/graphlib/graphlib-javadoc-xplat
6+
MAVEN_IDENTIFIER: 'com.kneelawk.graphlib:graphlib-core-xplat-intermediary'
7+
ROLE_ID: '1239437674058879047'
8+
9+
on:
10+
push:
11+
tags:
12+
# matches things like v0.1.2-alpha.1+1.18.2
13+
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+\+[0-9]+.[0-9]+.[0-9]+'
14+
# matches things like v0.1.2-beta.1+1.18.2
15+
- 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+\+[0-9]+.[0-9]+.[0-9]+'
16+
# matches things like v0.1.2-pre.1+1.18.2
17+
- 'v[0-9]+.[0-9]+.[0-9]+-pre.[0-9]+\+[0-9]+.[0-9]+.[0-9]+'
18+
# matches things like v0.3.0-alpha.1+1.19
19+
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+\+[0-9]+.[0-9]+'
20+
# matches things like v0.3.0-beta.1+1.19
21+
- 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+\+[0-9]+.[0-9]+'
22+
# matches things like v0.3.0-pre.1+1.19
23+
- 'v[0-9]+.[0-9]+.[0-9]+-pre.[0-9]+\+[0-9]+.[0-9]+'
24+
25+
jobs:
26+
prerelease:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
- name: Setup JDK 21
32+
uses: actions/setup-java@v4
33+
with:
34+
distribution: 'temurin'
35+
java-version: 21
36+
- name: Make Gradle Wrapper Executable
37+
run: chmod +x ./gradlew
38+
- name: Build
39+
run: ./gradlew build
40+
env:
41+
RELEASE_TAG: ${{ github.ref_name }}
42+
- name: Github Release
43+
uses: softprops/action-gh-release@v2
44+
with:
45+
files: build/libs/*
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
48+
- name: Maven Release
49+
run: ./gradlew publish -PkneelawkUsername=${{ secrets.MAVEN_USERNAME }} -PkneelawkPassword=${{ secrets.MAVEN_PASSWORD }}
50+
env:
51+
RELEASE_TAG: ${{ github.ref_name }}
52+
# This is the mess that publishes discord notifications
53+
- name: Process for Announcement
54+
uses: actions/github-script@v7
55+
id: announcement_text
56+
env:
57+
TAG_VERSION: ${{ github.ref_name }}
58+
with:
59+
script: |
60+
let fullVersion = process.env.TAG_VERSION;
61+
let versions = fullVersion.split('+');
62+
let mavenVersion = fullVersion.substring(1);
63+
let lines = [];
64+
lines.push(`# ${process.env.PROJECT_NAME} Prerelease`);
65+
lines.push(`**<@&${process.env.ROLE_ID}> ${process.env.PROJECT_NAME} prerelease ${versions[0]} has been published for Minecraft ${versions[1]}!**`);
66+
lines.push("Available on Kneelawk's maven: https://maven.kneelawk.com/releases/", `With the identifier: \`${process.env.MAVEN_IDENTIFIER}:${mavenVersion}\``);
67+
lines.push(`Javadoc available at: https://maven.kneelawk.com/javadoc/releases/${process.env.JAVADOC_DIR}/${mavenVersion}`);
68+
return lines.join('\n');
69+
result-encoding: string
70+
- name: Make Release Announcement
71+
uses: Ilshidur/action-discord@0.3.2
72+
env:
73+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
74+
with:
75+
args: ${{ steps.announcement_text.outputs.result }}

.github/workflows/release.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Performs all releases using a multipart approach
2+
name: release
3+
4+
env:
5+
PROJECT_NAME: GraphLib
6+
JAVADOC_DIR: com/kneelawk/graphlib/graphlib-javadoc-xplat
7+
MAVEN_IDENTIFIER: 'com.kneelawk.graphlib:graphlib-core-xplat-intermediary'
8+
ROLE_ID: '1239437674058879047'
9+
10+
# Variant: github, maven+javadoc, discord
11+
12+
# Changes:
13+
# 2023-04-22 - Kneelawk: Added changes & variant comments. Fixed Grab CF File ID task name. Renamed build job to
14+
# build-release. Reformatted.
15+
# 2023-04-22 - Kneelawk: Fix references to build job to point to build-release job.
16+
# 2023-04-22 - Kneelawk: Copy gradle caches to prevent re-building in publishing jobs.
17+
# 2023-05-02 - Kneelawk: Added javadoc publishing. Added maven job step for getting proper tag version by removing 'v'.
18+
# 2023-05-08 - Kneelawk: Combined maven and javadoc steps.
19+
# 2023-05-10 - Kneelawk: Copy all javadoc directories in the docs directory.
20+
# 2023-05-10 - Kneelawk: Use regular publish gradle task.
21+
# 2023-12-12 - Kneelawk: Switch back to single-job system to avoid uploading massive artifacts.
22+
23+
on:
24+
push:
25+
tags:
26+
# matches things like v0.3.3+1.18.2
27+
- 'v[0-9]+.[0-9]+.[0-9]+\+[0-9]+.[0-9]+.[0-9]+'
28+
# matches things like v0.4.0+1.19
29+
- 'v[0-9]+.[0-9]+.[0-9]+\+[0-9]+.[0-9]+'
30+
31+
jobs:
32+
release:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
- name: Validate Gradle Wrapper
38+
uses: gradle/wrapper-validation-action@v1
39+
- name: Setup JDK 21
40+
uses: actions/setup-java@v4
41+
with:
42+
distribution: 'temurin'
43+
java-version: 21
44+
- name: Make Gradle Wrapper Executable
45+
run: chmod +x ./gradlew
46+
- name: Build
47+
run: ./gradlew build
48+
env:
49+
RELEASE_TAG: ${{ github.ref_name }}
50+
- name: Capture Build Directory
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: build-dir
54+
path: build/
55+
- name: Github Release
56+
uses: softprops/action-gh-release@v2
57+
with:
58+
body_path: changelogs/changelog-${{ github.ref_name }}.md
59+
files: build/libs/*
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
62+
- name: Maven Release
63+
run: ./gradlew publish -PkneelawkUsername=${{ secrets.MAVEN_USERNAME }} -PkneelawkPassword=${{ secrets.MAVEN_PASSWORD }}
64+
env:
65+
RELEASE_TAG: ${{ github.ref_name }}
66+
# This is the mess that publishes discord notifications
67+
- name: Read Changelog File
68+
uses: juliangruber/read-file-action@v1
69+
id: changelog
70+
with:
71+
path: changelogs/changelog-${{ github.ref_name }}.md
72+
- name: Process Changelog for Announcement
73+
uses: actions/github-script@v7
74+
id: announcement_text
75+
env:
76+
CHANGELOG: ${{ steps.changelog.outputs.content }}
77+
TAG_VERSION: ${{ github.ref_name }}
78+
with:
79+
script: |
80+
let fullVersion = process.env.TAG_VERSION;
81+
let versions = fullVersion.split('+');
82+
let mavenVersion = fullVersion.substring(1);
83+
let lines = process.env.CHANGELOG.split('\n');
84+
let changesStart = lines.findIndex(line => line.startsWith('*'));
85+
lines.splice(0, changesStart);
86+
lines.unshift(`# ${process.env.PROJECT_NAME} Release`, `**<@&${process.env.ROLE_ID}> ${process.env.PROJECT_NAME} ${versions[0]} has been released for Minecraft ${versions[1]}!**`, '', '__Changes:__');
87+
lines.push("Available on Kneelawk's maven: https://maven.kneelawk.com/releases/", `With the identifier: \`${process.env.MAVEN_IDENTIFIER}:${mavenVersion}\``);
88+
lines.push(`Javadoc available at: https://maven.kneelawk.com/javadoc/releases/${process.env.JAVADOC_DIR}/${mavenVersion}`);
89+
return lines.join('\n');
90+
result-encoding: string
91+
- name: Make Release Announcement
92+
uses: Ilshidur/action-discord@0.3.2
93+
env:
94+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
95+
with:
96+
args: ${{ steps.announcement_text.outputs.result }}

0 commit comments

Comments
 (0)