Skip to content

Commit c130ba4

Browse files
committed
🚧 Modernise build workflow
1 parent f5f808c commit c130ba4

File tree

10 files changed

+157
-314
lines changed

10 files changed

+157
-314
lines changed

.github/workflows/build.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Build Backpacked
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
environment: Build
10+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
fetch-tags: true
17+
- name: Set up JDK 21
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '21'
21+
distribution: 'temurin'
22+
- name: Validate Gradle Wrapper
23+
uses: gradle/actions/wrapper-validation@v4
24+
- name: Read mod data from gradle.properties
25+
id: mod_data
26+
uses: christian-draeger/read-properties@1.1.1
27+
with:
28+
path: './gradle.properties'
29+
properties: 'mod_id mod_version minecraft_version'
30+
- name: Cache
31+
uses: actions/cache@v4.2.0
32+
with:
33+
path: ~/.gradle/caches
34+
key: gradle-minecraft-${{ steps.mod_data.outputs.minecraft_version }}
35+
restore-keys: |
36+
gradle-minecraft-${{ steps.mod_data.outputs.minecraft_version }}
37+
- name: Load Keystore
38+
id: load_keystore
39+
env:
40+
JKS: ${{ secrets.MRCRAYFISH_JKS }}
41+
if: ${{ env.JKS != '' }}
42+
uses: timheuer/base64-to-file@v1.2
43+
with:
44+
fileName: 'keystore.jks'
45+
encodedString: ${{ env.JKS }}
46+
- name: Set Keystore Variables
47+
if: ${{ steps.load_keystore.outputs.filePath != '' }}
48+
run: |
49+
echo "KEYSTORE=${{ steps.load_keystore.outputs.filePath }}" >> $GITHUB_ENV
50+
echo "KEYSTORE_ALIAS=${{ secrets.MRCRAYFISH_JKS_ALIAS }}" >> $GITHUB_ENV
51+
echo "KEYSTORE_PASS=${{ secrets.MRCRAYFISH_JKS_PASSPHRASE }}" >> $GITHUB_ENV
52+
- name: Make gradlew executable
53+
run: chmod +x ./gradlew
54+
- name: Build (Common)
55+
env:
56+
GPR_USER: "MrCrayfish"
57+
GPR_KEY: ${{ secrets.GPR_TOKEN }}
58+
PACKAGES_REPO: ${{ vars.PACKAGES_REPOSITORY }}
59+
run: ./gradlew :common:build
60+
- name: Build (Fabric)
61+
env:
62+
GPR_USER: "MrCrayfish"
63+
GPR_KEY: ${{ secrets.GPR_TOKEN }}
64+
PACKAGES_REPO: ${{ vars.PACKAGES_REPOSITORY }}
65+
run: ./gradlew :fabric:build
66+
- name: Build (NeoForge)
67+
env:
68+
GPR_USER: "MrCrayfish"
69+
GPR_KEY: ${{ secrets.GPR_TOKEN }}
70+
PACKAGES_REPO: ${{ vars.PACKAGES_REPOSITORY }}
71+
run: ./gradlew :neoforge:build
72+
- name: Construct artifact files
73+
id: artifacts
74+
run: |
75+
echo "fabric=fabric/build/libs/${{ steps.mod_data.outputs.mod_id }}-fabric-${{ steps.mod_data.outputs.minecraft_version }}-${{ steps.mod_data.outputs.mod_version }}-signed.jar" >> "$GITHUB_OUTPUT"
76+
echo "neoforge=neoforge/build/libs/${{ steps.mod_data.outputs.mod_id }}-neoforge-${{ steps.mod_data.outputs.minecraft_version }}-${{ steps.mod_data.outputs.mod_version }}-signed.jar" >> "$GITHUB_OUTPUT"
77+
- name: Create Changelog Files
78+
run: |
79+
echo "" > CHANGELOG.txt
80+
echo "### Technical Changelog:" >> RELEASE_BODY.md
81+
tag_count=$(git tag --merged | wc -l)
82+
if [ "$tag_count" -ge 2 ]; then
83+
latest_tag=$(git describe --tags --abbrev=0)
84+
previous_tag=$(git describe --tags --abbrev=0 --exclude=$latest_tag)
85+
git log "$previous_tag..$latest_tag^" --oneline --pretty="- %s (%H)" >> RELEASE_BODY.md
86+
git log "$previous_tag..$latest_tag^" --oneline --pretty="%s" >> CHANGELOG.txt
87+
else
88+
echo "No changes"
89+
fi
90+
echo "### Download:" >> RELEASE_BODY.md
91+
echo "- Official Website: https://mrcrayfish.com/mods/${{ steps.mod_data.outputs.mod_id }}" >> RELEASE_BODY.md
92+
echo "- CurseForge: https://curseforge.com/minecraft/mc-mods/backpacked" >> RELEASE_BODY.md
93+
- name: Import GPG
94+
env:
95+
SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
96+
SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
97+
if: ${{ env.SIGNING_KEY != '' && env.SIGNING_PASSPHRASE != '' }}
98+
uses: crazy-max/ghaction-import-gpg@v6.2.0
99+
with:
100+
gpg_private_key: ${{ env.SIGNING_KEY }}
101+
passphrase: ${{ env.SIGNING_PASSPHRASE }}
102+
- name: GPG Sign
103+
env:
104+
SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
105+
if: ${{ env.SIGNING_PASSPHRASE != '' }}
106+
run: |
107+
gpg --batch --yes --passphrase "${{ env.SIGNING_PASSPHRASE }}" --armor --detach-sign ${{ steps.artifacts.outputs.fabric }}
108+
gpg --batch --yes --passphrase "${{ env.SIGNING_PASSPHRASE }}" --armor --detach-sign ${{ steps.artifacts.outputs.neoforge }}
109+
- name: Publish to GitHub Packages
110+
env:
111+
GPR_USER: "MrCrayfish"
112+
GPR_KEY: ${{ secrets.GPR_TOKEN }}
113+
PACKAGES_REPO: ${{ vars.PACKAGES_REPOSITORY }}
114+
SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
115+
SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
116+
run: ./gradlew publish
117+
- name: Stop Gradle
118+
run: ./gradlew --stop
119+
- name: Create Release
120+
uses: ncipollo/release-action@v1
121+
with:
122+
name: '${{ steps.mod_data.outputs.minecraft_version }}-${{ steps.mod_data.outputs.mod_version }}'
123+
artifacts: "${{ steps.artifacts.outputs.fabric }},${{ steps.artifacts.outputs.fabric }}.asc,${{ steps.artifacts.outputs.neoforge }},${{ steps.artifacts.outputs.neoforge }}.asc,CHANGELOG.txt"
124+
bodyFile: "RELEASE_BODY.md"
125+
- name: Upload Artifacts
126+
uses: actions/upload-artifact@v4
127+
with:
128+
name: '${{ steps.mod_data.outputs.mod_id }}-${{ steps.mod_data.outputs.minecraft_version }}-${{ steps.mod_data.outputs.mod_version }}'
129+
path: |
130+
${{ steps.artifacts.outputs.fabric }}
131+
${{ steps.artifacts.outputs.fabric }}.asc
132+
${{ steps.artifacts.outputs.neoforge }}
133+
${{ steps.artifacts.outputs.neoforge }}.asc

.github/workflows/common.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

.github/workflows/fabric.yml

Lines changed: 0 additions & 73 deletions
This file was deleted.

.github/workflows/forge.yml

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)