|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - 'v*.*.*' |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + name: ${{ matrix.name }} |
| 16 | + runs-on: ${{ matrix.runner }} |
| 17 | + |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - name: Windows x86_64 |
| 23 | + id: windows-x86_64 |
| 24 | + runner: windows-2022 |
| 25 | + generator: Visual Studio 17 2022 |
| 26 | + platform: x64 |
| 27 | + osx_architectures: "" |
| 28 | + |
| 29 | + - name: Ubuntu 22.04 x86_64 |
| 30 | + id: ubuntu-22.04-x86_64 |
| 31 | + runner: ubuntu-22.04 |
| 32 | + generator: Ninja |
| 33 | + platform: "" |
| 34 | + osx_architectures: "" |
| 35 | + |
| 36 | + - name: Ubuntu 22.04 arm64 |
| 37 | + id: ubuntu-22.04-arm64 |
| 38 | + runner: ubuntu-22.04-arm |
| 39 | + generator: Ninja |
| 40 | + platform: "" |
| 41 | + osx_architectures: "" |
| 42 | + |
| 43 | + # - name: macOS x86_64 |
| 44 | + # id: macos-x86_64 |
| 45 | + # runner: macos-13 |
| 46 | + # generator: Ninja |
| 47 | + # platform: "" |
| 48 | + # osx_architectures: "" |
| 49 | + |
| 50 | + # - name: macOS arm64 |
| 51 | + # id: macos-arm64 |
| 52 | + # runner: macos-14 |
| 53 | + # generator: Ninja |
| 54 | + # platform: "" |
| 55 | + # osx_architectures: "" |
| 56 | + |
| 57 | + - name: macOS universal |
| 58 | + id: macos-universal |
| 59 | + runner: macos-14 |
| 60 | + generator: Ninja |
| 61 | + platform: "" |
| 62 | + osx_architectures: x86_64;arm64 |
| 63 | + |
| 64 | + steps: |
| 65 | + - name: Checkout |
| 66 | + uses: actions/checkout@v4 |
| 67 | + |
| 68 | + - name: Install rerun SDK |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + python -m pip install --upgrade pip |
| 72 | + python -m pip install rerun-sdk==0.33.0 |
| 73 | +
|
| 74 | + - name: Configure |
| 75 | + shell: bash |
| 76 | + run: | |
| 77 | + cmake_args=(-S . -B build -G "${{ matrix.generator }}") |
| 78 | +
|
| 79 | + if [ -n "${{ matrix.platform }}" ]; then |
| 80 | + cmake_args+=(-A "${{ matrix.platform }}") |
| 81 | + fi |
| 82 | +
|
| 83 | + if [ -n "${{ matrix.osx_architectures }}" ]; then |
| 84 | + cmake_args+=("-DCMAKE_OSX_ARCHITECTURES=${{ matrix.osx_architectures }}") |
| 85 | + fi |
| 86 | +
|
| 87 | + if [ "${{ runner.os }}" != "Windows" ]; then |
| 88 | + cmake_args+=(-DCMAKE_BUILD_TYPE=Release) |
| 89 | + fi |
| 90 | +
|
| 91 | + cmake "${cmake_args[@]}" |
| 92 | +
|
| 93 | + - name: Build and package |
| 94 | + shell: bash |
| 95 | + run: cmake --build build --config Release --target package |
| 96 | + |
| 97 | + - name: Upload package artifact |
| 98 | + uses: actions/upload-artifact@v4 |
| 99 | + with: |
| 100 | + name: package-${{ matrix.id }} |
| 101 | + path: build/*.zip |
| 102 | + if-no-files-found: error |
| 103 | + |
| 104 | + release: |
| 105 | + name: Create release |
| 106 | + # if: startsWith(github.ref, 'refs/tags/') |
| 107 | + runs-on: ubuntu-22.04 |
| 108 | + needs: build |
| 109 | + |
| 110 | + steps: |
| 111 | + - name: Download packages |
| 112 | + uses: actions/download-artifact@v4 |
| 113 | + with: |
| 114 | + pattern: package-* |
| 115 | + path: dist |
| 116 | + merge-multiple: true |
| 117 | + |
| 118 | + - name: Create or update GitHub release |
| 119 | + shell: bash |
| 120 | + env: |
| 121 | + GH_REPO: ${{ github.repository }} |
| 122 | + GH_TOKEN: ${{ github.token }} |
| 123 | + run: | |
| 124 | + set -euo pipefail |
| 125 | +
|
| 126 | + tag_name="ci-${GITHUB_SHA}" |
| 127 | + release_title="CI build ${GITHUB_SHA:0:12}" |
| 128 | + release_flags=(--prerelease) |
| 129 | +
|
| 130 | + if [ "${GITHUB_REF_TYPE}" = "tag" ]; then |
| 131 | + tag_name="${GITHUB_REF_NAME}" |
| 132 | + release_title="${GITHUB_REF_NAME}" |
| 133 | + release_flags=() |
| 134 | + fi |
| 135 | +
|
| 136 | + notes="Automated packages for ${GITHUB_SHA}." |
| 137 | +
|
| 138 | + if gh release view "${tag_name}" >/dev/null 2>&1; then |
| 139 | + gh release upload "${tag_name}" dist/*.zip --clobber |
| 140 | + else |
| 141 | + gh release create "${tag_name}" dist/*.zip \ |
| 142 | + --target "${GITHUB_SHA}" \ |
| 143 | + --title "${release_title}" \ |
| 144 | + --notes "${notes}" \ |
| 145 | + "${release_flags[@]}" |
| 146 | + fi |
0 commit comments