Skip to content

Commit ebc8bab

Browse files
committed
Use workflow_run trigger with artifact for safe tag passing
1 parent b9e0910 commit ebc8bab

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

.github/workflows/publish-on-release.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,40 @@
11
name: Publish to pub.dev
22

33
on:
4-
release:
5-
types: [published]
4+
workflow_run:
5+
workflows: ["Create Release"]
6+
types: [completed]
67

78
jobs:
89
publish:
910
runs-on: ubuntu-latest
11+
# Only run if the triggering workflow succeeded
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1013
permissions:
1114
id-token: write # Required for authentication using OIDC
1215
steps:
16+
- name: Download tag artifact
17+
uses: actions/download-artifact@v4
18+
with:
19+
name: release-tag
20+
github-token: ${{ secrets.GITHUB_TOKEN }}
21+
run-id: ${{ github.event.workflow_run.id }}
22+
23+
- name: Get tag from artifact
24+
id: get-tag
25+
run: |
26+
TAG=$(cat tag.txt)
27+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
28+
echo "🏷️ Tag from artifact: $TAG"
29+
1330
- uses: actions/checkout@v4
31+
with:
32+
ref: ${{ steps.get-tag.outputs.tag }}
1433

1534
- name: Determine package from tag
1635
id: package-info
1736
run: |
18-
TAG="${{ github.ref_name }}"
37+
TAG="${{ steps.get-tag.outputs.tag }}"
1938
echo "🏷️ Processing tag: $TAG"
2039
2140
if [[ "$TAG" == mcp_dart_cli-v* ]]; then

.github/workflows/publish.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,13 @@ jobs:
6868
name: ${{ inputs.package }} ${{ steps.get-version.outputs.version }}
6969
generate_release_notes: true
7070
draft: false
71+
72+
- name: Save tag for publish workflow
73+
run: echo "${{ steps.create-tag.outputs.tag }}" > tag.txt
74+
75+
- name: Upload tag artifact
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: release-tag
79+
path: tag.txt
80+
retention-days: 1

0 commit comments

Comments
 (0)