Update manually.yml #8
This file contains hidden or 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: Manually Build | ||
| on: | ||
| release: | ||
| types: [created] | ||
| jobs: | ||
| package-release: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| actions: read | ||
| env: | ||
| INCLUDE_PATHS: | | ||
| assets/ | ||
| MyCTMLib.cfg | ||
| pack.mcmeta | ||
| pack.png | ||
| README.md | ||
| TARGET_BRANCHES: "main no_mixed_color_gc_plate resonatic_circuit 2.8" | ||
| ZIP_NAME_main: "Modernity-GTNH-${{ github.event.release.tag_name }}.zip" | ||
| ZIP_NAME_no_mixed_color_gc_plate: "Modernity-GTNH-NoMixinColorGCHeavyMaterial.zip" | ||
| ZIP_NAME_resonatic_circuit: "Modernity-GTNH-GTNLResonaticCircuit.zip" | ||
| ZIP_NAME_2.8: "Modernity-GTNH-28x-Fix.zip" | ||
| EXTERNAL_REPOS: | | ||
| OutlinedOres-Modern=https://github.com/Ranzuu/OutlinedOres-Modern | ||
| Just-Productive-Bees=https://github.com/DarkScorpyon/Just-Productive-Bees- | ||
| Just-Forestry-Bees=https://github.com/DarkScorpyon/Just-Forestry-Bees- | ||
| EXTERNAL_ZIP_NAME_OutlinedOres_Modern: "Modernity-GTNH-OutlinedOres.zip" | ||
| EXTERNAL_ZIP_NAME_Just_Productive_Bees: "Modernity-GTNH-Just-Productive-Bees.zip" | ||
| EXTERNAL_ZIP_NAME_Just_Forestry_Bees: "Modernity-GTNH-Just-Forestry-Bees.zip" | ||
| steps: | ||
| - name: Checkout full repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.release.tag_name }} | ||
| fetch-depth: 0 | ||
| fetch-tags: true | ||
| - name: Get short commit hash | ||
| run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV | ||
| - name: Get last two release tags from ABKQPO/MyCTMLib | ||
| run: | | ||
| response=$(curl -s "https://api.github.com/repos/ABKQPO/MyCTMLib/releases?per_page=2") | ||
| tags=($(echo "$response" | jq -r '.[].tag_name')) | ||
| echo "TAG1=${tags[0]}" >> $GITHUB_ENV | ||
| echo "TAG2=${tags[1]}" >> $GITHUB_ENV | ||
| - name: Build all branches | ||
| run: | | ||
| TAG=${{ github.event.release.tag_name }} | ||
| for BRANCH in $TARGET_BRANCHES; do | ||
| echo "Checking out branch: $BRANCH" | ||
| git checkout $BRANCH | ||
| VAR_NAME="ZIP_NAME_${BRANCH//-/_}" | ||
| ZIP_TEMPLATE="${!VAR_NAME}" | ||
| ZIP_NAME="$ZIP_TEMPLATE" | ||
| ZIP_NAME="${ZIP_NAME//\{TAG\}/$TAG}" | ||
| ZIP_NAME="${ZIP_NAME//\{SHA\}/${GITHUB_SHA::7}}" | ||
| echo "Building ZIP for branch $BRANCH: $ZIP_NAME" | ||
| rm -rf zip-root | ||
| mkdir zip-root | ||
| for path in $INCLUDE_PATHS; do | ||
| if [ -e "$path" ]; then | ||
| cp -r --parents "$path" zip-root/ | ||
| fi | ||
| done | ||
| cd zip-root | ||
| zip -r "../$ZIP_NAME" ./ | ||
| cd .. | ||
| done | ||
| shell: bash | ||
| env: | ||
| INCLUDE_PATHS: ${{ env.INCLUDE_PATHS }} | ||
| ZIP_NAME_main: ${{ env.ZIP_NAME_main }} | ||
| ZIP_NAME_no_mixed_color_gc_plate: ${{ env.ZIP_NAME_no_mixed_color_gc_plate }} | ||
| ZIP_NAME_resonatic_circuit: ${{ env.ZIP_NAME_resonatic_circuit }} | ||
| ZIP_NAME_2.8: ${{ env.ZIP_NAME_2.8 }} | ||
| - name: Download and package external repositories | ||
| run: | | ||
| mkdir external-zips | ||
| while IFS== read -r NAME URL; do | ||
| [ -z "$NAME" ] && continue | ||
| SAFE_NAME="${NAME//-/_}" | ||
| ZIP_VAR="EXTERNAL_ZIP_NAME_${SAFE_NAME}" | ||
| ZIP_NAME="${!ZIP_VAR}" | ||
| echo "Cloning $URL as $NAME ..." | ||
| git clone --depth=1 "$URL" "$NAME" | ||
| ZIP_DIR="external-zips/${NAME}-zip-root" | ||
| mkdir -p "$ZIP_DIR" | ||
| for path in $INCLUDE_PATHS; do | ||
| [ -z "$path" ] && continue | ||
| if [ -e "$NAME/$path" ]; then | ||
| mkdir -p "$(dirname "$ZIP_DIR/$path")" | ||
| cp -r "$NAME/$path" "$ZIP_DIR/$path" | ||
| fi | ||
| done | ||
| cd "$ZIP_DIR" | ||
| zip -r "../../$ZIP_NAME" ./ | ||
| cd ../.. | ||
| done <<< "$EXTERNAL_REPOS" | ||
| shell: bash | ||
| env: | ||
| INCLUDE_PATHS: ${{ env.INCLUDE_PATHS }} | ||
| EXTERNAL_ZIP_NAME_OutlinedOres_Modern: ${{ env.EXTERNAL_ZIP_NAME_OutlinedOres_Modern }} | ||
| EXTERNAL_ZIP_NAME_Just_Productive_Bees: ${{ env.EXTERNAL_ZIP_NAME_Just_Productive_Bees }} | ||
| EXTERNAL_ZIP_NAME_Just_Forestry_Bees: ${{ env.EXTERNAL_ZIP_NAME_Just_Forestry_Bees }} | ||
| - name: Download latest two MyCTMLib jars | ||
| run: | | ||
| mkdir jars | ||
| for TAG in "$TAG1" "$TAG2"; do | ||
| URL="https://github.com/ABKQPO/MyCTMLib/releases/download/${TAG}/MyCTMLib-${TAG}.jar" | ||
| echo "Downloading $URL" | ||
| curl -L "$URL" -o jars/MyCTMLib-${TAG}.jar | ||
| done | ||
| shell: bash | ||
| env: | ||
| TAG1: ${{ env.TAG1 }} | ||
| TAG2: ${{ env.TAG2 }} | ||
| - name: Upload files to release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ github.event.release.tag_name }} | ||
| files: | | ||
| Modernity-GTNH-${{ github.event.release.tag_name }}.zip | ||
| Modernity-GTNH-28x-Fix.zip | ||
| Modernity-GTNH-NoMixinColorGCHeavyMaterial.zip | ||
| Modernity-GTNH-GTNLResonaticCircuit.zip | ||
| Modernity-GTNH-OutlinedOres.zip | ||
| Modernity-GTNH-Just-Productive-Bees.zip | ||
| Modernity-GTNH-Just-Forestry-Bees.zip | ||
| jars/MyCTMLib-${{ env.TAG1 }}.jar | ||
| jars/MyCTMLib-${{ env.TAG2 }}.jar | ||