Skip to content

Commit 909d1a5

Browse files
grdsdevclaude
andcommitted
ci(release): fix melos release automation with scoped publishing
Fix critical issues in release automation: release-publish.yml now accepts package-name and package-version as inputs and publishes only the scoped package instead of all unpublished packages. Added CHANGELOG extraction to release body, concurrency control per-package, and fetch-depth: 0 for melos bootstrap. release-tag.yml passes inputs to publish workflow and adds 30s delay between triggers for pub.dev propagation. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 9923153 commit 909d1a5

File tree

2 files changed

+47
-16
lines changed

2 files changed

+47
-16
lines changed

.github/workflows/release-publish.yml

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@ name: Publish Packages
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
package-name:
7+
description: 'Name of the package to publish'
8+
required: true
9+
type: string
10+
package-version:
11+
description: 'Version to publish (without v prefix, e.g. 2.18.0)'
12+
required: true
13+
type: string
14+
15+
concurrency:
16+
group: release-publish-${{ inputs.package-name }}
17+
cancel-in-progress: false
518

619
permissions:
720
contents: write
821
id-token: write
922

1023
jobs:
11-
publish-packages:
24+
publish-package:
1225
runs-on: ubuntu-latest
1326
timeout-minutes: 20
1427
steps:
@@ -18,34 +31,48 @@ jobs:
1831
with:
1932
app-id: ${{ secrets.APP_ID }}
2033
private-key: ${{ secrets.PRIVATE_KEY }}
34+
2135
- name: Checkout
2236
uses: actions/checkout@v6
37+
with:
38+
fetch-depth: 0
39+
ref: ${{ inputs.package-name }}-v${{ inputs.package-version }}
2340

2441
- name: Setup Flutter
2542
uses: subosito/flutter-action@v2
2643
with:
2744
cache: true
2845

29-
- name: Publish to pub.dev
46+
- name: Bootstrap with Melos
3047
uses: bluefireteam/melos-action@v3
31-
with:
32-
publish: true
48+
49+
- name: Publish dry run
50+
run: melos publish --scope ${{ inputs.package-name }} --dry-run
51+
52+
- name: Publish to pub.dev
53+
run: melos publish --scope ${{ inputs.package-name }}
54+
55+
- name: Extract CHANGELOG section
56+
id: changelog
57+
run: |
58+
VERSION="${{ inputs.package-version }}"
59+
PACKAGE="${{ inputs.package-name }}"
60+
CHANGELOG_CONTENT=$(awk "/^## ${VERSION}/{flag=1; next} /^## /{flag=0} flag" "packages/${PACKAGE}/CHANGELOG.md")
61+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
62+
echo "${CHANGELOG_CONTENT}" >> $GITHUB_OUTPUT
63+
echo "EOF" >> $GITHUB_OUTPUT
3364
3465
- name: Create GitHub Release
3566
uses: softprops/action-gh-release@v2
3667
with:
37-
tag_name: ${{ github.ref_name }}
38-
name: Release ${{ github.ref_name }}
68+
tag_name: ${{ inputs.package-name }}-v${{ inputs.package-version }}
69+
name: ${{ inputs.package-name }} v${{ inputs.package-version }}
3970
body: |
40-
## Package Release
41-
42-
Released package: ${{ github.ref_name }}
43-
44-
See the package CHANGELOG for detailed changes.
71+
${{ steps.changelog.outputs.changelog }}
4572
4673
---
47-
*This release was created automatically by the Publish Packages workflow.*
74+
Published to pub.dev: https://pub.dev/packages/${{ inputs.package-name }}/versions/${{ inputs.package-version }}
4875
draft: false
49-
prerelease: false
76+
prerelease: ${{ contains(inputs.package-version, '-') }}
5077
env:
5178
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

.github/workflows/release-tag.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ jobs:
3939
uses: bluefireteam/melos-action@v3
4040
with:
4141
tag: true
42-
- run: |
42+
- name: Trigger publish workflows
43+
run: |
4344
melos exec -c 1 --no-published --no-private --order-dependents -- \
44-
gh workflow run release-publish.yml \
45-
--ref \$MELOS_PACKAGE_NAME-v\$MELOS_PACKAGE_VERSION
45+
bash -c "gh workflow run release-publish.yml \
46+
--ref \$MELOS_PACKAGE_NAME-v\$MELOS_PACKAGE_VERSION \
47+
--field package-name=\$MELOS_PACKAGE_NAME \
48+
--field package-version=\$MELOS_PACKAGE_VERSION && \
49+
sleep 30"
4650
env:
4751
GH_TOKEN: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)