Build Controllable #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Controllable | |
on: workflow_dispatch | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: Build | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Validate Gradle Wrapper | |
uses: gradle/wrapper-validation-action@v3.5.0 | |
- name: Read modid from gradle.properties | |
id: mod_id | |
uses: Reedyuk/read-properties@v1.0.4 | |
with: | |
path: './gradle.properties' | |
property: 'mod_id' | |
- name: Read mod version from gradle.properties | |
id: mod_version | |
uses: Reedyuk/read-properties@v1.0.4 | |
with: | |
path: './gradle.properties' | |
property: 'mod_version' | |
- name: Read minecraft version from gradle.properties | |
id: mc_version | |
uses: Reedyuk/read-properties@v1.0.4 | |
with: | |
path: './gradle.properties' | |
property: 'minecraft_version' | |
- name: Cache | |
uses: actions/cache@v4.2.0 | |
with: | |
path: ~/.gradle/caches | |
key: gradle-minecraft-${{ steps.mc_version.outputs.value }} | |
- name: Load Keystore | |
id: load_keystore | |
env: | |
JKS: ${{ secrets.MRCRAYFISH_JKS }} | |
if: ${{ env.JKS != '' }} | |
uses: timheuer/base64-to-file@v1.2 | |
with: | |
fileName: 'keystore.jks' | |
encodedString: ${{ env.JKS }} | |
- name: Set Keystore Variables | |
if: ${{ steps.load_keystore.outputs.filePath != '' }} | |
run: | | |
echo "KEYSTORE=${{ steps.load_keystore.outputs.filePath }}" >> $GITHUB_ENV | |
echo "KEYSTORE_ALIAS=${{ secrets.MRCRAYFISH_JKS_ALIAS }}" >> $GITHUB_ENV | |
echo "KEYSTORE_PASS=${{ secrets.MRCRAYFISH_JKS_PASSPHRASE }}" >> $GITHUB_ENV | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Build (Common) | |
env: | |
GPR_USER: "MrCrayfish" | |
GPR_KEY: ${{ secrets.GPR_TOKEN }} | |
run: ./gradlew :common:build | |
- name: Build (Forge) | |
env: | |
GPR_USER: "MrCrayfish" | |
GPR_KEY: ${{ secrets.GPR_TOKEN }} | |
run: ./gradlew :forge:build | |
- name: Stop Gradle | |
run: ./gradlew --stop | |
- name: Construct artifact files | |
id: artifacts | |
run: | | |
echo "forge=forge/build/libs/${{ steps.mod_id.outputs.value }}-forge-${{ steps.mc_version.outputs.value }}-${{ steps.mod_version.outputs.value }}-release.jar" >> "$GITHUB_OUTPUT" | |
- name: Import GPG | |
env: | |
SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} | |
SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
if: ${{ env.SIGNING_KEY != '' && env.SIGNING_PASSPHRASE != '' }} | |
uses: crazy-max/ghaction-import-gpg@v6.2.0 | |
with: | |
gpg_private_key: ${{ env.SIGNING_KEY }} | |
passphrase: ${{ env.SIGNING_PASSPHRASE }} | |
- name: GPG Sign | |
env: | |
SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
if: ${{ env.SIGNING_PASSPHRASE != '' }} | |
run: | | |
gpg --batch --yes --passphrase "${{ env.SIGNING_PASSPHRASE }}" --armor --detach-sign ${{ steps.artifacts.outputs.forge }} | |
- name: Upload Forge Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: '${{ steps.mod_id.outputs.value }}-forge-${{ steps.mc_version.outputs.value }}-${{ steps.mod_version.outputs.value }}' | |
path: | | |
${{ steps.artifacts.outputs.forge }} | |
${{ steps.artifacts.outputs.forge }}.asc |