From 6be9097823c6679a290951feb311630a0dfff7e6 Mon Sep 17 00:00:00 2001 From: Nico Vidoni Date: Wed, 27 Nov 2024 17:51:10 +0100 Subject: [PATCH 1/3] ci(release): update release process --- .github/workflows/example_app_release_pr.yml | 7 +------ .github/workflows/publish_pub_dev.yml | 4 +--- RELEASE.md | 10 +++++++--- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/example_app_release_pr.yml b/.github/workflows/example_app_release_pr.yml index b15b389..5408c1a 100644 --- a/.github/workflows/example_app_release_pr.yml +++ b/.github/workflows/example_app_release_pr.yml @@ -2,16 +2,11 @@ name: Make example app release PR on: - pull_request_target: - types: - - labeled - branches: - - main workflow_dispatch: jobs: pull-request-creation: - if: contains(github.event.pull_request.labels.*.name, format('autorelease{0} tagged', ':')) || github.event_name == 'workflow_dispatch' + if: github.event_name == 'workflow_dispatch' permissions: pull-requests: write contents: write diff --git a/.github/workflows/publish_pub_dev.yml b/.github/workflows/publish_pub_dev.yml index 0264609..6babbd8 100644 --- a/.github/workflows/publish_pub_dev.yml +++ b/.github/workflows/publish_pub_dev.yml @@ -1,9 +1,7 @@ name: Publish to pub.dev on: - push: - tags: - - "[0-9]+.[0-9]+.[0-9]+" # tag pattern on pub.dev: '{{version}' + workflow_dispatch: # Publish using custom workflow jobs: diff --git a/RELEASE.md b/RELEASE.md index 4f5cdf9..e44fd4f 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -4,12 +4,16 @@ The releases will be done through [Release Please]. This project uses the [Githu All configuration files for [Release Please] are found in the `./ci` directory. +### Pub Dev + +The pub dev release is done by running the `publish_pub_dev` Github action. + ### Example App -Merging a release please PR will open another PR with a commit syncing the example app to the -package version and increasing the build number by one. +The example app release process is initiated by running the `example_app_release_pr` Github action. This will +open a PR with a commit syncing the example app to the package version and increasing the build number by one. -Upon merging this PR, the example app will be released to the enterprise app stores. +Upon merging this PR, the example app will be released to the enterprise app store. [Release Please]: https://github.com/googleapis/release-please [Github Action version]: https://github.com/googleapis/release-please-action \ No newline at end of file From b500295590fb578d962c20715e0b3f096bc285fe Mon Sep 17 00:00:00 2001 From: Nico Vidoni Date: Thu, 19 Dec 2024 15:02:27 +0100 Subject: [PATCH 2/3] ci: pub dev publishing done with Github App --- .github/workflows/example_app_release_pr.yml | 21 ++++++++++++++++++-- .github/workflows/publish_pub_dev.yml | 20 ++++--------------- .github/workflows/release-please.yml | 8 ++++++++ RELEASE.md | 10 +++++++--- ci/release-please-config.json | 3 ++- 5 files changed, 40 insertions(+), 22 deletions(-) diff --git a/.github/workflows/example_app_release_pr.yml b/.github/workflows/example_app_release_pr.yml index 5408c1a..d1f5bd3 100644 --- a/.github/workflows/example_app_release_pr.yml +++ b/.github/workflows/example_app_release_pr.yml @@ -2,19 +2,34 @@ name: Make example app release PR on: + pull_request: + types: + - closed + branches: + - main workflow_dispatch: jobs: pull-request-creation: - if: github.event_name == 'workflow_dispatch' + if: github.event.pull_request.merged && contains( github.event.pull_request.labels.*.name, format('autorelease{0} pending', ':')) || github.event_name == 'workflow_dispatch' permissions: pull-requests: write contents: write runs-on: ubuntu-latest steps: + - name: Generate Token + id: app-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.APPBAKERYGITHUBAPP_APPID }} + private-key: ${{ secrets.APPBAKERYGITHUBAPP_PRIVATEKEY }} + - name: Clone Repository uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + persist-credentials: false - name: Read new build_name from root pubspec.yaml. id: read_build_name @@ -39,12 +54,14 @@ jobs: - name: Create Pull Request uses: peter-evans/create-pull-request@v7 with: + token: ${{ steps.app-token.outputs.token }} + committer: sbb-app-bakery[bot] <914587+sbb-app-bakery[bot]@users.noreply.github.com> commit-message: ${{ format('chore{0} example app release v{1}', ':', steps.read_build_name.outputs.pubspec_build_name) }} branch: "chore/example-release" title: ${{ format('Release example app v{0}', steps.read_build_name.outputs.pubspec_build_name) }} body: | Update pubspec version to ${{ steps.read_build_name.outputs.pubspec_build_name }}+${{ steps.read_build_number.outputs.pubspec_build_number }} - **Merging this PR will trigger the release into the enterprise app stores.** + **Merging this PR will trigger the release into the enterprise app store.** labels: | exampleAppRelease:pending diff --git a/.github/workflows/publish_pub_dev.yml b/.github/workflows/publish_pub_dev.yml index 6babbd8..608ff44 100644 --- a/.github/workflows/publish_pub_dev.yml +++ b/.github/workflows/publish_pub_dev.yml @@ -1,24 +1,12 @@ name: Publish to pub.dev on: - workflow_dispatch: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" -# Publish using custom workflow jobs: publish: permissions: id-token: write # Required for authentication using OIDC - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: subosito/flutter-action@v2 - with: - channel: stable - cache: true - - - run: flutter doctor -v - - run: flutter pub get - - run: dart run build_runner build --delete-conflicting-outputs - - - run: flutter pub publish --force + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index cc72825..100506d 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -15,8 +15,16 @@ jobs: outputs: release-created: ${{ steps.release.outputs.release_created }} steps: + - name: Generate Token + id: app-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.APPBAKERYGITHUBAPP_APPID }} + private-key: ${{ secrets.APPBAKERYGITHUBAPP_PRIVATEKEY }} + - uses: googleapis/release-please-action@v4 id: release with: config-file: ci/release-please-config.json manifest-file: ci/.release-please-manifest.json + token: ${{ steps.app-token.outputs.token }} diff --git a/RELEASE.md b/RELEASE.md index e44fd4f..9080e3b 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -2,13 +2,17 @@ The releases will be done through [Release Please]. This project uses the [Github Action version]. +For triggering subsequent workflows, we use the *sbb-app-bakery* Github App with a private key stored in the +Github Actions secrets. + All configuration files for [Release Please] are found in the `./ci` directory. -### Pub Dev +#### Pub Dev -The pub dev release is done by running the `publish_pub_dev` Github action. +Merging the release please PR will result in the `publish_pub_dev` workflow to be triggered. This workflow +takes care of the release to pub.dev. -### Example App +#### Example App The example app release process is initiated by running the `example_app_release_pr` Github action. This will open a PR with a commit syncing the example app to the package version and increasing the build number by one. diff --git a/ci/release-please-config.json b/ci/release-please-config.json index e622c43..e6ca64d 100644 --- a/ci/release-please-config.json +++ b/ci/release-please-config.json @@ -9,5 +9,6 @@ }, "include-v-in-tag": false, "include-component-in-tag": false, - "pull-request-title-pattern": "Release ${version}" + "pull-request-title-pattern": "Release ${version}", + "pull-request-footer": "This PR was generated with Release Please. See documentation.\n\n**Merging this PR will create a Github Release and a Pub Dev release**" } From 3883cd40cca7661cc12ccbcbe25d9a5248ec1ff5 Mon Sep 17 00:00:00 2001 From: Nico Vidoni Date: Thu, 19 Dec 2024 15:06:31 +0100 Subject: [PATCH 3/3] docs: update release docs --- RELEASE.md | 8 ++++++-- ci/release-please-config.json | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 9080e3b..2409f4a 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -14,10 +14,14 @@ takes care of the release to pub.dev. #### Example App -The example app release process is initiated by running the `example_app_release_pr` Github action. This will -open a PR with a commit syncing the example app to the package version and increasing the build number by one. +Merging the release please PR will trigger the `example_app_release_pr` Github action. This will +* open a PR with a commit + * syncing the example app to the package version + * increasing the build number by one. Upon merging this PR, the example app will be released to the enterprise app store. +This PR can also be opened manually and will fail silently if no changes are commited. + [Release Please]: https://github.com/googleapis/release-please [Github Action version]: https://github.com/googleapis/release-please-action \ No newline at end of file diff --git a/ci/release-please-config.json b/ci/release-please-config.json index e6ca64d..6d03a9d 100644 --- a/ci/release-please-config.json +++ b/ci/release-please-config.json @@ -10,5 +10,5 @@ "include-v-in-tag": false, "include-component-in-tag": false, "pull-request-title-pattern": "Release ${version}", - "pull-request-footer": "This PR was generated with Release Please. See documentation.\n\n**Merging this PR will create a Github Release and a Pub Dev release**" + "pull-request-footer": "This PR was generated with Release Please. See documentation.\n\n**Merging this PR will create a Github Release, a Pub Dev release and open a PR for the Example App relase**" }