From ee1ed71dc1c07e21ec91a7eb773e127fcb1bd262 Mon Sep 17 00:00:00 2001 From: Bart de Lange Date: Fri, 27 Nov 2026 16:45:03 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20chore(config):=20Start=20store?= =?UTF-8?q?=20workflow=20when=20the=20GitHub=20release=20is=20published?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release-throwl.yaml | 123 ++++++++++---------- CONTRIBUTING.md | 20 ++-- apps/throwl/fastlane/store-release-notes.md | 4 - 3 files changed, 71 insertions(+), 76 deletions(-) diff --git a/.github/workflows/release-throwl.yaml b/.github/workflows/release-throwl.yaml index a35cbe6f..e6cdeb53 100644 --- a/.github/workflows/release-throwl.yaml +++ b/.github/workflows/release-throwl.yaml @@ -3,8 +3,6 @@ name: Distribute app to Android & iOS stores 🚀 on: push: branches: [master] - tags: - - '*' paths: - 'apps/throwl/**' - 'libs/**' @@ -17,6 +15,8 @@ on: - 'pnpm-*.yaml' - 'nx.json' - 'tsconfig*.json' + release: + types: [published] workflow_dispatch: inputs: deploy: @@ -39,10 +39,54 @@ concurrency: jobs: validate: + if: github.event_name != 'release' || (!github.event.release.prerelease && !github.event.repository.fork) runs-on: ubuntu-latest + outputs: + notes: ${{ steps.release.outputs.notes }} + version: ${{ steps.release.outputs.version }} + ios_build: ${{ steps.release.outputs.ios_build }} + android_build: ${{ steps.release.outputs.android_build }} steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: ${{ github.event_name == 'release' && '0' || '1' }} + + - name: Validate published release notes and build versions + id: release + if: github.event_name == 'release' + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + run: | + [[ "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo 'Enter a version tag such as v5.1.2.'; exit 1; } + git merge-base --is-ancestor "$GITHUB_SHA" origin/master + notes=$(jq -ce '[ + .release.body | match("\\s*```json\\r?\\n([\\s\\S]*?)\\r?\\n```"; "g") | .captures[0].string + ] | if length == 1 then .[0] | fromjson else error("Keep one store-notes JSON block in the GitHub release") end + | if .["en-US"] and all(to_entries[]; + (.key | test("^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$")) and + (.value.whatsNew | type == "string" and test("\\S") and length <= 500) and + (.value | if has("iosPromotionalText") then + .iosPromotionalText | type == "string" and length <= 170 + else true end)) + then . else error("Fill in the store notes and check the locale and text lengths") end' \ + "$GITHUB_EVENT_PATH") + + version=$(jq -er .version apps/throwl/package.json) + gradle=apps/throwl/android/app/build.gradle + xcode=apps/throwl/ios/Throwl.xcodeproj/project.pbxproj + android_build=$(awk '$1 == "versionCode" { print $2 }' "$gradle") + ios_build=$(awk '$1 == "CURRENT_PROJECT_VERSION" { gsub(/;/, "", $3); print $3 }' "$xcode" | sort -u) + android_version=$(awk '$1 == "versionName" { gsub(/"/, "", $2); print $2 }' "$gradle") + ios_version=$(awk '$1 == "MARKETING_VERSION" { gsub(/;/, "", $3); print $3 }' "$xcode" | sort -u) + [[ "$RELEASE_TAG" == "v$version" && "$android_version" == "$version" && "$ios_version" == "$version" ]] + [[ "$android_build" =~ ^[0-9]+$ && "$ios_build" =~ ^[0-9]+$ ]] + { + printf 'notes=%s\n' "$notes" + echo "version=$version" + echo "ios_build=$ios_build" + echo "android_build=$android_build" + } >> "$GITHUB_OUTPUT" - name: Setup directory and install required packages uses: ./.github/actions/reusable-setup/ @@ -79,7 +123,7 @@ jobs: os: ubuntu-24.04 working_directory: apps/throwl/android store: Google Play Store - publish: ${{ (github.event_name == 'push' && github.ref_type == 'tag') || (github.event_name == 'workflow_dispatch' && inputs.publish) }} + publish: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.publish) }} secrets: RELEASE_ARTIFACT_KEY: ${{ secrets.RELEASE_ARTIFACT_KEY }} ANDROID_KEYSTORE_FILE: ${{ secrets.ANDROID_KEYSTORE_FILE }} @@ -100,7 +144,7 @@ jobs: os: xcode-27 working_directory: apps/throwl/ios store: TestFlight - publish: ${{ (github.event_name == 'push' && github.ref_type == 'tag') || (github.event_name == 'workflow_dispatch' && inputs.publish) }} + publish: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.publish) }} secrets: RELEASE_ARTIFACT_KEY: ${{ secrets.RELEASE_ARTIFACT_KEY }} IOS_APP_STORE_CONNECT_TEAM_ID: ${{ secrets.APP_STORE_CONNECT_TEAM_ID }} @@ -117,8 +161,8 @@ jobs: prepare: name: Submit both tested builds for store review - needs: [deploy_android, deploy_ios] - if: github.event_name == 'push' && github.ref_type == 'tag' && startsWith(github.ref_name, 'v') && !github.event.repository.fork + needs: [validate, deploy_android, deploy_ios] + if: github.event_name == 'release' concurrency: group: throwl-production-store-preparation cancel-in-progress: false @@ -126,11 +170,9 @@ jobs: environment: store-review permissions: actions: read - contents: write + contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - name: Require recorded store-review approval env: @@ -142,44 +184,10 @@ jobs: exit 1 } - - name: Read the tested release and validate its store notes - id: release + - name: Save validated notes for Fastlane env: - GH_TOKEN: ${{ github.token }} - RELEASE_TAG: ${{ github.ref_name }} - run: | - [[ "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo 'Enter a version tag such as v5.1.2.'; exit 1; } - git merge-base --is-ancestor "$GITHUB_SHA" origin/master - gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/releases" \ - | jq -e '[.[][] | select(.tag_name == env.RELEASE_TAG and .draft)] | if length == 1 then .[0] else error("Expected one GitHub draft for this tag") end' \ - > "$RUNNER_TEMP/draft.json" - jq -er '[ - .body | match("\\s*```json\\r?\\n([\\s\\S]*?)\\r?\\n```"; "g") | .captures[0].string - ] | if length == 1 then .[0] | fromjson else error("Keep one store-notes JSON block in the draft") end - | if .["en-US"] and all(to_entries[]; - (.key | test("^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$")) and - (.value.whatsNew | type == "string" and test("\\S") and length <= 500) and - (.value | if has("iosPromotionalText") then - .iosPromotionalText | type == "string" and length <= 170 - else true end)) - then . else error("Fill in the store notes and check the locale and text lengths") end' \ - "$RUNNER_TEMP/draft.json" > "$RUNNER_TEMP/store-notes.json" - - version=$(jq -er .version apps/throwl/package.json) - gradle=apps/throwl/android/app/build.gradle - xcode=apps/throwl/ios/Throwl.xcodeproj/project.pbxproj - android_build=$(awk '$1 == "versionCode" { print $2 }' "$gradle") - ios_build=$(awk '$1 == "CURRENT_PROJECT_VERSION" { gsub(/;/, "", $3); print $3 }' "$xcode" | sort -u) - android_version=$(awk '$1 == "versionName" { gsub(/"/, "", $2); print $2 }' "$gradle") - ios_version=$(awk '$1 == "MARKETING_VERSION" { gsub(/;/, "", $3); print $3 }' "$xcode" | sort -u) - [[ "$RELEASE_TAG" == "v$version" && "$android_version" == "$version" && "$ios_version" == "$version" ]] - [[ "$android_build" =~ ^[0-9]+$ && "$ios_build" =~ ^[0-9]+$ ]] - { - echo "id=$(jq -er .id "$RUNNER_TEMP/draft.json")" - echo "version=$version" - echo "ios_build=$ios_build" - echo "android_build=$android_build" - } >> "$GITHUB_OUTPUT" + STORE_NOTES: ${{ needs.validate.outputs.notes }} + run: printf '%s\n' "$STORE_NOTES" > "$RUNNER_TEMP/store-notes.json" - name: Set up Ruby uses: ruby/setup-ruby@145243922b4465b78e04dd66294782c7de45901f # v1.345.0 @@ -193,8 +201,8 @@ jobs: working-directory: apps/throwl run: bundle exec fastlane ios submit_tested_build "version:$VERSION" "build:$BUILD_NUMBER" "notes:$RUNNER_TEMP/store-notes.json" env: - VERSION: ${{ steps.release.outputs.version }} - BUILD_NUMBER: ${{ steps.release.outputs.ios_build }} + VERSION: ${{ needs.validate.outputs.version }} + BUILD_NUMBER: ${{ needs.validate.outputs.ios_build }} DEVELOPER_APP_IDENTIFIER: ${{ secrets.DEVELOPER_APP_IDENTIFIER }} APPLE_KEY_ID: ${{ secrets.APPLE_KEY_ID }} APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }} @@ -206,24 +214,13 @@ jobs: working-directory: apps/throwl run: bundle exec fastlane android submit_tested_build "build:$BUILD_NUMBER" "notes:$RUNNER_TEMP/store-notes.json" env: - BUILD_NUMBER: ${{ steps.release.outputs.android_build }} + BUILD_NUMBER: ${{ needs.validate.outputs.android_build }} PLAY_CONFIG_JSON: ${{ secrets.PLAY_CONFIG_JSON }} - - name: Record both store results in the GitHub draft + - name: Report store submission results env: - GH_TOKEN: ${{ github.token }} - RELEASE_ID: ${{ steps.release.outputs.id }} IOS_OUTCOME: ${{ steps.ios.outcome }} ANDROID_OUTCOME: ${{ steps.android.outcome }} run: | - printf '### Store preparation\n\n- iOS: %s\n- Android: %s\n' "$IOS_OUTCOME" "$ANDROID_OUTCOME" >> "$GITHUB_STEP_SUMMARY" - [[ "$IOS_OUTCOME" == success && "$ANDROID_OUTCOME" == success ]] || exit 1 - gh api "repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID" > "$RUNNER_TEMP/current-draft.json" - jq -e --slurpfile original "$RUNNER_TEMP/draft.json" ' - if .draft and .body == $original[0].body then - {body: ("\n**Both builds were submitted to their stores for review.** Each store publishes after approval.\n\n" + - (.body | sub("^\\s*\\*\\*[^\\r\\n]*\\s*"; "")))} - else error("The GitHub draft changed during store preparation; update its status manually") end - ' "$RUNNER_TEMP/current-draft.json" > "$RUNNER_TEMP/ready.json" - gh api --method PATCH "repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID" \ - --input "$RUNNER_TEMP/ready.json" --jq .html_url + printf '### Store submission\n\n- iOS: %s\n- Android: %s\n' "$IOS_OUTCOME" "$ANDROID_OUTCOME" >> "$GITHUB_STEP_SUMMARY" + [[ "$IOS_OUTCOME" == success && "$ANDROID_OUTCOME" == success ]] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 21d7e303..cef891db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,8 +82,8 @@ Actual release tasks fail clearly unless release signing is configured. iOS store signing and all Fastlane deployment credentials are maintainer-only. Branch from `master`, follow the existing gitmoji/commitlint style, and include -screenshots for visual changes. Releases currently trigger on every tag (`*`), -so the owner should protect that tag namespace and `master` with GitHub rulesets. +screenshots for visual changes. Publishing a GitHub release starts distribution +for its version tag. Protect version tags and `master` with GitHub rulesets. App Check is optional post-publication abuse hardening. Firestore Security Rules, not App Check, remain the authorization boundary. @@ -107,7 +107,7 @@ Keep the key stable while any upload retries are pending. Pushes to `master` that change the app, dependencies, or release tooling validate and build both platforms. These runs use release signing and warm native caches without retaining bundles or uploading to the stores. A newer qualifying push -cancels an older post-merge run. Tag releases run independently and can restore +cancels an older post-merge run. Published releases run independently and can restore eligible caches from `master`. To check encrypted bundle creation on GitHub without uploading to the stores, @@ -123,13 +123,15 @@ draft directly: GITHUB_TOKEN="$(gh auth token)" pnpm nx run @throwl/throwl:release ``` -On GitHub, edit the draft's changelog and store notes before approving. +On GitHub, edit the draft's changelog and store notes, then publish it. Enter `whatsNew` (up to 500 characters per locale) and optional `iosPromotionalText` (up to 170 characters). Omit the promotional text field to preserve existing text or use an empty string to clear it. -The same tag workflow validates, builds, and uploads both candidate builds, -then waits at **Review deployments**. Test the exact TestFlight and Play +Publishing starts one workflow. It validates the notes as published, builds +the tagged commit, uploads both candidate builds, and waits at **Review +deployments**. Edits to the GitHub release after publishing do not change the +notes in that run. Test the exact TestFlight and Play Internal builds before approving `store-review` in that run. Before the first release, configure the `store-review` GitHub environment with @@ -146,6 +148,6 @@ approving, check that Play has no active production review or rollout. Fastlane's promotion uses Google's default handling for an existing review. Each store can approve and publish on its own schedule. -After both lanes succeed, the workflow records their outcomes on the GitHub -draft. Publish that draft separately. If one lane fails, check both store -consoles before retrying because the other lane may have already succeeded. +The Actions summary records each submission outcome. If one lane fails, check +both store consoles before retrying because the other lane may have already +succeeded. diff --git a/apps/throwl/fastlane/store-release-notes.md b/apps/throwl/fastlane/store-release-notes.md index 6dc555ba..5707beac 100644 --- a/apps/throwl/fastlane/store-release-notes.md +++ b/apps/throwl/fastlane/store-release-notes.md @@ -1,7 +1,3 @@ - - -**Store review is pending.** Add the release notes, test both builds, and approve the workflow to submit them. - ## Changes Add the changelog here.