mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-08 19:04:46 +00:00
update workflow to work with 1.12.2
This commit is contained in:
3 files changed
+125
-59
No files matched your search
@@ -4,16 +4,21 @@ set -euo pipefail
|
||||
|
||||
artifact_dir="${1:-output}"
|
||||
artifact_prefix="${2:-}"
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
minecraft_version="$(sed -n 's/^minecraft_version=//p' "$repo_root/gradle.properties" | tr -d '\r' | tail -n 1)"
|
||||
mod_version="$(sed -n 's/^mod_version=//p' "$repo_root/gradle.properties" | tr -d '\r' | tail -n 1)"
|
||||
|
||||
if [[ ! -d "$artifact_dir" ]]; then
|
||||
echo "Artifact directory does not exist: $artifact_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$minecraft_version" || -z "$mod_version" ]]; then
|
||||
echo "Could not determine artifact versions from gradle.properties." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$artifact_prefix" ]]; then
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
minecraft_version="$(sed -n 's/^minecraft_version=//p' "$repo_root/gradle.properties" | tr -d '\r' | tail -n 1)"
|
||||
mod_version="$(sed -n 's/^mod_version=//p' "$repo_root/gradle.properties" | tr -d '\r' | tail -n 1)"
|
||||
artifact_prefix="Mekanism-Community-Edition-${minecraft_version}-${mod_version}"
|
||||
|
||||
if [[ -n "${BUILD_VER:-}" ]]; then
|
||||
@@ -21,17 +26,18 @@ if [[ -z "$artifact_prefix" ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
declare -a expected=(
|
||||
"ALL:jar"
|
||||
"API:jar"
|
||||
"Core:jar"
|
||||
"DEV:jar"
|
||||
"DefenseTech:jar"
|
||||
"Generators:jar"
|
||||
"MDK:zip"
|
||||
"Tools:jar"
|
||||
"Ultimate:jar"
|
||||
)
|
||||
case "$minecraft_version" in
|
||||
1.7.10)
|
||||
expected=(ALL:jar API:jar Core:jar DEV:jar DefenseTech:jar Generators:jar MDK:zip Tools:jar Ultimate:jar)
|
||||
;;
|
||||
1.12.2)
|
||||
expected=(ALL:jar API:jar Core:jar Generators:jar Tools:jar Ultimate:jar)
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported Minecraft version: $minecraft_version" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
listing="$(mktemp)"
|
||||
trap 'rm -f -- "$listing"' EXIT
|
||||
@@ -55,6 +61,16 @@ require_matching_entry() {
|
||||
fi
|
||||
}
|
||||
|
||||
reject_matching_entry() {
|
||||
local pattern="$1"
|
||||
local description="$2"
|
||||
local artifact="$3"
|
||||
if grep -Eq "$pattern" "$listing"; then
|
||||
echo "Unexpected $description was packaged in $artifact" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
for spec in "${expected[@]}"; do
|
||||
classifier="${spec%%:*}"
|
||||
extension="${spec##*:}"
|
||||
@@ -79,14 +95,28 @@ for spec in "${expected[@]}"; do
|
||||
case "$classifier" in
|
||||
Core)
|
||||
require_exact_entry 'mekanism/common/Mekanism.class' "$artifact"
|
||||
reject_matching_entry '^(mekanism/(generators|tools|ultimate)/|defense/)' 'module class' "$artifact"
|
||||
|
||||
if [[ "$minecraft_version" == '1.12.2' ]]; then
|
||||
reject_matching_entry '^assets/mekanism(generators|tools|ultimate)/' 'module asset' "$artifact"
|
||||
fi
|
||||
;;
|
||||
ALL)
|
||||
require_exact_entry 'mekanism/common/Mekanism.class' "$artifact"
|
||||
require_exact_entry 'defense/common/DefenseTech.class' "$artifact"
|
||||
require_exact_entry 'mekanism/generators/common/MekanismGenerators.class' "$artifact"
|
||||
require_exact_entry 'mekanism/tools/common/MekanismTools.class' "$artifact"
|
||||
require_exact_entry 'mekanism/ultimate/common/MekanismUltimate.class' "$artifact"
|
||||
|
||||
if [[ "$minecraft_version" == '1.7.10' ]]; then
|
||||
require_exact_entry 'defense/common/DefenseTech.class' "$artifact"
|
||||
fi
|
||||
;;
|
||||
API)
|
||||
require_matching_entry '^mekanism/api/.*\.class$' 'compiled Mekanism API class' "$artifact"
|
||||
|
||||
if [[ "$minecraft_version" == '1.12.2' ]]; then
|
||||
require_matching_entry '^mekanism/api/.*\.java$' 'Mekanism API source' "$artifact"
|
||||
fi
|
||||
;;
|
||||
DEV)
|
||||
require_exact_entry 'mekanism/common/Mekanism.class' "$artifact"
|
||||
@@ -96,18 +126,19 @@ for spec in "${expected[@]}"; do
|
||||
require_exact_entry 'defense/common/DefenseTech.class' "$artifact"
|
||||
;;
|
||||
Generators)
|
||||
require_exact_entry 'mcmod.info' "$artifact"
|
||||
require_exact_entry 'mekanism/generators/common/MekanismGenerators.class' "$artifact"
|
||||
;;
|
||||
MDK)
|
||||
require_matching_entry '^mekanism/api/.*\.java$' 'Mekanism API source' "$artifact"
|
||||
;;
|
||||
Tools)
|
||||
require_exact_entry 'mcmod.info' "$artifact"
|
||||
require_exact_entry 'mekanism/tools/common/MekanismTools.class' "$artifact"
|
||||
;;
|
||||
Ultimate)
|
||||
require_exact_entry 'mcmod.info' "$artifact"
|
||||
require_exact_entry 'mekanism/ultimate/common/MekanismUltimate.class' "$artifact"
|
||||
require_exact_entry 'mekanism/ultimate/common/tile/TileEntityUltimateFactory.class' "$artifact"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
@@ -93,12 +93,29 @@ jobs:
|
||||
;;
|
||||
esac
|
||||
|
||||
artifact_prefix="Mekanism-Community-Edition-${minecraft_version}-${mod_version}"
|
||||
if [[ -n "$build_suffix" ]]; then
|
||||
artifact_prefix="${artifact_prefix}-${build_suffix}"
|
||||
fi
|
||||
artifact_prefix="Mekanism-Community-Edition-${minecraft_version}-${mod_version}-${build_suffix}"
|
||||
|
||||
case "$minecraft_version" in
|
||||
1.7.10)
|
||||
artifact_specs=(ALL.jar API.jar Core.jar DEV.jar DefenseTech.jar Generators.jar MDK.zip Tools.jar Ultimate.jar)
|
||||
;;
|
||||
1.12.2)
|
||||
artifact_specs=(ALL.jar API.jar Core.jar Generators.jar Tools.jar Ultimate.jar)
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported Minecraft version: $minecraft_version" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "prefix=$artifact_prefix" >> "$GITHUB_OUTPUT"
|
||||
{
|
||||
echo 'artifact_files<<ARTIFACT_FILES'
|
||||
for spec in "${artifact_specs[@]}"; do
|
||||
echo "output/${artifact_prefix}-${spec}"
|
||||
done
|
||||
echo 'ARTIFACT_FILES'
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Empty output directory
|
||||
shell: bash
|
||||
@@ -153,16 +170,7 @@ jobs:
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: mekanism-ce-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
path: |
|
||||
output/${{ steps.artifacts.outputs.prefix }}-ALL.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-API.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Core.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-DEV.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-DefenseTech.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Generators.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-MDK.zip
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Tools.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Ultimate.jar
|
||||
path: ${{ steps.artifacts.outputs.artifact_files }}
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
compression-level: 0
|
||||
+56
-29
@@ -1,5 +1,8 @@
|
||||
name: Publish release
|
||||
|
||||
# GitHub resolves release-event workflows from the repository's default branch.
|
||||
# Keep this workflow branch-aware so both 1.7.10 and 1.12.2 tags publish correctly.
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
@@ -19,6 +22,9 @@ jobs:
|
||||
environment: release
|
||||
outputs:
|
||||
artifact_prefix: ${{ steps.artifacts.outputs.prefix }}
|
||||
minecraft_version: ${{ steps.artifacts.outputs.minecraft_version }}
|
||||
release_files: ${{ steps.artifacts.outputs.release_files }}
|
||||
main_files: ${{ steps.artifacts.outputs.main_files }}
|
||||
|
||||
steps:
|
||||
- name: Check out release tag
|
||||
@@ -54,7 +60,37 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "prefix=Mekanism-Community-Edition-${minecraft_version}-${mod_version}" >> "$GITHUB_OUTPUT"
|
||||
artifact_prefix="Mekanism-Community-Edition-${minecraft_version}-${mod_version}"
|
||||
|
||||
case "$minecraft_version" in
|
||||
1.7.10)
|
||||
release_specs=(ALL.jar API.jar Core.jar DEV.jar DefenseTech.jar Generators.jar MDK.zip Tools.jar Ultimate.jar)
|
||||
main_specs=(Core.jar API.jar DEV.jar MDK.zip)
|
||||
;;
|
||||
1.12.2)
|
||||
release_specs=(ALL.jar API.jar Core.jar Generators.jar Tools.jar Ultimate.jar)
|
||||
main_specs=(Core.jar API.jar)
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported Minecraft version: $minecraft_version" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "prefix=$artifact_prefix" >> "$GITHUB_OUTPUT"
|
||||
echo "minecraft_version=$minecraft_version" >> "$GITHUB_OUTPUT"
|
||||
{
|
||||
echo 'release_files<<RELEASE_FILES'
|
||||
for spec in "${release_specs[@]}"; do
|
||||
echo "output/${artifact_prefix}-${spec}"
|
||||
done
|
||||
echo 'RELEASE_FILES'
|
||||
echo 'main_files<<MAIN_FILES'
|
||||
for spec in "${main_specs[@]}"; do
|
||||
echo "output/${artifact_prefix}-${spec}"
|
||||
done
|
||||
echo 'MAIN_FILES'
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Verify tag matches the project version
|
||||
shell: bash
|
||||
@@ -96,32 +132,14 @@ jobs:
|
||||
github-token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
|
||||
github-tag: ${{ github.event.release.tag_name }}
|
||||
github-generate-changelog: false
|
||||
files: |
|
||||
output/${{ steps.artifacts.outputs.prefix }}-ALL.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-API.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Core.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-DEV.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-DefenseTech.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Generators.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-MDK.zip
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Tools.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Ultimate.jar
|
||||
files: ${{ steps.artifacts.outputs.release_files }}
|
||||
version: ${{ github.event.release.tag_name }}
|
||||
|
||||
- name: Save release artifacts for publishing jobs
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: release-${{ github.event.release.tag_name }}
|
||||
path: |
|
||||
output/${{ steps.artifacts.outputs.prefix }}-ALL.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-API.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Core.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-DEV.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-DefenseTech.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Generators.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-MDK.zip
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Tools.jar
|
||||
output/${{ steps.artifacts.outputs.prefix }}-Ultimate.jar
|
||||
path: ${{ steps.artifacts.outputs.release_files }}
|
||||
if-no-files-found: error
|
||||
# This artifact only passes the verified files to the parallel
|
||||
# publishing jobs; GitHub Releases and Maven are the durable stores.
|
||||
@@ -149,17 +167,13 @@ jobs:
|
||||
with:
|
||||
modrinth-id: toGHjw6t
|
||||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
|
||||
files: |
|
||||
output/${{ needs.build.outputs.artifact_prefix }}-Core.jar
|
||||
output/${{ needs.build.outputs.artifact_prefix }}-API.jar
|
||||
output/${{ needs.build.outputs.artifact_prefix }}-DEV.jar
|
||||
output/${{ needs.build.outputs.artifact_prefix }}-MDK.zip
|
||||
files: ${{ needs.build.outputs.main_files }}
|
||||
name: Mekanism CE - CORE ${{ github.event.release.tag_name }}
|
||||
version: ${{ github.event.release.tag_name }}
|
||||
version-type: ${{ github.event.release.prerelease && 'beta' || 'release' }}
|
||||
changelog: ${{ github.event.release.body }}
|
||||
loaders: forge
|
||||
game-versions: '1.7.10'
|
||||
game-versions: ${{ needs.build.outputs.minecraft_version }}
|
||||
game-version-filter: none
|
||||
java: '8'
|
||||
environment: client | server
|
||||
@@ -179,27 +193,33 @@ jobs:
|
||||
project-id: qBExn86I
|
||||
classifier: DefenseTech
|
||||
beta-only: false
|
||||
only_version: '1.7.10'
|
||||
- name: Generators
|
||||
project-id: ksSEAhTL
|
||||
classifier: Generators
|
||||
beta-only: false
|
||||
only_version: ''
|
||||
- name: Tools
|
||||
project-id: CD05L8Jr
|
||||
classifier: Tools
|
||||
beta-only: false
|
||||
only_version: ''
|
||||
- name: Ultimate
|
||||
project-id: Q6fY4JVC
|
||||
classifier: Ultimate
|
||||
beta-only: true
|
||||
only_version: ''
|
||||
|
||||
steps:
|
||||
- name: Download release artifacts
|
||||
if: matrix.only_version == '' || needs.build.outputs.minecraft_version == matrix.only_version
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: release-${{ github.event.release.tag_name }}
|
||||
path: output
|
||||
|
||||
- name: Publish ${{ matrix.name }} to Modrinth
|
||||
if: matrix.only_version == '' || needs.build.outputs.minecraft_version == matrix.only_version
|
||||
uses: Kira-NT/mc-publish@52307b03863581dec6b652b83e597aec02ebb075 # v3.3.1
|
||||
with:
|
||||
modrinth-id: ${{ matrix.project-id }}
|
||||
@@ -210,7 +230,7 @@ jobs:
|
||||
version-type: ${{ matrix.beta-only && 'beta' || (github.event.release.prerelease && 'beta' || 'release') }}
|
||||
changelog: ${{ github.event.release.body }}
|
||||
loaders: forge
|
||||
game-versions: '1.7.10'
|
||||
game-versions: ${{ needs.build.outputs.minecraft_version }}
|
||||
game-version-filter: none
|
||||
java: '8'
|
||||
environment: client | server
|
||||
@@ -232,35 +252,42 @@ jobs:
|
||||
classifier: Core
|
||||
dependencies: ''
|
||||
beta-only: false
|
||||
only_version: ''
|
||||
- name: DefenseTech
|
||||
project-id: '1488821'
|
||||
classifier: DefenseTech
|
||||
dependencies: mekanism-ce(required)
|
||||
beta-only: false
|
||||
only_version: '1.7.10'
|
||||
- name: Generators
|
||||
project-id: '813408'
|
||||
classifier: Generators
|
||||
dependencies: mekanism-ce(required)
|
||||
beta-only: false
|
||||
only_version: ''
|
||||
- name: Tools
|
||||
project-id: '813407'
|
||||
classifier: Tools
|
||||
dependencies: mekanism-ce(required)
|
||||
beta-only: false
|
||||
only_version: ''
|
||||
- name: Ultimate
|
||||
project-id: '872280'
|
||||
classifier: Ultimate
|
||||
dependencies: mekanism-ce(required)
|
||||
beta-only: true
|
||||
only_version: ''
|
||||
|
||||
steps:
|
||||
- name: Download release artifacts
|
||||
if: matrix.only_version == '' || needs.build.outputs.minecraft_version == matrix.only_version
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: release-${{ github.event.release.tag_name }}
|
||||
path: output
|
||||
|
||||
- name: Publish ${{ matrix.name }} to CurseForge
|
||||
if: matrix.only_version == '' || needs.build.outputs.minecraft_version == matrix.only_version
|
||||
uses: Kira-NT/mc-publish@52307b03863581dec6b652b83e597aec02ebb075 # v3.3.1
|
||||
with:
|
||||
curseforge-id: ${{ matrix.project-id }}
|
||||
@@ -271,7 +298,7 @@ jobs:
|
||||
version-type: ${{ matrix.beta-only && 'beta' || (github.event.release.prerelease && 'beta' || 'release') }}
|
||||
changelog: ${{ github.event.release.body }}
|
||||
loaders: forge
|
||||
game-versions: '1.7.10'
|
||||
game-versions: ${{ needs.build.outputs.minecraft_version }}
|
||||
game-version-filter: none
|
||||
java: '8'
|
||||
environment: client | server
|
||||
|
||||
Reference in new issue
Block a user