diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index f8adbfe18..b64fdcd9e 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -2,13 +2,26 @@ name: Publish Packages on: workflow_dispatch: + inputs: + package-name: + description: 'Name of the package to publish' + required: true + type: string + package-version: + description: 'Version to publish (without v prefix, e.g. 2.18.0)' + required: true + type: string + +concurrency: + group: release-publish-${{ inputs.package-name }} + cancel-in-progress: false permissions: contents: write id-token: write jobs: - publish-packages: + publish-package: runs-on: ubuntu-latest timeout-minutes: 20 steps: @@ -18,34 +31,49 @@ jobs: with: app-id: ${{ secrets.APP_ID }} private-key: ${{ secrets.PRIVATE_KEY }} + - name: Checkout uses: actions/checkout@v6 + with: + fetch-depth: 0 + ref: ${{ inputs.package-name }}-v${{ inputs.package-version }} - name: Setup Flutter uses: subosito/flutter-action@v2 with: cache: true - - name: Publish to pub.dev + - name: Bootstrap with Melos uses: bluefireteam/melos-action@v3 - with: - publish: true + + - name: Publish dry run + run: melos publish --scope ${{ inputs.package-name }} --dry-run + + - name: Publish to pub.dev + run: melos publish --scope ${{ inputs.package-name }} + + - name: Extract CHANGELOG section + id: changelog + run: | + VERSION="${{ inputs.package-version }}" + PACKAGE="${{ inputs.package-name }}" + HEADER="## ${VERSION}" + CHANGELOG_CONTENT=$(awk -v header="$HEADER" 'index($0,header)==1{flag=1;next} /^## /{flag=0} flag' "packages/${PACKAGE}/CHANGELOG.md") + echo "changelog<> $GITHUB_OUTPUT + echo "${CHANGELOG_CONTENT}" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: - tag_name: ${{ github.ref_name }} - name: Release ${{ github.ref_name }} + tag_name: ${{ inputs.package-name }}-v${{ inputs.package-version }} + name: ${{ inputs.package-name }} v${{ inputs.package-version }} body: | - ## Package Release - - Released package: ${{ github.ref_name }} - - See the package CHANGELOG for detailed changes. + ${{ steps.changelog.outputs.changelog }} --- - *This release was created automatically by the Publish Packages workflow.* + Published to pub.dev: https://pub.dev/packages/${{ inputs.package-name }}/versions/${{ inputs.package-version }} draft: false - prerelease: false + prerelease: ${{ contains(inputs.package-version, '-') }} env: GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml index dbd642dce..eeaee0719 100644 --- a/.github/workflows/release-tag.yml +++ b/.github/workflows/release-tag.yml @@ -39,9 +39,13 @@ jobs: uses: bluefireteam/melos-action@v3 with: tag: true - - run: | + - name: Trigger publish workflows + run: | melos exec -c 1 --no-published --no-private --order-dependents -- \ - gh workflow run release-publish.yml \ - --ref \$MELOS_PACKAGE_NAME-v\$MELOS_PACKAGE_VERSION + bash -c "gh workflow run release-publish.yml \ + --ref \$MELOS_PACKAGE_NAME-v\$MELOS_PACKAGE_VERSION \ + --field package-name=\$MELOS_PACKAGE_NAME \ + --field package-version=\$MELOS_PACKAGE_VERSION && \ + sleep 30" env: GH_TOKEN: ${{ steps.app-token.outputs.token }} \ No newline at end of file