Skip to content

Commit 711e5c9

Browse files
grdsdevclaude
andauthored
ci(release): fix melos release automation with scoped publishing (#1316)
* 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> * ci(release): use fixed-string awk matching for CHANGELOG extraction Replace regex-based awk pattern with index()-based fixed-string matching to correctly handle version strings containing regex metacharacters (e.g. dots, plus signs in build metadata like 0.3.1+1). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 9923153 commit 711e5c9

2 files changed

Lines changed: 48 additions & 16 deletions

File tree

.github/workflows/release-publish.yml

Lines changed: 41 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,49 @@ 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+
HEADER="## ${VERSION}"
61+
CHANGELOG_CONTENT=$(awk -v header="$HEADER" 'index($0,header)==1{flag=1;next} /^## /{flag=0} flag' "packages/${PACKAGE}/CHANGELOG.md")
62+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
63+
echo "${CHANGELOG_CONTENT}" >> $GITHUB_OUTPUT
64+
echo "EOF" >> $GITHUB_OUTPUT
3365
3466
- name: Create GitHub Release
3567
uses: softprops/action-gh-release@v2
3668
with:
37-
tag_name: ${{ github.ref_name }}
38-
name: Release ${{ github.ref_name }}
69+
tag_name: ${{ inputs.package-name }}-v${{ inputs.package-version }}
70+
name: ${{ inputs.package-name }} v${{ inputs.package-version }}
3971
body: |
40-
## Package Release
41-
42-
Released package: ${{ github.ref_name }}
43-
44-
See the package CHANGELOG for detailed changes.
72+
${{ steps.changelog.outputs.changelog }}
4573
4674
---
47-
*This release was created automatically by the Publish Packages workflow.*
75+
Published to pub.dev: https://pub.dev/packages/${{ inputs.package-name }}/versions/${{ inputs.package-version }}
4876
draft: false
49-
prerelease: false
77+
prerelease: ${{ contains(inputs.package-version, '-') }}
5078
env:
5179
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)