fix mixing upload jars

This commit is contained in:
maggi373 committed 2026-09-19 13:27:18 +02:00
1 parent 1211b57356
commit 600bb02226
3 files changed
+115 -40

No files matched your search

+15 -6
View File
@@ -1,15 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail
shopt -s nullglob
artifact_dir="${1:-output}"
artifact_prefix="${2:-}"
if [[ ! -d "$artifact_dir" ]]; then
echo "Artifact directory does not exist: $artifact_dir" >&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
artifact_prefix="${artifact_prefix}-${BUILD_VER}"
fi
fi
declare -a expected=(
"ALL:jar"
"API:jar"
@@ -47,15 +58,13 @@ require_matching_entry() {
for spec in "${expected[@]}"; do
classifier="${spec%%:*}"
extension="${spec##*:}"
matches=("$artifact_dir"/Mekanism-Community-Edition-*-"$classifier"."$extension")
artifact="$artifact_dir/$artifact_prefix-$classifier.$extension"
if (( ${#matches[@]} != 1 )); then
echo "Expected exactly one $classifier artifact, found ${#matches[@]}." >&2
printf ' %s\n' "${matches[@]:-<none>}" >&2
if [[ ! -f "$artifact" ]]; then
echo "Expected artifact is missing: $artifact" >&2
exit 1
fi
artifact="${matches[0]}"
if (( $(wc -c < "$artifact") < 512 )); then
echo "Artifact is unexpectedly small: $artifact" >&2
exit 1
+46 -5
View File
@@ -70,15 +70,47 @@ jobs:
- name: Grant execute permission for Gradle
run: chmod +x gradlew
- name: Remove stale packaged artifacts
- name: Determine exact artifact names
id: artifacts
shell: bash
env:
PR_NUMBER: ${{ github.event.pull_request.number || '' }}
run: |
minecraft_version="$(sed -n 's/^minecraft_version=//p' gradle.properties | tr -d '\r' | tail -n 1)"
mod_version="$(sed -n 's/^mod_version=//p' gradle.properties | tr -d '\r' | tail -n 1)"
if [[ -z "$minecraft_version" || -z "$mod_version" ]]; then
echo "Could not determine artifact versions from gradle.properties." >&2
exit 1
fi
case "$GITHUB_EVENT_NAME" in
pull_request|pull_request_target)
build_suffix="pr-${PR_NUMBER}-${GITHUB_RUN_NUMBER}"
;;
*)
build_suffix="$GITHUB_RUN_NUMBER"
;;
esac
artifact_prefix="Mekanism-Community-Edition-${minecraft_version}-${mod_version}"
if [[ -n "$build_suffix" ]]; then
artifact_prefix="${artifact_prefix}-${build_suffix}"
fi
echo "prefix=$artifact_prefix" >> "$GITHUB_OUTPUT"
- name: Empty output directory
shell: bash
run: |
mkdir -p output
find output -maxdepth 1 -type f \( -name '*.jar' -o -name '*.zip' \) -delete
find output -mindepth 1 -delete
- name: Build external pull request
if: github.event_name == 'pull_request'
run: ./gradlew --no-daemon --stacktrace clean fullBuild
env:
BUILD_VER: ${{ format('pr-{0}-{1}', github.event.pull_request.number, github.run_number) }}
- name: Build trusted team pull request
if: github.event_name == 'pull_request_target'
@@ -95,7 +127,9 @@ jobs:
- name: Validate packaged artifacts
shell: bash
run: bash .github/scripts/validate-release-artifacts.sh
run: >-
bash .github/scripts/validate-release-artifacts.sh
output '${{ steps.artifacts.outputs.prefix }}'
# Preserve the development Maven publication used by the external test
# servers. Trusted team PRs publish a unique pr-N-RUN version. Unknown PRs
@@ -120,8 +154,15 @@ jobs:
with:
name: mekanism-ce-${{ github.run_id }}-${{ github.run_attempt }}
path: |
output/*.jar
output/*.zip
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
if-no-files-found: error
retention-days: 14
compression-level: 0
+54 -29
View File
@@ -17,6 +17,8 @@ jobs:
runs-on: self-hosted
timeout-minutes: 90
environment: release
outputs:
artifact_prefix: ${{ steps.artifacts.outputs.prefix }}
steps:
- name: Check out release tag
@@ -40,6 +42,20 @@ jobs:
- name: Grant execute permission for Gradle
run: chmod +x gradlew
- name: Determine exact artifact names
id: artifacts
shell: bash
run: |
minecraft_version="$(sed -n 's/^minecraft_version=//p' gradle.properties | tr -d '\r' | tail -n 1)"
mod_version="$(sed -n 's/^mod_version=//p' gradle.properties | tr -d '\r' | tail -n 1)"
if [[ -z "$minecraft_version" || -z "$mod_version" ]]; then
echo "Could not determine artifact versions from gradle.properties." >&2
exit 1
fi
echo "prefix=Mekanism-Community-Edition-${minecraft_version}-${mod_version}" >> "$GITHUB_OUTPUT"
- name: Verify tag matches the project version
shell: bash
env:
@@ -51,18 +67,20 @@ jobs:
exit 1
fi
- name: Remove stale packaged artifacts
- name: Empty output directory
shell: bash
run: |
mkdir -p output
find output -maxdepth 1 -type f \( -name '*.jar' -o -name '*.zip' \) -delete
find output -mindepth 1 -delete
- name: Build release artifacts
run: ./gradlew --no-daemon --stacktrace clean fullBuild
- name: Validate packaged artifacts
shell: bash
run: bash .github/scripts/validate-release-artifacts.sh
run: >-
bash .github/scripts/validate-release-artifacts.sh
output '${{ steps.artifacts.outputs.prefix }}'
- name: Publish release to Maven
run: ./gradlew --no-daemon --stacktrace artifactoryPublish
@@ -79,15 +97,15 @@ jobs:
github-tag: ${{ github.event.release.tag_name }}
github-generate-changelog: false
files: |
output/*-ALL.jar
output/*-API.jar
output/*-Core.jar
output/*-DEV.jar
output/*-DefenseTech.jar
output/*-Generators.jar
output/*-MDK.zip
output/*-Tools.jar
output/*-Ultimate.jar
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
version: ${{ github.event.release.tag_name }}
- name: Save release artifacts for publishing jobs
@@ -95,8 +113,15 @@ jobs:
with:
name: release-${{ github.event.release.tag_name }}
path: |
output/*.jar
output/*.zip
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
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.
@@ -125,10 +150,10 @@ jobs:
modrinth-id: toGHjw6t
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
files: |
output/*-Core.jar
output/*-API.jar
output/*-DEV.jar
output/*-MDK.zip
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
name: Mekanism CE - CORE ${{ github.event.release.tag_name }}
version: ${{ github.event.release.tag_name }}
version-type: ${{ github.event.release.prerelease && 'beta' || 'release' }}
@@ -152,19 +177,19 @@ jobs:
include:
- name: DefenseTech
project-id: qBExn86I
file: output/*-DefenseTech.jar
classifier: DefenseTech
beta-only: false
- name: Generators
project-id: ksSEAhTL
file: output/*-Generators.jar
classifier: Generators
beta-only: false
- name: Tools
project-id: CD05L8Jr
file: output/*-Tools.jar
classifier: Tools
beta-only: false
- name: Ultimate
project-id: Q6fY4JVC
file: output/*-Ultimate.jar
classifier: Ultimate
beta-only: true
steps:
@@ -179,7 +204,7 @@ jobs:
with:
modrinth-id: ${{ matrix.project-id }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
files: ${{ matrix.file }}
files: output/${{ needs.build.outputs.artifact_prefix }}-${{ matrix.classifier }}.jar
name: Mekanism CE - ${{ matrix.name }} ${{ github.event.release.tag_name }}
version: ${{ github.event.release.tag_name }}
version-type: ${{ matrix.beta-only && 'beta' || (github.event.release.prerelease && 'beta' || 'release') }}
@@ -204,27 +229,27 @@ jobs:
include:
- name: Core
project-id: '399904'
file: output/*-Core.jar
classifier: Core
dependencies: ''
beta-only: false
- name: DefenseTech
project-id: '1488821'
file: output/*-DefenseTech.jar
classifier: DefenseTech
dependencies: mekanism-ce(required)
beta-only: false
- name: Generators
project-id: '813408'
file: output/*-Generators.jar
classifier: Generators
dependencies: mekanism-ce(required)
beta-only: false
- name: Tools
project-id: '813407'
file: output/*-Tools.jar
classifier: Tools
dependencies: mekanism-ce(required)
beta-only: false
- name: Ultimate
project-id: '872280'
file: output/*-Ultimate.jar
classifier: Ultimate
dependencies: mekanism-ce(required)
beta-only: true
@@ -240,7 +265,7 @@ jobs:
with:
curseforge-id: ${{ matrix.project-id }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
files: ${{ matrix.file }}
files: output/${{ needs.build.outputs.artifact_prefix }}-${{ matrix.classifier }}.jar
name: Mekanism CE - ${{ matrix.name }} ${{ github.event.release.tag_name }}
version: ${{ github.event.release.tag_name }}
version-type: ${{ matrix.beta-only && 'beta' || (github.event.release.prerelease && 'beta' || 'release') }}