|
| 1 | +name: Build and Release Macro Plugin |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build-arm64: |
| 9 | + name: Build arm64 |
| 10 | + runs-on: macos-15 |
| 11 | + steps: |
| 12 | + - name: Git Checkout |
| 13 | + uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Build arm64 macro plugin |
| 16 | + run: | |
| 17 | + swift build -c release --product ReerCodableMacros |
| 18 | + cp .build/release/ReerCodableMacros-tool ./ReerCodableMacros-arm64 |
| 19 | + file ./ReerCodableMacros-arm64 |
| 20 | + |
| 21 | + - name: Upload arm64 artifact |
| 22 | + uses: actions/upload-artifact@v4 |
| 23 | + with: |
| 24 | + name: macro-plugin-arm64 |
| 25 | + path: ReerCodableMacros-arm64 |
| 26 | + |
| 27 | + build-x86_64: |
| 28 | + name: Build x86_64 |
| 29 | + runs-on: macos-15-intel |
| 30 | + steps: |
| 31 | + - name: Git Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Build x86_64 macro plugin |
| 35 | + run: | |
| 36 | + swift build -c release --product ReerCodableMacros |
| 37 | + cp .build/release/ReerCodableMacros-tool ./ReerCodableMacros-x86_64 |
| 38 | + file ./ReerCodableMacros-x86_64 |
| 39 | + |
| 40 | + - name: Upload x86_64 artifact |
| 41 | + uses: actions/upload-artifact@v4 |
| 42 | + with: |
| 43 | + name: macro-plugin-x86_64 |
| 44 | + path: ReerCodableMacros-x86_64 |
| 45 | + |
| 46 | + create-universal-and-upload: |
| 47 | + name: Create Universal Macro Plugin and Upload |
| 48 | + needs: [build-arm64, build-x86_64] |
| 49 | + runs-on: macos-15 |
| 50 | + permissions: |
| 51 | + contents: write |
| 52 | + steps: |
| 53 | + - name: Git Checkout |
| 54 | + uses: actions/checkout@v4 |
| 55 | + |
| 56 | + - name: Download arm64 artifact |
| 57 | + uses: actions/download-artifact@v4 |
| 58 | + with: |
| 59 | + name: macro-plugin-arm64 |
| 60 | + path: ./artifacts |
| 61 | + |
| 62 | + - name: Download x86_64 artifact |
| 63 | + uses: actions/download-artifact@v4 |
| 64 | + with: |
| 65 | + name: macro-plugin-x86_64 |
| 66 | + path: ./artifacts |
| 67 | + |
| 68 | + - name: Create Universal Macro Plugin and Artifact Bundle |
| 69 | + run: | |
| 70 | + cd artifacts |
| 71 | + |
| 72 | + # Create Universal Macro Plugin |
| 73 | + lipo -create ReerCodableMacros-arm64 ReerCodableMacros-x86_64 \ |
| 74 | + -output ReerCodableMacros |
| 75 | + |
| 76 | + echo "=== Universal Macro Plugin Info ===" |
| 77 | + lipo -info ReerCodableMacros |
| 78 | + file ReerCodableMacros |
| 79 | + |
| 80 | + # Create artifact bundle structure |
| 81 | + mkdir -p ReerCodableMacros.artifactbundle/macos/bin |
| 82 | + cp ReerCodableMacros ReerCodableMacros.artifactbundle/macos/bin/ |
| 83 | + |
| 84 | + # Create info.json |
| 85 | + cat > ReerCodableMacros.artifactbundle/info.json << EOF |
| 86 | + { |
| 87 | + "schemaVersion": "1.0", |
| 88 | + "artifacts": { |
| 89 | + "ReerCodableMacros": { |
| 90 | + "version": "${{ github.ref_name }}", |
| 91 | + "type": "executable", |
| 92 | + "variants": [ |
| 93 | + { |
| 94 | + "path": "macos/bin/ReerCodableMacros", |
| 95 | + "supportedTriples": ["x86_64-apple-macosx", "arm64-apple-macosx"] |
| 96 | + } |
| 97 | + ] |
| 98 | + } |
| 99 | + } |
| 100 | + } |
| 101 | + EOF |
| 102 | + |
| 103 | + # Create zip archive |
| 104 | + zip -r ReerCodableMacros.artifactbundle.zip ReerCodableMacros.artifactbundle |
| 105 | + |
| 106 | + echo "=== Artifact Bundle Contents ===" |
| 107 | + unzip -l ReerCodableMacros.artifactbundle.zip |
| 108 | + |
| 109 | + - name: Upload to GitHub Release |
| 110 | + uses: softprops/action-gh-release@v2 |
| 111 | + with: |
| 112 | + files: | |
| 113 | + artifacts/ReerCodableMacros |
| 114 | + artifacts/ReerCodableMacros.artifactbundle.zip |
0 commit comments