|
| 1 | +name: Beta Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - beta |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - beta |
| 9 | + |
| 10 | +jobs: |
| 11 | + lint: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Setup |
| 18 | + uses: ./.github/actions/setup |
| 19 | + |
| 20 | + - name: Lint files |
| 21 | + run: yarn lint './**/*.{ts,tsx,js,jsx}' --ignore-pattern node_modules |
| 22 | + |
| 23 | + - name: Typecheck files |
| 24 | + run: yarn typecheck |
| 25 | + |
| 26 | + test: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Setup |
| 33 | + uses: ./.github/actions/setup |
| 34 | + |
| 35 | + - name: Run unit tests |
| 36 | + run: yarn test:cov |
| 37 | + |
| 38 | + - name: Update Coverage Badge |
| 39 | + # GitHub actions: default branch variable |
| 40 | + # https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable |
| 41 | + if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) |
| 42 | + uses: we-cli/coverage-badge-action@main |
| 43 | + |
| 44 | + build-library: |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - name: Checkout |
| 48 | + uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - name: Setup |
| 51 | + uses: ./.github/actions/setup |
| 52 | + |
| 53 | + - name: Build package |
| 54 | + run: yarn prepack |
| 55 | + |
| 56 | + build-android: |
| 57 | + runs-on: ubuntu-latest |
| 58 | + env: |
| 59 | + TURBO_CACHE_DIR: .turbo/android |
| 60 | + ANDROID_HOME: /usr/local/lib/android/sdk |
| 61 | + JAVA_HOME: /usr/lib/jvm/zulu-11-amd64 |
| 62 | + steps: |
| 63 | + - name: Checkout |
| 64 | + uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: Setup |
| 67 | + uses: ./.github/actions/setup |
| 68 | + |
| 69 | + - name: Cache turborepo for Android |
| 70 | + uses: actions/cache@v4 |
| 71 | + with: |
| 72 | + path: ${{ env.TURBO_CACHE_DIR }} |
| 73 | + key: ${{ runner.os }}-turborepo-android-${{ hashFiles('**/yarn.lock') }} |
| 74 | + restore-keys: | |
| 75 | + ${{ runner.os }}-turborepo-android- |
| 76 | +
|
| 77 | + - name: Check turborepo cache for Android |
| 78 | + run: | |
| 79 | + TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status") |
| 80 | +
|
| 81 | + if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then |
| 82 | + echo "turbo_cache_hit=1" >> $GITHUB_ENV |
| 83 | + fi |
| 84 | +
|
| 85 | + - name: Install JDK |
| 86 | + if: env.turbo_cache_hit != 1 |
| 87 | + uses: actions/setup-java@v4 |
| 88 | + with: |
| 89 | + distribution: 'zulu' |
| 90 | + java-version: '11' |
| 91 | + |
| 92 | + - name: Set up Android SDK |
| 93 | + if: env.turbo_cache_hit != 1 |
| 94 | + uses: android-actions/setup-android@v2 |
| 95 | + with: |
| 96 | + api-level: 30 |
| 97 | + build-tools: 30.0.3 |
| 98 | + ndk: "23.1.7779620" |
| 99 | + |
| 100 | + - name: Create local.properties |
| 101 | + if: env.turbo_cache_hit != 1 |
| 102 | + run: | |
| 103 | + echo "sdk.dir=$ANDROID_HOME" > example/android/local.properties |
| 104 | +
|
| 105 | + - name: Finalize Android SDK |
| 106 | + if: env.turbo_cache_hit != 1 |
| 107 | + run: | |
| 108 | + /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null" |
| 109 | +
|
| 110 | + - name: Cache Gradle |
| 111 | + if: env.turbo_cache_hit != 1 |
| 112 | + uses: actions/cache@v4 |
| 113 | + with: |
| 114 | + path: | |
| 115 | + ~/.gradle/wrapper |
| 116 | + ~/.gradle/caches |
| 117 | + key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }} |
| 118 | + restore-keys: | |
| 119 | + ${{ runner.os }}-gradle- |
| 120 | +
|
| 121 | + - name: Build example for Android |
| 122 | + run: | |
| 123 | + yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" |
| 124 | +
|
| 125 | + build-ios: |
| 126 | + runs-on: macos-latest |
| 127 | + env: |
| 128 | + TURBO_CACHE_DIR: .turbo/ios |
| 129 | + steps: |
| 130 | + - name: Checkout |
| 131 | + uses: actions/checkout@v4 |
| 132 | + |
| 133 | + - name: Setup |
| 134 | + uses: ./.github/actions/setup |
| 135 | + |
| 136 | + - name: Cache turborepo for iOS |
| 137 | + uses: actions/cache@v4 |
| 138 | + with: |
| 139 | + path: ${{ env.TURBO_CACHE_DIR }} |
| 140 | + key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('**/yarn.lock') }} |
| 141 | + restore-keys: | |
| 142 | + ${{ runner.os }}-turborepo-ios- |
| 143 | +
|
| 144 | + - name: Check turborepo cache for iOS |
| 145 | + run: | |
| 146 | + TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status") |
| 147 | +
|
| 148 | + if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then |
| 149 | + echo "turbo_cache_hit=1" >> $GITHUB_ENV |
| 150 | + fi |
| 151 | +
|
| 152 | + - name: Cache cocoapods |
| 153 | + if: env.turbo_cache_hit != 1 |
| 154 | + id: cocoapods-cache |
| 155 | + uses: actions/cache@v4 |
| 156 | + with: |
| 157 | + path: | |
| 158 | + **/ios/Pods |
| 159 | + key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }} |
| 160 | + restore-keys: | |
| 161 | + ${{ runner.os }}-cocoapods- |
| 162 | +
|
| 163 | + - name: Install cocoapods |
| 164 | + if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true' |
| 165 | + run: | |
| 166 | + yarn example pods |
| 167 | + env: |
| 168 | + NO_FLIPPER: 1 |
| 169 | + |
| 170 | + - name: Build example for iOS |
| 171 | + run: | |
| 172 | + yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" 2>&1 | grep -i error > ios_errorlog.txt |
| 173 | +
|
| 174 | + - name: Upload iOS error log |
| 175 | + uses: actions/upload-artifact@v4 |
| 176 | + with: |
| 177 | + name: ios-error-log |
| 178 | + path: ios_errorlog.txt |
| 179 | + |
| 180 | + publish-beta: |
| 181 | + needs: [lint, test, build-library, build-android, build-ios] |
| 182 | + runs-on: ubuntu-latest |
| 183 | + permissions: |
| 184 | + contents: write # To publish a GitHub release |
| 185 | + issues: write # To comment on released issues |
| 186 | + pull-requests: write # To comment on released pull requests |
| 187 | + id-token: write # To enable use of OIDC for npm provenance |
| 188 | + steps: |
| 189 | + - name: Checkout |
| 190 | + uses: actions/checkout@v4 |
| 191 | + with: |
| 192 | + fetch-depth: 0 # Ensures all tags are fetched |
| 193 | + |
| 194 | + - name: Setup Node.js |
| 195 | + uses: actions/setup-node@v4 |
| 196 | + with: |
| 197 | + node-version: "lts/*" # Use the latest LTS version of Node.js |
| 198 | + registry-url: 'https://registry.npmjs.org/' # Specify npm registry |
| 199 | + |
| 200 | + - name: Install dependencies |
| 201 | + run: npm ci # Clean install dependencies based on the lock file |
| 202 | + |
| 203 | + - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies |
| 204 | + run: npm audit signatures # Check the signatures to verify integrity |
| 205 | + |
| 206 | + - name: Release Beta |
| 207 | + run: npx semantic-release # Run semantic-release to manage versioning and publishing |
| 208 | + env: |
| 209 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub token for authentication |
| 210 | + |
| 211 | + # Why NODE_AUTH_TOKEN instead of NPM_TOKEN: https://github.com/semantic-release/semantic-release/issues/2313 |
| 212 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # npm token for publishing package |
0 commit comments