name: Build macOS reusable template on: workflow_call: inputs: macos_version: required: true type: string image_format: required: true type: string jobs: build-macos-image: runs-on: macos-15-intel timeout-minutes: 80 steps: - name: Preflight run: | FOUND=false PAGE=1 while [ $PAGE -le 50 ]; do DATA=$(curl -s \ -H "Accept: application/vnd.github+json" \ "https://api.github.com/repos/LongQT-sea/macos-iso-builder/stargazers?per_page=100&page=${PAGE}") echo "$DATA" | grep -qi '"login".*"${{ github.actor }}"' && FOUND=true && break [ "$(echo "$DATA" | grep -c '"login"')" -lt 100 ] && break PAGE=$((PAGE + 1)) done if [ "$FOUND" = "false" ]; then echo "Workflow blocked for mysterious reasons. Starring the repo might help. Worth a shot." >> $GITHUB_STEP_SUMMARY echo "Head over to https://github.com/LongQT-sea/macos-iso-builder, drop a star, and re-run." >> $GITHUB_STEP_SUMMARY echo "![star](https://raw.githubusercontent.com/LongQT-sea/mkmaciso/main/.github/star.jpg)" >> $GITHUB_STEP_SUMMARY exit 1 fi - name: Checkout repository uses: actions/checkout@v5 - name: System Information run: | echo "Runner OS: $(sw_vers -productName) $(sw_vers -productVersion)" echo "Architecture: $(uname -m)" echo "" df -h $(mktemp) echo "" echo "RAM: $(top -l 1 | grep PhysMem)" echo "" echo "CPU: $(sysctl -n machdep.cpu.brand_string)" echo "" echo "Model: $(sysctl -n hw.model)" - name: Create macOS image id: create_image continue-on-error: true run: | if [ "${{ inputs.image_format }}" == "iso" ]; then sudo bash mkmaciso "${{ inputs.macos_version }}" iso echo "image_name=$(basename *.iso)" >> $GITHUB_OUTPUT else sudo bash mkmaciso "${{ inputs.macos_version }}" dmg echo "image_name=$(basename *.dmg.img)" >> $GITHUB_OUTPUT fi - name: Upload ISO artifact if: inputs.image_format == 'iso' && steps.create_image.outcome == 'success' uses: actions/upload-artifact@v5 with: name: ${{ steps.create_image.outputs.image_name }} path: ./*.iso compression-level: 0 retention-days: 15 - name: Upload DMG artifact if: inputs.image_format == 'dmg' && steps.create_image.outcome == 'success' uses: actions/upload-artifact@v5 with: name: ${{ steps.create_image.outputs.image_name }} path: ./*.dmg.img compression-level: 0 retention-days: 15 - name: Summary if: always() run: | if [ "${{ steps.create_image.outcome }}" == "failure" ]; then echo "## Download macOS failed" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY echo "> This runner may have network issues. Please **re-run the workflow** to try a different runner." >> $GITHUB_STEP_SUMMARY elif [ "${{ job.status }}" == "success" ]; then if [ "${{ inputs.image_format }}" == "iso" ]; then echo "## Successfully built $(basename *.iso)" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "> [!Important]" >> $GITHUB_STEP_SUMMARY echo "> This ISO image is intended for creating macOS virtual machines on Proxmox VE, QEMU, VMware, and VirtualBox." >> $GITHUB_STEP_SUMMARY else echo "## Successfully built $(basename *.dmg.img)" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "> [!Important]" >> $GITHUB_STEP_SUMMARY echo '> This DMG image is intended for flashing to USB drive using [Rufus](https://rufus.ie/en/#download) *(Windows)* or `dd` *(Linux)*.' >> $GITHUB_STEP_SUMMARY fi echo "" >> $GITHUB_STEP_SUMMARY echo "> [!TIP]" >> $GITHUB_STEP_SUMMARY echo "> Enable [Cloudflare WARP](https://one.one.one.one/) for faster connection to Azure Blob Storage." >> $GITHUB_STEP_SUMMARY fi