fix(ci): add -c to jq in gen_matrix for compact JSON output #45
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: Build | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: "25" | |
| distribution: "zulu" | |
| cache: "gradle" | |
| - name: Make gradle wrapper executable | |
| run: chmod +x ./gradlew | |
| - name: Read mod version | |
| id: mod_info | |
| run: echo "mod_version=$(grep '^mod_version' gradle.properties | cut -d= -f2)" >> $GITHUB_OUTPUT | |
| - name: Build all versions | |
| run: | | |
| mkdir -p dist | |
| VERSION="${{ steps.mod_info.outputs.mod_version }}" | |
| while read -r version_data; do | |
| VER=$(echo "$version_data" | jq -r '.version') | |
| MC_SRC=$(echo "$version_data" | jq -r '.mcVersion // .version') | |
| MC_VER=$(echo "$version_data" | jq -r '.minecraft_version') | |
| FABRIC_API=$(echo "$version_data" | jq -r '.fabric_api_version') | |
| YARN=$(echo "$version_data" | jq -r '.yarn_mappings // empty') | |
| LOADER=$(echo "$version_data" | jq -r '.loader_version // empty') | |
| if [ ! -d "src/mc-${MC_SRC}" ]; then | |
| echo "Skipping $VER (no src/mc-${MC_SRC})" | |
| continue | |
| fi | |
| echo "Building $VER..." | |
| PROP_ARGS=(-DmcVersion="$MC_SRC" -PmcVersion="$MC_SRC" -Pminecraft_version="$MC_VER" -Pfabric_api_version="$FABRIC_API") | |
| [ -n "$YARN" ] && PROP_ARGS+=(-Pyarn_mappings="$YARN") | |
| [ -n "$LOADER" ] && PROP_ARGS+=(-Ploader_version="$LOADER") | |
| ./gradlew clean build "${PROP_ARGS[@]}" --no-daemon -q 2>&1 || exit 1 | |
| cp "build/libs/stackabletools-${VERSION}.jar" "dist/stackabletools-${VERSION}-mc${VER}.jar" | |
| done < <(jq -c '.versions[]' versions.json) | |
| - name: Push artifacts to build branch | |
| run: | | |
| cd dist | |
| git init | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git checkout -b build | |
| git add . | |
| git commit -m "Build v${{ steps.mod_info.outputs.mod_version }} - $(date +'%Y-%m-%d %H:%M:%S')" | |
| git remote add origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" | |
| git push --force-with-lease origin build 2>/dev/null || git push -f origin build |