Skip to content

Commit f2c8a0b

Browse files
author
Daniele Briggi
committed
fix(workflow): trigger when main workflow completes
- release or publish trigger doesn't work when the relase is done by another workflow
1 parent 878a1cf commit f2c8a0b

File tree

3 files changed

+70
-59
lines changed

3 files changed

+70
-59
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build, Test and Release SQLite AI
1+
name: Build and Test
22
on:
33
push:
44
workflow_dispatch:
@@ -358,55 +358,3 @@ jobs:
358358
name: ai-${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
359359
path: dist/ai.*
360360
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/[email protected]
371-
372-
- uses: actions/[email protected]
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/[email protected]
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

.github/workflows/python-package.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ on:
77
description: "Version to use for the Python package (e.g. 0.5.9)"
88
required: true
99
type: string
10-
release:
11-
types: [released]
10+
workflow_run:
11+
workflows: ["Release"]
12+
types:
13+
- completed
1214

1315
jobs:
1416
build-and-publish:
17+
if: |
18+
github.event_name == 'workflow_dispatch' ||
19+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main')
1520
runs-on: ${{ matrix.os }}
1621
permissions:
17-
id-token: write # mandatory for Pypi trusted publishing
22+
id-token: write # mandatory for Pypi trusted publishing
1823
strategy:
1924
matrix:
2025
include:
@@ -42,7 +47,7 @@ jobs:
4247
platform: macos
4348
python-version: "3.10"
4449
arch: arm64
45-
plat_name: macosx_11_0_arm64
50+
plat_name: macosx_11_0_arm64
4651
defaults:
4752
run:
4853
shell: bash
@@ -65,8 +70,9 @@ jobs:
6570
- name: Get version
6671
id: get_version
6772
run: |
68-
if [[ "${{ github.event_name }}" == "release" ]]; then
69-
VERSION="${{ github.event.release.tag_name }}"
73+
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
74+
# Fetch latest published release tag from GitHub API
75+
VERSION=$(curl -s "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r '.tag_name')
7076
else
7177
VERSION="${{ github.event.inputs.version }}"
7278
fi

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build and Test"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
release:
11+
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main'
12+
runs-on: ubuntu-22.04
13+
name: release
14+
steps:
15+
- uses: actions/[email protected]
16+
17+
- uses: actions/[email protected]
18+
with:
19+
path: artifacts
20+
21+
- name: release tag version from sqlite-ai.h
22+
id: tag
23+
run: |
24+
VERSION=$(make version)
25+
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
26+
LATEST=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.name')
27+
if [[ "$VERSION" != "$LATEST" || "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
28+
echo "version=$VERSION" >> $GITHUB_OUTPUT
29+
else
30+
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"
31+
fi
32+
exit 0
33+
fi
34+
echo "❌ SQLITE_AI_VERSION not found in sqlite-ai.h"
35+
exit 1
36+
37+
- name: zip artifacts
38+
run: |
39+
for folder in "artifacts"/*; do
40+
if [ -d "$folder" ]; then
41+
name=$(basename "$folder")
42+
if [[ "$name" != "ai-apple-xcframework" ]]; then
43+
tar -czf "${name}-${{ steps.tag.outputs.version }}.tar.gz" -C "$folder" .
44+
fi
45+
(cd "$folder" && zip -rq "../../${name}-${{ steps.tag.outputs.version }}.zip" .)
46+
fi
47+
done
48+
49+
- uses: softprops/[email protected]
50+
if: steps.tag.outputs.version != ''
51+
with:
52+
generate_release_notes: true
53+
tag_name: ${{ steps.tag.outputs.version }}
54+
files: |
55+
ai-*-${{ steps.tag.outputs.version }}.zip
56+
ai-*-${{ steps.tag.outputs.version }}.tar.gz
57+
make_latest: true

0 commit comments

Comments
 (0)