From 297739081729f6c4a6a5535ed4e549c7132e6934 Mon Sep 17 00:00:00 2001 From: Lukas Klingsbo Date: Thu, 2 Jul 2026 16:38:59 +0200 Subject: [PATCH] ci: add automated release workflows for pub.dev publishing Adds a workflow_dispatch-driven release pipeline modeled on supabase-flutter: a Prepare Release workflow bumps versions/changelogs and opens a release PR, merging it tags changed packages, and each tag triggers a publish workflow that releases to pub.dev via trusted publishing and creates the GitHub release. --- .github/workflows/release-prepare.yml | 45 +++++++++++++++++++++++++++ .github/workflows/release-publish.yml | 35 +++++++++++++++++++++ .github/workflows/release-tag.yml | 45 +++++++++++++++++++++++++++ CONTRIBUTING.md | 26 ++++++++-------- 4 files changed, 138 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/release-prepare.yml create mode 100644 .github/workflows/release-publish.yml create mode 100644 .github/workflows/release-tag.yml diff --git a/.github/workflows/release-prepare.yml b/.github/workflows/release-prepare.yml new file mode 100644 index 00000000..71928918 --- /dev/null +++ b/.github/workflows/release-prepare.yml @@ -0,0 +1,45 @@ +name: Prepare Release + +on: + workflow_dispatch: + inputs: + prerelease: + description: 'Version as prerelease' + required: false + default: false + type: boolean + graduate: + description: 'Graduate prereleases to stable' + required: false + default: false + type: boolean + +permissions: + contents: write + pull-requests: write + +jobs: + prepare-release: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "3.27.4" + cache: true + + - name: Version packages + uses: bluefireteam/melos-action@v3 + with: + run-versioning: ${{ inputs.prerelease == false }} + run-versioning-prerelease: ${{ inputs.prerelease == true }} + run-versioning-graduate: ${{ inputs.graduate == true }} + create-pr: true + pr-title: 'chore(release): publish packages' + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml new file mode 100644 index 00000000..7a277937 --- /dev/null +++ b/.github/workflows/release-publish.yml @@ -0,0 +1,35 @@ +name: Publish Packages + +on: + workflow_dispatch: + +concurrency: + group: release-publish-${{ github.ref }} + cancel-in-progress: false + +permissions: + contents: write + id-token: write + +jobs: + publish-package: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "3.27.4" + cache: true + + - name: Publish to pub.dev and create GitHub Release + uses: bluefireteam/melos-action@v3 + with: + publish: true + create-release: true + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml new file mode 100644 index 00000000..0bafb4a9 --- /dev/null +++ b/.github/workflows/release-tag.yml @@ -0,0 +1,45 @@ +name: Create Release Tags + +on: + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +permissions: + contents: write + actions: write + +jobs: + create-tags: + if: ${{ contains(github.event.head_commit.message, 'chore(release):') }} + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "3.27.4" + cache: true + + - name: Tag packages + uses: bluefireteam/melos-action@v3 + with: + tag: true + token: ${{ secrets.GITHUB_TOKEN }} + + - 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 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 84c3dcd8..2697cfc9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -133,19 +133,19 @@ Once your PR is open: ## 7. Release Process (For Maintainers) -This project uses Melos to handle versioning and publishing. Once changes in main are ready to release: - -1. Pull the latest main branch locally. -2. For the changed packages, update the version in the `pubspec.yaml` file. The version should follow the [Semantic Versioning](https://semver.org/) guidelines. -3. Update the `CHANGELOG.md` file with the new version and a list of changes. The changes should be grouped by package and follow the format of the previous entries. -4. Dry run publish: - ```bash - melos publish - ``` -5. If everything looks good, publish: - ```bash - melos publish --no-dry-run - ``` +This project uses Melos together with GitHub Actions to handle versioning and publishing. Once changes in main are ready to release: + +1. Run the [`Prepare Release`](../../actions/workflows/release-prepare.yml) workflow via `workflow_dispatch` (`gh workflow run release-prepare.yml`). This bumps versions and updates `CHANGELOG.md` for all changed packages, based on their conventional commit history, and opens a `chore(release): publish packages` pull request. + - Use the `prerelease` input to cut a prerelease instead of a stable version. + - Use the `graduate` input to graduate existing prereleases to stable. +2. Review the generated pull request (versions, changelog entries) and merge it into main. +3. Merging triggers [`Create Release Tags`](../../actions/workflows/release-tag.yml), which tags each changed package and triggers [`Publish Packages`](../../actions/workflows/release-publish.yml) for it. +4. `Publish Packages` runs `melos publish` for that package (via pub.dev trusted publishing) and creates the matching GitHub release. No local publish steps or stored pub.dev credentials are needed. + +You can still dry-run a version bump locally before triggering the workflow: +```bash + melos version --no-changelog +``` ## 8. Contributing Documentation If you’d like to improve or add documentation: