Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 60 additions & 63 deletions .github/workflows/release-throwl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Distribute app to Android & iOS stores 🚀
on:
push:
branches: [master]
tags:
- '*'
paths:
- 'apps/throwl/**'
- 'libs/**'
Expand All @@ -17,6 +15,8 @@ on:
- 'pnpm-*.yaml'
- 'nx.json'
- 'tsconfig*.json'
release:
types: [published]
workflow_dispatch:
inputs:
deploy:
Expand All @@ -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("<!-- throwl-store-notes -->\\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/
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -117,20 +161,18 @@ 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
runs-on: macos-latest
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:
Expand All @@ -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("<!-- throwl-store-notes -->\\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
Expand All @@ -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 }}
Expand All @@ -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: ("<!-- throwl-store-status: ready -->\n**Both builds were submitted to their stores for review.** Each store publishes after approval.\n\n" +
(.body | sub("^<!-- throwl-store-status: (pending|ready) -->\\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 ]]
20 changes: 11 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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.
4 changes: 0 additions & 4 deletions apps/throwl/fastlane/store-release-notes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<!-- throwl-store-status: pending -->

**Store review is pending.** Add the release notes, test both builds, and approve the workflow to submit them.

## Changes

Add the changelog here.
Expand Down