almostunified/.github/workflows/release.yml

266 lines
9.2 KiB
YAML
Raw Normal View History

2022-08-21 07:41:39 -04:00
name: Release
on:
workflow_dispatch:
push:
tags:
2023-06-14 06:56:08 -04:00
- 'v1.20.1-*.*.*'
2022-08-21 07:41:39 -04:00
env:
JAVA_DIST: 'zulu'
JAVA_VERSION: 17
MOD_ID: 'almostunified'
MOD_NAME: 'AlmostUnified'
2023-06-14 05:48:49 -04:00
CURSEFORGE_ID: '633823'
MODRINTH_ID: 'sdaSaQEz'
2022-08-21 07:41:39 -04:00
jobs:
2023-06-14 05:48:49 -04:00
build:
name: Build, collect info, parse changelog
2022-08-21 07:41:39 -04:00
runs-on: ubuntu-latest
2023-06-14 05:48:49 -04:00
outputs:
JAR_FILE: ${{ steps.collect_info.outputs.JAR_FILE }}
MINECRAFT_VERSION: ${{ steps.collect_info.outputs.MINECRAFT_VERSION }}
MOD_VERSION: ${{ steps.collect_info.outputs.MOD_VERSION }}
RELEASE_TYPE: ${{ steps.collect_info.outputs.RELEASE_TYPE }}
2022-08-21 07:41:39 -04:00
steps:
- name: Clone Repository
uses: actions/checkout@v3
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DIST }}
cache: gradle
- name: Cleanup Gradle Cache
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
2022-08-21 07:41:39 -04:00
- name: Make Gradle executable
run: chmod +x ./gradlew
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Assemble the JARs
run: ./gradlew assemble
2023-06-14 05:48:49 -04:00
- name: Move JARs to central directory
2022-08-21 07:41:39 -04:00
run: |
2023-06-14 05:48:49 -04:00
mkdir output
mv -f Forge/build/libs/*.jar Fabric/build/libs/*.jar output/
rm -f output/*-dev-shadow.jar output/*-sources.jar
2022-08-21 07:41:39 -04:00
- name: Collect version information
2023-06-14 05:48:49 -04:00
id: collect_info
2022-08-21 07:41:39 -04:00
run: |
shopt -s failglob # print a warning if a glob does not match anything
set_var() {
echo $1="$2"
2023-06-14 05:48:49 -04:00
echo $1="$2" >> $GITHUB_OUTPUT
2022-08-21 07:41:39 -04:00
declare -g $1="$2"
}
2023-06-14 05:48:49 -04:00
set_var JAR_FILE $(eval echo output/${{ env.MOD_ID }}-*-*-*.jar)
2022-08-21 07:41:39 -04:00
set_var MINECRAFT_VERSION $(echo ${JAR_FILE%.*} | cut -d- -f3)
set_var MOD_VERSION $(echo ${JAR_FILE%.*} | cut -d- -f4)
set_var RELEASE_TYPE "$(echo ${GITHUB_REF##*/} | cut -d- -f3)"
2022-08-21 07:41:39 -04:00
set_var RELEASE_TYPE "$([[ -z $RELEASE_TYPE ]] && echo release || echo $RELEASE_TYPE)"
- name: Install changelog parser
uses: taiki-e/install-action@parse-changelog
- name: Parse changelog
2023-06-14 05:48:49 -04:00
run: parse-changelog CHANGELOG.md ${{ steps.collect_info.outputs.MOD_VERSION }} > output/changelog.md
2022-08-21 07:41:39 -04:00
2023-06-14 05:48:49 -04:00
- name: Archive results
run: tar -zcvf build.tar.gz output
- name: Upload results
uses: actions/upload-artifact@v3
2022-08-21 07:41:39 -04:00
with:
2023-06-14 05:48:49 -04:00
name: build-artifacts
path: build.tar.gz
if-no-files-found: error
retention-days: 3
- name: Job Summary
run: |
echo "# Version Information" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- Minecraft Version: ${{ steps.collect_info.outputs.MINECRAFT_VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- Mod Version: ${{ steps.collect_info.outputs.MOD_VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- Release Type: ${{ steps.collect_info.outputs.RELEASE_TYPE }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Build Information" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
2023-07-30 13:43:34 -04:00
echo "- JAR files: $(find output -maxdepth 1 -type f -name '*.jar' | wc -l)" >> $GITHUB_STEP_SUMMARY
2023-06-14 05:48:49 -04:00
echo "- Folder size: $(du -sh output | cut -f1)" >> $GITHUB_STEP_SUMMARY
echo "- Archive size: $(du -sh build.tar.gz | cut -f1)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Changelog" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat output/changelog.md >> $GITHUB_STEP_SUMMARY
mr-fabric-release:
name: Modrinth Fabric Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Extract build artifacts
run: tar -zxvf build.tar.gz
- name: Release Fabric on Modrinth
uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: ${{ env.MODRINTH_ID }}
2022-08-21 07:41:39 -04:00
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
2023-06-14 05:48:49 -04:00
files: output/*fabric*.jar
name: ${{ env.MOD_NAME }}-Fabric-${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version: ${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}+fabric
version-type: ${{ needs.build.outputs.RELEASE_TYPE }}
changelog-file: output/changelog.md
2022-08-21 07:41:39 -04:00
loaders: fabric
2023-06-14 05:48:49 -04:00
game-versions: ${{ needs.build.outputs.MINECRAFT_VERSION }}
2022-08-21 07:41:39 -04:00
java: ${{ env.JAVA_VERSION }}
2023-04-02 04:44:20 -04:00
dependencies: |
2023-06-14 05:48:49 -04:00
jei(optional){curseforge:238222}{modrinth:u6dRKJwZ}
rei(optional){curseforge:310111}{modrinth:nfn13YXA}
cf-fabric-release:
name: CurseForge Fabric Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
2023-06-14 05:48:49 -04:00
- name: Extract build artifacts
run: tar -zxvf build.tar.gz
2022-08-21 07:41:39 -04:00
2023-06-14 05:48:49 -04:00
- name: Release Fabric on CurseForge
uses: Kir-Antipov/mc-publish@v3.3
2022-08-21 07:41:39 -04:00
with:
2023-06-14 05:48:49 -04:00
curseforge-id: ${{ env.CURSEFORGE_ID }}
2022-08-21 07:41:39 -04:00
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
2023-06-14 05:48:49 -04:00
files: output/*fabric*.jar
name: ${{ env.MOD_NAME }}-Fabric-${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version: ${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}+fabric
version-type: ${{ needs.build.outputs.RELEASE_TYPE }}
changelog-file: output/changelog.md
loaders: fabric
game-versions: ${{ needs.build.outputs.MINECRAFT_VERSION }}
java: ${{ env.JAVA_VERSION }}
dependencies: |
jei(optional){curseforge:238222}{modrinth:u6dRKJwZ}
rei(optional){curseforge:310111}{modrinth:nfn13YXA}
mr-forge-release:
name: Modrinth Forge Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Extract build artifacts
run: tar -zxvf build.tar.gz
- name: Release Forge on Modrinth
uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: ${{ env.MODRINTH_ID }}
2022-08-21 07:41:39 -04:00
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
2023-06-14 05:48:49 -04:00
files: output/*forge*.jar
name: ${{ env.MOD_NAME }}-Forge-${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version: ${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}+forge
version-type: ${{ needs.build.outputs.RELEASE_TYPE }}
changelog-file: output/changelog.md
2022-08-21 07:41:39 -04:00
2023-07-29 14:52:29 -04:00
loaders: |
forge
neoforge
2023-06-14 05:48:49 -04:00
game-versions: ${{ needs.build.outputs.MINECRAFT_VERSION }}
2022-08-21 07:41:39 -04:00
java: ${{ env.JAVA_VERSION }}
2023-04-02 04:44:20 -04:00
dependencies: |
2023-06-14 05:48:49 -04:00
jei(optional){curseforge:238222}{modrinth:u6dRKJwZ}
rei(optional){curseforge:310111}{modrinth:nfn13YXA}
cf-forge-release:
name: CurseForge Forge Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
- name: Extract build artifacts
run: tar -zxvf build.tar.gz
- name: Release Forge on CurseForge
uses: Kir-Antipov/mc-publish@v3.3
with:
curseforge-id: ${{ env.CURSEFORGE_ID }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
files: output/*forge*.jar
name: ${{ env.MOD_NAME }}-Forge-${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version: ${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}+forge
version-type: ${{ needs.build.outputs.RELEASE_TYPE }}
changelog-file: output/changelog.md
2023-07-29 14:52:29 -04:00
loaders: |
forge
neoforge
2023-06-14 05:48:49 -04:00
game-versions: ${{ needs.build.outputs.MINECRAFT_VERSION }}
java: ${{ env.JAVA_VERSION }}
dependencies: |
jei(optional){curseforge:238222}{modrinth:u6dRKJwZ}
rei(optional){curseforge:310111}{modrinth:nfn13YXA}
github-release:
name: GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
2023-06-14 05:48:49 -04:00
- name: Extract build artifacts
run: tar -zxvf build.tar.gz
2022-08-21 07:41:39 -04:00
2023-06-14 05:48:49 -04:00
- name: Release on GitHub
uses: Kir-Antipov/mc-publish@v3.3
2022-08-21 07:41:39 -04:00
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
2023-06-14 05:48:49 -04:00
files: output/*.jar
name: v${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version: ${{ needs.build.outputs.MINECRAFT_VERSION }}-${{ needs.build.outputs.MOD_VERSION }}
version-type: ${{ needs.build.outputs.RELEASE_TYPE }}
changelog-file: output/changelog.md