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
1 change: 0 additions & 1 deletion .github/actions/reusable-setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ description: Install the pinned Node, pnpm, Ruby, and optional Bundler dependenc

inputs:
bundle:
type: boolean
required: true

runs:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ jobs:

- name: Firestore Rules
run: pnpm test:firestore-rules

- name: Verify release artifact encryption
run: node --test scripts/release-artifact.test.mjs
25 changes: 25 additions & 0 deletions .github/workflows/release-throwl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@ name: Distribute app to Android & iOS stores 🚀

on:
push:
branches: [master]
tags:
- '*'
paths:
- 'apps/throwl/**'
- 'libs/**'
- 'scripts/**'
- '.github/actions/**'
- '.github/workflows/release-throwl.yaml'
- '.github/workflows/reusable-deploy.yaml'
- '.nvmrc'
- 'package.json'
- 'pnpm-*.yaml'
- 'nx.json'
- 'tsconfig*.json'
workflow_dispatch:
inputs:
deploy:
Expand All @@ -12,10 +25,18 @@ on:
type: choice
required: false
options: [ios, android, both]
publish:
description: Upload the signed builds to the stores
type: boolean
default: true

permissions:
contents: read

concurrency:
group: ${{ github.event_name == 'push' && github.ref_type == 'branch' && 'master-native-build' || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'push' && github.ref_type == 'branch' }}

jobs:
validate:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -58,7 +79,9 @@ 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) }}
secrets:
RELEASE_ARTIFACT_KEY: ${{ secrets.RELEASE_ARTIFACT_KEY }}
ANDROID_KEYSTORE_FILE: ${{ secrets.ANDROID_KEYSTORE_FILE }}
ANDROID_KEYSTORE_KEY_ALIAS: ${{ secrets.ANDROID_KEYSTORE_ALIAS }}
ANDROID_KEYSTORE_KEY_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
Expand All @@ -77,7 +100,9 @@ jobs:
os: macos-latest
working_directory: apps/throwl/ios
store: TestFlight
publish: ${{ (github.event_name == 'push' && github.ref_type == 'tag') || (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 }}
IOS_DEVELOPER_APP_ID: ${{ secrets.DEVELOPER_APP_ID }}
IOS_DEVELOPER_APP_IDENTIFIER: ${{ secrets.DEVELOPER_APP_IDENTIFIER }}
Expand Down
161 changes: 139 additions & 22 deletions .github/workflows/reusable-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ on:
required: true
description: One of `apps/throwl/ios` or `apps/throwl/android`

publish:
type: boolean
required: true

secrets:
RELEASE_ARTIFACT_KEY:
required: true

# iOS
IOS_APP_STORE_CONNECT_TEAM_ID:
IOS_DEVELOPER_APP_ID:
Expand All @@ -43,14 +50,13 @@ permissions:
contents: read

jobs:
build_and_deploy:
name: Build and Deploy to ${{ inputs.store }}
build:
name: Build for ${{ inputs.store }}
outputs:
artifact_id: ${{ steps.bundle.outputs.artifact-id }}
runs-on: ${{ inputs.os }}
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ inputs.os }}-${{ inputs.working_directory }}
cancel-in-progress: true

steps:
- name: Checkout repository
Expand All @@ -61,6 +67,12 @@ jobs:
with:
bundle: true

- name: Check release artifact key
if: inputs.publish || github.event_name == 'workflow_dispatch'
run: node scripts/release-artifact.mjs check
env:
RELEASE_ARTIFACT_KEY: ${{ secrets.RELEASE_ARTIFACT_KEY }}

#region Android
- name: Use JAVA 22
if: ${{ endsWith(inputs.working_directory, '/android') }}
Expand All @@ -69,6 +81,13 @@ jobs:
distribution: 'zulu'
java-version: '22.0.2'

- name: Cache Gradle dependencies
if: ${{ endsWith(inputs.working_directory, '/android') }}
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6
with:
cache-provider: basic
cache-read-only: false

- name: Configure Keystore
if: ${{ endsWith(inputs.working_directory, '/android') }}
working-directory: ${{ inputs.working_directory }}
Expand Down Expand Up @@ -97,20 +116,6 @@ jobs:
KEYSTORE_KEY_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_KEY_PASSWORD }}
KEYSTORE_STORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_STORE_PASSWORD }}

- name: Create Google Play Config file
if: ${{ endsWith(inputs.working_directory, '/android') }}
working-directory: ${{ inputs.working_directory }}
run: |
python3 - <<'PY'
import base64, os, pathlib

wd = pathlib.Path(".")
play_b64 = os.environ["PLAY_CONFIG_JSON"]
(wd / "playstore_config.json").write_bytes(base64.b64decode(play_b64))
PY
env:
PLAY_CONFIG_JSON: ${{ secrets.ANDROID_PLAY_CONFIG_JSON }}

- name: Create google-services.json (Firebase)
if: ${{ endsWith(inputs.working_directory, '/android') }}
working-directory: ${{ inputs.working_directory }}
Expand Down Expand Up @@ -153,15 +158,22 @@ jobs:
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0
with:
xcode-version: latest-stable
- name: Cache CocoaPods downloads
if: ${{ endsWith(inputs.working_directory, '/ios') }}
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/Library/Caches/CocoaPods
key: cocoapods-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('apps/throwl/Gemfile.lock', 'apps/throwl/ios/Podfile.lock') }}
restore-keys: cocoapods-${{ runner.os }}-${{ runner.arch }}-
#endregion

- name: Distribute app to ${{ inputs.store }} 🚀
- name: Build signed store bundle
working-directory: apps/throwl
run: |
if [[ "${{ inputs.working_directory }}" == *"/ios" ]]; then
bundle exec fastlane ios beta
bundle exec fastlane ios beta upload:false
else
bundle exec fastlane android beta
bundle exec fastlane android beta upload:false
fi
env:
# iOS (only set when iOS)
Expand All @@ -175,3 +187,108 @@ jobs:
APPLE_KEY_ID: ${{ (endsWith(inputs.working_directory, '/ios') && secrets.IOS_APPLE_KEY_ID) || '' }}
APPLE_ISSUER_ID: ${{ (endsWith(inputs.working_directory, '/ios') && secrets.IOS_APPLE_ISSUER_ID) || '' }}
APPLE_KEY_CONTENT: ${{ (endsWith(inputs.working_directory, '/ios') && secrets.IOS_APPLE_KEY_CONTENT) || '' }}

- name: Encrypt signed bundle
if: inputs.publish || github.event_name == 'workflow_dispatch'
run: |
if [[ "$APP_PLATFORM" == ios ]]; then
bundle=apps/throwl/fastlane/output/Throwl.ipa
else
bundle=apps/throwl/android/app/build/outputs/bundle/release/app-release.aab
fi
node scripts/release-artifact.mjs encrypt "$bundle" "$RUNNER_TEMP/release-bundle.enc"
env:
APP_PLATFORM: ${{ endsWith(inputs.working_directory, '/ios') && 'ios' || 'android' }}
RELEASE_ARTIFACT_KEY: ${{ secrets.RELEASE_ARTIFACT_KEY }}
RELEASE_ARTIFACT_CONTEXT: ${{ github.run_id }}:${{ github.sha }}:${{ inputs.working_directory }}

- name: Retain encrypted bundle for upload retries
if: inputs.publish || github.event_name == 'workflow_dispatch'
id: bundle
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: release-${{ endsWith(inputs.working_directory, '/ios') && 'ios' || 'android' }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/release-bundle.enc
if-no-files-found: error
compression-level: 0
retention-days: 7

upload:
name: Upload to ${{ inputs.store }}
needs: build
if: inputs.publish
runs-on: ${{ inputs.os }}
concurrency:
group: store-upload-${{ inputs.working_directory }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .nvmrc
package-manager-cache: false

- name: Set up Ruby
uses: ruby/setup-ruby@145243922b4465b78e04dd66294782c7de45901f # v1.345.0
with:
working-directory: apps/throwl
bundler-cache: true

- name: Download exact bundle from build job
env:
BUILD_ARTIFACT_ID: ${{ needs.build.outputs.artifact_id }}
run: test -n "$BUILD_ARTIFACT_ID"

- name: Download encrypted bundle
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
artifact-ids: ${{ needs.build.outputs.artifact_id }}
path: ${{ runner.temp }}/release-artifact

- name: Decrypt signed bundle
run: |
node scripts/release-artifact.mjs decrypt "$RUNNER_TEMP/release-artifact/release-bundle.enc" "$RUNNER_TEMP/$BUNDLE_NAME"
env:
BUNDLE_NAME: ${{ endsWith(inputs.working_directory, '/ios') && 'Throwl.ipa' || 'app-release.aab' }}
RELEASE_ARTIFACT_KEY: ${{ secrets.RELEASE_ARTIFACT_KEY }}
RELEASE_ARTIFACT_CONTEXT: ${{ github.run_id }}:${{ github.sha }}:${{ inputs.working_directory }}

- name: Use latest Xcode
if: ${{ endsWith(inputs.working_directory, '/ios') }}
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0
with:
xcode-version: latest-stable

- name: Upload to TestFlight
if: ${{ endsWith(inputs.working_directory, '/ios') }}
working-directory: apps/throwl
run: bundle exec fastlane ios upload "ipa:$RUNNER_TEMP/Throwl.ipa"
env:
DEVELOPER_APP_IDENTIFIER: ${{ secrets.IOS_DEVELOPER_APP_IDENTIFIER }}
APP_STORE_CONNECT_TEAM_ID: ${{ secrets.IOS_APP_STORE_CONNECT_TEAM_ID }}
FASTLANE_APPLE_ID: ${{ secrets.IOS_FASTLANE_APPLE_ID }}
APPLE_KEY_ID: ${{ secrets.IOS_APPLE_KEY_ID }}
APPLE_ISSUER_ID: ${{ secrets.IOS_APPLE_ISSUER_ID }}
APPLE_KEY_CONTENT: ${{ secrets.IOS_APPLE_KEY_CONTENT }}

- name: Create Google Play Config file
if: ${{ endsWith(inputs.working_directory, '/android') }}
working-directory: ${{ inputs.working_directory }}
run: |
python3 - <<'PY'
import base64, os, pathlib

wd = pathlib.Path(".")
play_b64 = os.environ["PLAY_CONFIG_JSON"]
(wd / "playstore_config.json").write_bytes(base64.b64decode(play_b64))
PY
env:
PLAY_CONFIG_JSON: ${{ secrets.ANDROID_PLAY_CONFIG_JSON }}

- name: Upload to Play Internal
if: ${{ endsWith(inputs.working_directory, '/android') }}
working-directory: apps/throwl
run: bundle exec fastlane android upload "aab:$RUNNER_TEMP/app-release.aab"
26 changes: 26 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,29 @@ so the owner should protect that tag namespace and `master` with GitHub rulesets

App Check is optional post-publication abuse hardening. Firestore Security Rules,
not App Check, remain the authorization boundary.

### Release build retries

Before merging the release workflow change, a maintainer must provision the
`RELEASE_ARTIFACT_KEY` GitHub Actions repository secret once. From an
authenticated checkout, generate it without printing it:

```sh
openssl rand -hex 32 | gh secret set RELEASE_ARTIFACT_KEY
```

The build job stores only the encrypted signed bundle, for seven days. If store
upload fails, fix the store issue and choose **Re-run failed jobs** on the same
workflow run. The successful build job's artifact ID selects the original
bundle. If the artifact expired or the key was rotated, rerun the build too.
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
eligible caches from `master`.

To check encrypted bundle creation on GitHub without uploading to the stores,
run the release workflow manually with `publish: false`. That run requires
release signing and the artifact secret, and retains the encrypted bundles.
Loading