Publish Packages #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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-package: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Generate token | |
| id: app-token | |
| uses: actions/create-github-app-token@v2 | |
| 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: Bootstrap with Melos | |
| uses: bluefireteam/melos-action@v3 | |
| - 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 }}" | |
| CHANGELOG_CONTENT=$(awk "/^## ${VERSION}/{flag=1; next} /^## /{flag=0} flag" "packages/${PACKAGE}/CHANGELOG.md") | |
| echo "changelog<<EOF" >> $GITHUB_OUTPUT | |
| echo "${CHANGELOG_CONTENT}" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ inputs.package-name }}-v${{ inputs.package-version }} | |
| name: ${{ inputs.package-name }} v${{ inputs.package-version }} | |
| body: | | |
| ${{ steps.changelog.outputs.changelog }} | |
| --- | |
| Published to pub.dev: https://pub.dev/packages/${{ inputs.package-name }}/versions/${{ inputs.package-version }} | |
| draft: false | |
| prerelease: ${{ contains(inputs.package-version, '-') }} | |
| env: | |
| GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |