|
1 | | -name: Build and Test |
| 1 | +name: Build, Test and Release |
2 | 2 | on: |
3 | 3 | push: |
4 | 4 | workflow_dispatch: |
@@ -358,3 +358,55 @@ jobs: |
358 | 358 | name: ai-${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} |
359 | 359 | path: dist/ai.* |
360 | 360 | if-no-files-found: error |
| 361 | + |
| 362 | + release: |
| 363 | + runs-on: ubuntu-22.04 |
| 364 | + name: release |
| 365 | + needs: build |
| 366 | + if: github.ref == 'refs/heads/main' |
| 367 | + |
| 368 | + steps: |
| 369 | + |
| 370 | + - uses: actions/checkout@v4.2.2 |
| 371 | + |
| 372 | + - uses: actions/download-artifact@v4.2.1 |
| 373 | + with: |
| 374 | + path: artifacts |
| 375 | + |
| 376 | + - name: release tag version from sqlite-ai.h |
| 377 | + id: tag |
| 378 | + run: | |
| 379 | + VERSION=$(make version) |
| 380 | + if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 381 | + LATEST=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.name') |
| 382 | + if [[ "$VERSION" != "$LATEST" || "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then |
| 383 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 384 | + else |
| 385 | + echo "::warning file=src/sqlite-ai.h::To release a new version, please update the SQLITE_AI_VERSION in src/sqlite-ai.h to be different than the latest $LATEST" |
| 386 | + fi |
| 387 | + exit 0 |
| 388 | + fi |
| 389 | + echo "❌ SQLITE_AI_VERSION not found in sqlite-ai.h" |
| 390 | + exit 1 |
| 391 | + |
| 392 | + - name: zip artifacts |
| 393 | + run: | |
| 394 | + for folder in "artifacts"/*; do |
| 395 | + if [ -d "$folder" ]; then |
| 396 | + name=$(basename "$folder") |
| 397 | + if [[ "$name" != "ai-apple-xcframework" ]]; then |
| 398 | + tar -czf "${name}-${{ steps.tag.outputs.version }}.tar.gz" -C "$folder" . |
| 399 | + fi |
| 400 | + (cd "$folder" && zip -rq "../../${name}-${{ steps.tag.outputs.version }}.zip" .) |
| 401 | + fi |
| 402 | + done |
| 403 | +
|
| 404 | + - uses: softprops/action-gh-release@v2.2.1 |
| 405 | + if: steps.tag.outputs.version != '' |
| 406 | + with: |
| 407 | + generate_release_notes: true |
| 408 | + tag_name: ${{ steps.tag.outputs.version }} |
| 409 | + files: | |
| 410 | + ai-*-${{ steps.tag.outputs.version }}.zip |
| 411 | + ai-*-${{ steps.tag.outputs.version }}.tar.gz |
| 412 | + make_latest: true |
0 commit comments