|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +jobs: |
| 8 | + # ── Step 1: Check if the version in CMakeLists.txt is new ─────────────────── |
| 9 | + check-version: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + version: ${{ steps.version.outputs.version }} |
| 13 | + should_release: ${{ steps.tag_check.outputs.should_release }} |
| 14 | + |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Extract version from CMakeLists.txt |
| 21 | + id: version |
| 22 | + run: | |
| 23 | + VERSION=$(grep -oP '(?<=project\(Convoy VERSION )\d+\.\d+\.\d+' CMakeLists.txt) |
| 24 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 25 | + echo "Detected version: $VERSION" |
| 26 | +
|
| 27 | + - name: Check if tag already exists |
| 28 | + id: tag_check |
| 29 | + run: | |
| 30 | + if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then |
| 31 | + echo "Tag v${{ steps.version.outputs.version }} already exists — skipping release." |
| 32 | + echo "should_release=false" >> $GITHUB_OUTPUT |
| 33 | + else |
| 34 | + echo "New version v${{ steps.version.outputs.version }} — will create release." |
| 35 | + echo "should_release=true" >> $GITHUB_OUTPUT |
| 36 | + fi |
| 37 | +
|
| 38 | + # ── Step 2: Build full graphics executable on both platforms ──────────────── |
| 39 | + build-release: |
| 40 | + needs: check-version |
| 41 | + if: needs.check-version.outputs.should_release == 'true' |
| 42 | + name: Build ${{ matrix.config.name }} |
| 43 | + runs-on: ${{ matrix.config.os }} |
| 44 | + |
| 45 | + strategy: |
| 46 | + fail-fast: false |
| 47 | + matrix: |
| 48 | + config: |
| 49 | + - name: "Windows" |
| 50 | + os: windows-latest |
| 51 | + artifact_name: convoy-windows-x86_64 |
| 52 | + artifact_ext: zip |
| 53 | + - name: "Linux" |
| 54 | + os: ubuntu-latest |
| 55 | + artifact_name: convoy-linux-x86_64 |
| 56 | + artifact_ext: tar.gz |
| 57 | + |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + |
| 61 | + # ── Windows: GLFW via vcpkg (static-md = static libs + dynamic CRT) ───── |
| 62 | + - name: Bootstrap vcpkg (Windows) |
| 63 | + if: runner.os == 'Windows' |
| 64 | + run: | |
| 65 | + git clone --depth=1 https://github.com/microsoft/vcpkg.git C:/vcpkg |
| 66 | + C:/vcpkg/bootstrap-vcpkg.bat -disableMetrics |
| 67 | + shell: bash |
| 68 | + |
| 69 | + - name: Cache vcpkg packages (Windows) |
| 70 | + if: runner.os == 'Windows' |
| 71 | + uses: actions/cache@v4 |
| 72 | + with: |
| 73 | + path: C:/vcpkg/installed |
| 74 | + key: vcpkg-windows-${{ hashFiles('vcpkg.json') }} |
| 75 | + restore-keys: vcpkg-windows- |
| 76 | + |
| 77 | + - name: Configure CMake (Windows) |
| 78 | + if: runner.os == 'Windows' |
| 79 | + run: | |
| 80 | + cmake -B build \ |
| 81 | + -DCMAKE_BUILD_TYPE=Release \ |
| 82 | + -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" \ |
| 83 | + -DVCPKG_TARGET_TRIPLET=x64-windows-static-md |
| 84 | + shell: bash |
| 85 | + |
| 86 | + # ── Linux: build GLFW 3.4 from source (Ubuntu apt ships 3.3.x) ────────── |
| 87 | + - name: Install build dependencies (Linux) |
| 88 | + if: runner.os == 'Linux' |
| 89 | + run: | |
| 90 | + sudo apt-get update |
| 91 | + sudo apt-get install -y build-essential cmake libgl1-mesa-dev xorg-dev wget unzip |
| 92 | +
|
| 93 | + - name: Build and install GLFW 3.4 from source (Linux) |
| 94 | + if: runner.os == 'Linux' |
| 95 | + run: | |
| 96 | + wget -q https://github.com/glfw/glfw/releases/download/3.4/glfw-3.4.zip |
| 97 | + unzip -q glfw-3.4.zip |
| 98 | + cmake -B glfw-build -S glfw-3.4 \ |
| 99 | + -DGLFW_BUILD_DOCS=OFF \ |
| 100 | + -DGLFW_BUILD_TESTS=OFF \ |
| 101 | + -DGLFW_BUILD_EXAMPLES=OFF \ |
| 102 | + -DCMAKE_BUILD_TYPE=Release |
| 103 | + cmake --build glfw-build |
| 104 | + sudo cmake --install glfw-build |
| 105 | + rm -rf glfw-3.4 glfw-3.4.zip glfw-build |
| 106 | +
|
| 107 | + - name: Configure CMake (Linux) |
| 108 | + if: runner.os == 'Linux' |
| 109 | + run: cmake -B build -DCMAKE_BUILD_TYPE=Release |
| 110 | + |
| 111 | + # ── Build ──────────────────────────────────────────────────────────────── |
| 112 | + - name: Build |
| 113 | + run: cmake --build build --config Release |
| 114 | + |
| 115 | + # ── Verify convoy executable was produced ──────────────────────────────── |
| 116 | + - name: Verify executable (Windows) |
| 117 | + if: runner.os == 'Windows' |
| 118 | + run: test -f build/Release/convoy.exe |
| 119 | + shell: bash |
| 120 | + |
| 121 | + - name: Verify executable (Linux) |
| 122 | + if: runner.os == 'Linux' |
| 123 | + run: test -f build/convoy |
| 124 | + |
| 125 | + # ── Package ────────────────────────────────────────────────────────────── |
| 126 | + - name: Package (Windows) |
| 127 | + if: runner.os == 'Windows' |
| 128 | + run: | |
| 129 | + mkdir dist |
| 130 | + cp build/Release/convoy.exe dist/ |
| 131 | + 7z a convoy-windows-x86_64.zip ./dist/convoy.exe |
| 132 | + shell: bash |
| 133 | + |
| 134 | + - name: Package (Linux) |
| 135 | + if: runner.os == 'Linux' |
| 136 | + run: | |
| 137 | + mkdir dist |
| 138 | + cp build/convoy dist/ |
| 139 | + tar -czf convoy-linux-x86_64.tar.gz -C dist convoy |
| 140 | +
|
| 141 | + - name: Upload artifact |
| 142 | + uses: actions/upload-artifact@v4 |
| 143 | + with: |
| 144 | + name: ${{ matrix.config.artifact_name }} |
| 145 | + path: ${{ matrix.config.artifact_name }}.${{ matrix.config.artifact_ext }} |
| 146 | + |
| 147 | + # ── Step 3: Create git tag and GitHub Release ──────────────────────────────── |
| 148 | + create-release: |
| 149 | + needs: [check-version, build-release] |
| 150 | + if: needs.check-version.outputs.should_release == 'true' |
| 151 | + runs-on: ubuntu-latest |
| 152 | + permissions: |
| 153 | + contents: write |
| 154 | + |
| 155 | + steps: |
| 156 | + - uses: actions/checkout@v4 |
| 157 | + with: |
| 158 | + fetch-depth: 0 |
| 159 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + |
| 161 | + - name: Create and push git tag |
| 162 | + run: | |
| 163 | + git config user.name "github-actions[bot]" |
| 164 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 165 | + git tag "v${{ needs.check-version.outputs.version }}" |
| 166 | + git push origin "v${{ needs.check-version.outputs.version }}" |
| 167 | +
|
| 168 | + - name: Download all build artifacts |
| 169 | + uses: actions/download-artifact@v4 |
| 170 | + with: |
| 171 | + path: artifacts |
| 172 | + |
| 173 | + - name: Create GitHub Release |
| 174 | + uses: softprops/action-gh-release@v2 |
| 175 | + with: |
| 176 | + tag_name: v${{ needs.check-version.outputs.version }} |
| 177 | + name: Convoy v${{ needs.check-version.outputs.version }} |
| 178 | + generate_release_notes: true |
| 179 | + files: | |
| 180 | + artifacts/convoy-windows-x86_64/convoy-windows-x86_64.zip |
| 181 | + artifacts/convoy-linux-x86_64/convoy-linux-x86_64.tar.gz |
0 commit comments