Skip to content

Commit c6126fb

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 c6126fb

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

.github/workflows/python-package.yml

Lines changed: 14 additions & 8 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: ["Build, Test and Release SQLite AI"]
12+
types:
13+
- completed
1214

1315
jobs:
14-
build-and-publish:
16+
build-and-publish: # && github.event.workflow_run.head_branch == 'main')
17+
if: |
18+
github.event_name == 'workflow_dispatch' ||
19+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
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
@@ -93,4 +99,4 @@ jobs:
9399
# Avoid workflow to fail if the version has already been published
94100
skip-existing: true
95101
# Upload to Test Pypi for testing
96-
# repository-url: https://test.pypi.org/legacy/
102+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)