|
| 1 | +name: Build TablePro |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: ['v*'] |
| 7 | + paths-ignore: |
| 8 | + - '**.md' |
| 9 | + - 'docs/**' |
| 10 | + - '.github/**' |
| 11 | + - '.vscode/**' |
| 12 | + pull_request: |
| 13 | + branches: [main] |
| 14 | + paths-ignore: |
| 15 | + - '**.md' |
| 16 | + - 'docs/**' |
| 17 | + |
| 18 | +env: |
| 19 | + XCODE_PROJECT: TablePro.xcodeproj |
| 20 | + XCODE_SCHEME: TablePro |
| 21 | + BUILD_CONFIGURATION: Release |
| 22 | + |
| 23 | +jobs: |
| 24 | + lint: |
| 25 | + name: SwiftLint |
| 26 | + runs-on: macos-14 |
| 27 | + timeout-minutes: 10 |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout code |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Cache SwiftLint |
| 34 | + uses: actions/cache@v4 |
| 35 | + with: |
| 36 | + path: ~/Library/Caches/Homebrew/swiftlint* |
| 37 | + key: swiftlint-${{ runner.os }}-${{ hashFiles('.swiftlint.yml') }} |
| 38 | + restore-keys: | |
| 39 | + swiftlint-${{ runner.os }}- |
| 40 | +
|
| 41 | + - name: Install SwiftLint |
| 42 | + run: brew install swiftlint |
| 43 | + |
| 44 | + - name: Run SwiftLint |
| 45 | + run: swiftlint lint --strict |
| 46 | + |
| 47 | + prepare-libs: |
| 48 | + name: Prepare Universal Libraries |
| 49 | + runs-on: macos-14 |
| 50 | + needs: lint |
| 51 | + timeout-minutes: 25 |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Checkout code |
| 55 | + uses: actions/checkout@v4 |
| 56 | + |
| 57 | + - name: Cache Homebrew packages |
| 58 | + uses: actions/cache@v4 |
| 59 | + with: |
| 60 | + path: | |
| 61 | + ~/Library/Caches/Homebrew |
| 62 | + /opt/homebrew/Cellar/mariadb-connector-c |
| 63 | + /opt/homebrew/Cellar/libpq |
| 64 | + /usr/local/Cellar/mariadb-connector-c |
| 65 | + /usr/local/Cellar/libpq |
| 66 | + key: brew-deps-${{ runner.os }}-${{ hashFiles('**/build-release.sh') }} |
| 67 | + restore-keys: | |
| 68 | + brew-deps-${{ runner.os }}- |
| 69 | +
|
| 70 | + - name: Install ARM64 Homebrew dependencies |
| 71 | + run: | |
| 72 | + brew install mariadb-connector-c libpq |
| 73 | +
|
| 74 | + - name: Install x86_64 Homebrew |
| 75 | + run: | |
| 76 | + # Install Rosetta 2 if needed |
| 77 | + if ! arch -x86_64 /usr/bin/true 2>/dev/null; then |
| 78 | + echo "Installing Rosetta 2..." |
| 79 | + softwareupdate --install-rosetta --agree-to-license |
| 80 | + fi |
| 81 | +
|
| 82 | + # Check if x86_64 Homebrew is already installed |
| 83 | + if [ ! -f /usr/local/bin/brew ]; then |
| 84 | + echo "Installing x86_64 Homebrew..." |
| 85 | + arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 86 | + else |
| 87 | + echo "x86_64 Homebrew already installed" |
| 88 | + fi |
| 89 | +
|
| 90 | + - name: Install x86_64 Homebrew dependencies |
| 91 | + run: | |
| 92 | + arch -x86_64 /usr/local/bin/brew install mariadb-connector-c libpq |
| 93 | +
|
| 94 | + - name: Create universal libmariadb library |
| 95 | + run: | |
| 96 | + echo "Creating universal libmariadb.a..." |
| 97 | + lipo -create \ |
| 98 | + /opt/homebrew/opt/mariadb-connector-c/lib/mariadb/libmariadb.a \ |
| 99 | + /usr/local/opt/mariadb-connector-c/lib/mariadb/libmariadb.a \ |
| 100 | + -output Libs/libmariadb_universal.a |
| 101 | +
|
| 102 | + echo "Verifying universal library:" |
| 103 | + lipo -info Libs/libmariadb_universal.a |
| 104 | + ls -lh Libs/libmariadb_universal.a |
| 105 | +
|
| 106 | + - name: Upload library artifacts |
| 107 | + uses: actions/upload-artifact@v4 |
| 108 | + with: |
| 109 | + name: libs-universal |
| 110 | + path: Libs/ |
| 111 | + retention-days: 1 |
| 112 | + |
| 113 | + build-arm64: |
| 114 | + name: Build ARM64 |
| 115 | + runs-on: macos-14 |
| 116 | + needs: prepare-libs |
| 117 | + timeout-minutes: 20 |
| 118 | + |
| 119 | + steps: |
| 120 | + - name: Checkout code |
| 121 | + uses: actions/checkout@v4 |
| 122 | + |
| 123 | + - name: Download library artifacts |
| 124 | + uses: actions/download-artifact@v4 |
| 125 | + with: |
| 126 | + name: libs-universal |
| 127 | + path: Libs/ |
| 128 | + |
| 129 | + - name: Cache Homebrew packages |
| 130 | + uses: actions/cache@v4 |
| 131 | + with: |
| 132 | + path: | |
| 133 | + ~/Library/Caches/Homebrew |
| 134 | + /opt/homebrew/Cellar/mariadb-connector-c |
| 135 | + /opt/homebrew/Cellar/libpq |
| 136 | + key: brew-arm64-${{ runner.os }}-${{ hashFiles('**/build-release.sh') }} |
| 137 | + restore-keys: | |
| 138 | + brew-arm64-${{ runner.os }}- |
| 139 | +
|
| 140 | + - name: Install ARM64 dependencies |
| 141 | + run: brew install mariadb-connector-c libpq |
| 142 | + |
| 143 | + - name: Build ARM64 |
| 144 | + run: | |
| 145 | + chmod +x build-release.sh |
| 146 | + ./build-release.sh arm64 |
| 147 | +
|
| 148 | + - name: Verify build |
| 149 | + run: | |
| 150 | + echo "Build completed. Binary info:" |
| 151 | + ls -lh build/Release/TablePro-arm64.app/Contents/MacOS/TablePro |
| 152 | + lipo -info build/Release/TablePro-arm64.app/Contents/MacOS/TablePro |
| 153 | + du -sh build/Release/TablePro-arm64.app |
| 154 | +
|
| 155 | + - name: Create ZIP archive |
| 156 | + run: | |
| 157 | + cd build/Release |
| 158 | + zip -r TablePro-arm64.zip TablePro-arm64.app |
| 159 | + ls -lh TablePro-arm64.zip |
| 160 | +
|
| 161 | + - name: Upload artifact |
| 162 | + uses: actions/upload-artifact@v4 |
| 163 | + with: |
| 164 | + name: TablePro-arm64-${{ github.sha }} |
| 165 | + path: build/Release/TablePro-arm64.zip |
| 166 | + retention-days: ${{ startsWith(github.ref, 'refs/tags/v') && 90 || 7 }} |
| 167 | + |
| 168 | + build-x86_64: |
| 169 | + name: Build x86_64 |
| 170 | + runs-on: macos-14 |
| 171 | + needs: prepare-libs |
| 172 | + timeout-minutes: 20 |
| 173 | + |
| 174 | + steps: |
| 175 | + - name: Checkout code |
| 176 | + uses: actions/checkout@v4 |
| 177 | + |
| 178 | + - name: Download library artifacts |
| 179 | + uses: actions/download-artifact@v4 |
| 180 | + with: |
| 181 | + name: libs-universal |
| 182 | + path: Libs/ |
| 183 | + |
| 184 | + - name: Cache Homebrew packages |
| 185 | + uses: actions/cache@v4 |
| 186 | + with: |
| 187 | + path: | |
| 188 | + ~/Library/Caches/Homebrew |
| 189 | + /usr/local/Cellar/mariadb-connector-c |
| 190 | + /usr/local/Cellar/libpq |
| 191 | + key: brew-x86_64-${{ runner.os }}-${{ hashFiles('**/build-release.sh') }} |
| 192 | + restore-keys: | |
| 193 | + brew-x86_64-${{ runner.os }}- |
| 194 | +
|
| 195 | + - name: Install Rosetta 2 |
| 196 | + run: | |
| 197 | + if ! arch -x86_64 /usr/bin/true 2>/dev/null; then |
| 198 | + softwareupdate --install-rosetta --agree-to-license |
| 199 | + fi |
| 200 | +
|
| 201 | + - name: Install x86_64 Homebrew |
| 202 | + run: | |
| 203 | + if [ ! -f /usr/local/bin/brew ]; then |
| 204 | + arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 205 | + fi |
| 206 | +
|
| 207 | + - name: Install x86_64 dependencies |
| 208 | + run: arch -x86_64 /usr/local/bin/brew install mariadb-connector-c libpq |
| 209 | + |
| 210 | + - name: Build x86_64 |
| 211 | + run: | |
| 212 | + chmod +x build-release.sh |
| 213 | + ./build-release.sh x86_64 |
| 214 | +
|
| 215 | + - name: Verify build |
| 216 | + run: | |
| 217 | + echo "Build completed. Binary info:" |
| 218 | + ls -lh build/Release/TablePro-x86_64.app/Contents/MacOS/TablePro |
| 219 | + lipo -info build/Release/TablePro-x86_64.app/Contents/MacOS/TablePro |
| 220 | + du -sh build/Release/TablePro-x86_64.app |
| 221 | +
|
| 222 | + - name: Create ZIP archive |
| 223 | + run: | |
| 224 | + cd build/Release |
| 225 | + zip -r TablePro-x86_64.zip TablePro-x86_64.app |
| 226 | + ls -lh TablePro-x86_64.zip |
| 227 | +
|
| 228 | + - name: Upload artifact |
| 229 | + uses: actions/upload-artifact@v4 |
| 230 | + with: |
| 231 | + name: TablePro-x86_64-${{ github.sha }} |
| 232 | + path: build/Release/TablePro-x86_64.zip |
| 233 | + retention-days: ${{ startsWith(github.ref, 'refs/tags/v') && 90 || 7 }} |
| 234 | + |
| 235 | + release: |
| 236 | + name: Create GitHub Release |
| 237 | + runs-on: macos-14 |
| 238 | + needs: [build-arm64, build-x86_64] |
| 239 | + if: startsWith(github.ref, 'refs/tags/v') |
| 240 | + timeout-minutes: 10 |
| 241 | + |
| 242 | + steps: |
| 243 | + - name: Checkout code |
| 244 | + uses: actions/checkout@v4 |
| 245 | + |
| 246 | + - name: Download ARM64 artifact |
| 247 | + uses: actions/download-artifact@v4 |
| 248 | + with: |
| 249 | + name: TablePro-arm64-${{ github.sha }} |
| 250 | + path: artifacts/ |
| 251 | + |
| 252 | + - name: Download x86_64 artifact |
| 253 | + uses: actions/download-artifact@v4 |
| 254 | + with: |
| 255 | + name: TablePro-x86_64-${{ github.sha }} |
| 256 | + path: artifacts/ |
| 257 | + |
| 258 | + - name: Rename artifacts for release |
| 259 | + run: | |
| 260 | + VERSION=${GITHUB_REF#refs/tags/} |
| 261 | + mv artifacts/TablePro-arm64.zip artifacts/TablePro-${VERSION}-arm64.zip |
| 262 | + mv artifacts/TablePro-x86_64.zip artifacts/TablePro-${VERSION}-x86_64.zip |
| 263 | + ls -lh artifacts/ |
| 264 | +
|
| 265 | + - name: Generate release notes |
| 266 | + id: release_notes |
| 267 | + run: | |
| 268 | + VERSION=${GITHUB_REF#refs/tags/} |
| 269 | + cat > release_notes.md <<EOF |
| 270 | + ## TablePro ${VERSION} |
| 271 | +
|
| 272 | + ### Downloads |
| 273 | +
|
| 274 | + Choose the appropriate version for your Mac: |
| 275 | +
|
| 276 | + - **Apple Silicon (M1/M2/M3)**: Download \`TablePro-${VERSION}-arm64.zip\` |
| 277 | + - **Intel**: Download \`TablePro-${VERSION}-x86_64.zip\` |
| 278 | +
|
| 279 | + ### Installation |
| 280 | +
|
| 281 | + 1. Download the appropriate ZIP file for your Mac |
| 282 | + 2. Unzip the file |
| 283 | + 3. Move TablePro.app to your Applications folder |
| 284 | + 4. Right-click and select "Open" on first launch (unsigned app) |
| 285 | +
|
| 286 | + ### Changes |
| 287 | +
|
| 288 | + $(git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 HEAD^)..HEAD) |
| 289 | + EOF |
| 290 | +
|
| 291 | + cat release_notes.md |
| 292 | +
|
| 293 | + - name: Create GitHub Release |
| 294 | + uses: softprops/action-gh-release@v1 |
| 295 | + with: |
| 296 | + files: | |
| 297 | + artifacts/*.zip |
| 298 | + body_path: release_notes.md |
| 299 | + draft: false |
| 300 | + prerelease: ${{ contains(github.ref, '-beta') || contains(github.ref, '-alpha') || contains(github.ref, '-rc') }} |
| 301 | + env: |
| 302 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments