|
| 1 | +name: release-on-tag |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build - ${{ matrix.target }} |
| 12 | + runs-on: ${{ matrix.runner }} |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - runner: ubuntu-latest |
| 17 | + target: x86_64-unknown-linux-gnu |
| 18 | + bin: libgodot_mcap.so |
| 19 | + final_name: godot_mcap.so |
| 20 | + |
| 21 | + - runner: windows-latest |
| 22 | + target: x86_64-pc-windows-msvc |
| 23 | + bin: godot_mcap.dll |
| 24 | + final_name: godot_mcap.dll |
| 25 | + |
| 26 | + - runner: macos-latest |
| 27 | + target: x86_64-apple-darwin |
| 28 | + bin: libgodot_mcap.dylib |
| 29 | + final_name: godot_mcap_x64.dylib |
| 30 | + |
| 31 | + - runner: macos-latest |
| 32 | + target: aarch64-apple-darwin |
| 33 | + bin: libgodot_mcap.dylib |
| 34 | + final_name: godot_mcap_arm.dylib |
| 35 | + |
| 36 | + - runner: ubuntu-latest |
| 37 | + target: aarch64-linux-android |
| 38 | + bin: libgodot_mcap.so |
| 39 | + final_name: libgodot_mcap_arm64.so |
| 40 | + |
| 41 | + - runner: ubuntu-latest |
| 42 | + target: armv7-linux-androideabi |
| 43 | + bin: libgodot_mcap.so |
| 44 | + final_name: libgodot_mcap_armv7.so |
| 45 | + |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + - name: Install Rust |
| 49 | + uses: dtolnay/rust-toolchain@stable |
| 50 | + with: |
| 51 | + targets: ${{ matrix.target }} |
| 52 | + |
| 53 | + - name: Install cargo-ndk |
| 54 | + if: startsWith(matrix.target, 'aarch64-linux-android') || startsWith(matrix.target, 'armv7-linux-androideabi') |
| 55 | + run: | |
| 56 | + cargo install cargo-ndk |
| 57 | + rustup target add aarch64-linux-android armv7-linux-androideabi |
| 58 | + rustup target install aarch64-linux-android armv7-linux-androideabi |
| 59 | +
|
| 60 | + - name: Setup Android NDK |
| 61 | + if: startsWith(matrix.target, 'aarch64-linux-android') || startsWith(matrix.target, 'armv7-linux-androideabi') |
| 62 | + |
| 63 | + with: |
| 64 | + ndk-version: r27c |
| 65 | + |
| 66 | + - name: Setup Java JDK |
| 67 | + if: startsWith(matrix.target, 'aarch64-linux-android') || startsWith(matrix.target, 'armv7-linux-androideabi') |
| 68 | + |
| 69 | + with: |
| 70 | + java-version: 17 |
| 71 | + distribution: temurin |
| 72 | + java-package: jdk |
| 73 | + |
| 74 | + - name: Build rust binary |
| 75 | + if: startsWith(matrix.target, 'x86_64-unknown-linux-gnu') || startsWith(matrix.target, 'x86_64-pc-windows-msvc') || startsWith(matrix.target, 'x86_64-apple-darwin') || startsWith(matrix.target, 'aarch64-apple-darwin') |
| 76 | + run: cargo build --verbose --locked --release --target ${{ matrix.target }} |
| 77 | + |
| 78 | + - name: Build rust binary for android |
| 79 | + if: startsWith(matrix.target, 'aarch64-linux-android') || startsWith(matrix.target, 'armv7-linux-androideabi') |
| 80 | + run: cargo ndk -t ${{ matrix.target }} build --release --verbose |
| 81 | + |
| 82 | + - name: Rename to final_name |
| 83 | + run: mv target/${{ matrix.target }}/release/${{ matrix.bin }} target/${{ matrix.target }}/release/${{ matrix.final_name }} |
| 84 | + |
| 85 | + - name: Upload artifact |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: ${{ matrix.final_name }} |
| 89 | + path: target/${{ matrix.target }}/release/${{ matrix.final_name }} |
| 90 | + |
| 91 | + package: |
| 92 | + runs-on: macos-latest |
| 93 | + needs: build |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + |
| 97 | + - name: Download all binaries into addons/godot_mcap |
| 98 | + uses: actions/download-artifact@v4 |
| 99 | + with: |
| 100 | + path: addons/godot_mcap |
| 101 | + merge-multiple: true |
| 102 | + |
| 103 | + # Make a universal macOS dylib from the two arch builds |
| 104 | + - name: Build macOS universal dylib |
| 105 | + run: | |
| 106 | + lipo -create \ |
| 107 | + -output addons/godot_mcap/godot_mcap.dylib \ |
| 108 | + addons/godot_mcap/godot_mcap_x64.dylib \ |
| 109 | + addons/godot_mcap/godot_mcap_arm.dylib |
| 110 | + rm addons/godot_mcap/godot_mcap_x64.dylib addons/godot_mcap/godot_mcap_arm.dylib |
| 111 | +
|
| 112 | + - name: Generate third party notices |
| 113 | + run: | |
| 114 | + cargo install cargo-about --locked |
| 115 | + cargo about generate about.hbs > addons/godot_mcap/LICENSE_NOTICES.html |
| 116 | +
|
| 117 | + - name: Zip addon folder |
| 118 | + run: | |
| 119 | + zip -r godot_mcap.zip addons |
| 120 | +
|
| 121 | + - name: Upload package |
| 122 | + uses: actions/upload-artifact@v4 |
| 123 | + with: |
| 124 | + name: package |
| 125 | + path: godot_mcap.zip |
| 126 | + |
| 127 | + release: |
| 128 | + runs-on: ubuntu-latest |
| 129 | + needs: package |
| 130 | + if: startsWith(github.ref, 'refs/tags/v') |
| 131 | + permissions: |
| 132 | + contents: write |
| 133 | + steps: |
| 134 | + - name: Download package |
| 135 | + uses: actions/download-artifact@v4 |
| 136 | + with: |
| 137 | + name: package |
| 138 | + path: . |
| 139 | + |
| 140 | + - name: Create draft release |
| 141 | + uses: softprops/action-gh-release@v1 |
| 142 | + with: |
| 143 | + tag_name: ${{ github.ref_name }} |
| 144 | + draft: true |
| 145 | + generate_release_notes: true |
| 146 | + files: godot_mcap.zip |
0 commit comments