Version Packages (#708) #762
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Native UI Previews | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| paths: | |
| - 'packages/native-ui/**' | |
| - 'apps/native-ui-storybook/**' | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'packages/native-ui/**' | |
| - 'apps/native-ui-storybook/**' | |
| env: | |
| CI: true | |
| jobs: | |
| build-for-android: | |
| name: Build for Android | |
| runs-on: macos-14-large | |
| concurrency: | |
| group: preview-android-${{ github.ref }} | |
| cancel-in-progress: true | |
| steps: | |
| - name: 🔍 Check if Android build should run | |
| id: check_build | |
| run: | | |
| BUILD=false | |
| if [ "${{ github.event_name }}" == "push" ]; then | |
| if [[ "${{ github.event.head_commit.message }}" == *"[build-android]"* ]] || [[ "${{ github.event.head_commit.message }}" == *"[build-native]"* ]]; then | |
| BUILD=true | |
| fi | |
| elif [ "${{ github.event_name }}" == "pull_request" ]; then | |
| if [[ "${{ github.event.pull_request.title }}" == *"[build-android]"* ]] || [[ "${{ github.event.pull_request.title }}" == *"[build-native]"* ]] || [[ "${{ github.event.pull_request.body }}" == *"[build-android]"* ]] || [[ "${{ github.event.pull_request.body }}" == *"[build-native]"* ]]; then | |
| BUILD=true | |
| fi | |
| fi | |
| echo "build=$BUILD" >> "$GITHUB_OUTPUT" | |
| - name: 🔧 Setup pnpm | |
| if: steps.check_build.outputs.build == 'true' | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: 📂 Checkout code | |
| if: steps.check_build.outputs.build == 'true' | |
| uses: actions/checkout@v3 | |
| - name: 🔧 Setup Node | |
| uses: actions/setup-node@v4 | |
| if: steps.check_build.outputs.build == 'true' | |
| with: | |
| node-version: '22.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: 'pnpm' | |
| - name: ☕ Setup Java | |
| uses: actions/setup-java@v4 | |
| if: steps.check_build.outputs.build == 'true' | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17.0.10' | |
| java-package: jdk | |
| architecture: x64 | |
| - name: 🔧 Setup EAS | |
| uses: expo/expo-github-action@v8 | |
| if: steps.check_build.outputs.build == 'true' | |
| with: | |
| eas-version: latest | |
| token: ${{ secrets.EXPO_TOKEN }} | |
| - name: 📦 Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| if: steps.check_build.outputs.build == 'true' | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: 🔄 Restore .env | |
| if: steps.check_build.outputs.build == 'true' && github.event.action == 'synchronize' && !github.event_name != 'push' | |
| working-directory: ./apps/native-ui-storybook | |
| run: | | |
| GITHUB_PAT_TOKEN=${{ secrets.DS_ACTION_READ_PAT }} ARTIFACT_NAME=${{ github.event.pull_request.base.sha }}-env-android node ./scripts/getArtifacts.js | |
| - name: 🤖 Build Android APK Bundle | |
| if: steps.check_build.outputs.build == 'true' | |
| working-directory: ./apps/native-ui-storybook | |
| run: pnpm run build:preview:android | |
| - name: 🔐 Create/Read .env | |
| if: steps.check_build.outputs.build == 'true' | |
| run: touch ./apps/native-ui-storybook/.env.android && cat ./apps/native-ui-storybook/.env.android | |
| - name: 🔄 Load .env file | |
| if: steps.check_build.outputs.build == 'true' | |
| uses: xom9ikk/dotenv@v2 | |
| with: | |
| path: ./apps/native-ui-storybook | |
| mode: 'android' | |
| - name: ⬆️ Upload new bundle to Appetize | |
| uses: appetizeio/[email protected] | |
| id: appetizeio_github_action_appetize | |
| if: steps.check_build.outputs.build == 'true' && (github.event.action == 'opened' || github.event.action == 'reopened' || (!env.ANDROID_API_KEY && github.event_name == 'pull_request')) | |
| with: | |
| apiToken: ${{ secrets.APPETIZE_API_TOKEN }} | |
| appFile: /Users/runner/work/design-systems/design-systems/apps/native-ui-storybook/build/native-ui.apk | |
| platform: 'android' | |
| - name: 📝 Add output to .env | |
| if: steps.check_build.outputs.build == 'true' && (github.event.action == 'opened' || github.event.action == 'reopened' || !env.ANDROID_API_KEY) | |
| working-directory: ./apps/native-ui-storybook | |
| run: | | |
| if [ "${{ github.event_name }}" == "push" ]; then | |
| echo "ANDROID_API_KEY=${{ secrets.APPETIZE_PUBLIC_KEY_ANDROID }}" >> .env.android | |
| elif [ ${{steps.appetizeio_github_action_appetize.outputs.publicKey}} ]; then | |
| echo "ANDROID_API_KEY=${{ steps.appetizeio_github_action_appetize.outputs.publicKey }}" >> .env.android | |
| else | |
| echo "No public key found" | |
| fi | |
| - name: 🔄 Reload .env file | |
| uses: xom9ikk/dotenv@v2 | |
| if: steps.check_build.outputs.build == 'true' | |
| with: | |
| path: ./apps/native-ui-storybook | |
| mode: 'android' | |
| - name: 💾 Save .env | |
| uses: actions/upload-artifact@v4 | |
| if: steps.check_build.outputs.build == 'true' && github.event_name == 'pull_request' && env.ANDROID_API_KEY | |
| with: | |
| name: ${{ github.event.pull_request.base.sha }}-env-android | |
| path: ./apps/native-ui-storybook/.env.android | |
| include-hidden-files: true | |
| overwrite: true | |
| - name: ⬆️ Upload updated bundle to Appetize | |
| uses: appetizeio/[email protected] | |
| if: steps.check_build.outputs.build == 'true' && (github.event.action != 'opened' && env.ANDROID_API_KEY) | |
| with: | |
| apiToken: ${{ secrets.APPETIZE_API_TOKEN }} | |
| publicKey: ${{ env.ANDROID_API_KEY }} | |
| appFile: /Users/runner/work/design-systems/design-systems/apps/native-ui-storybook/build/native-ui.apk | |
| platform: 'android' | |
| - name: ✅ Done | |
| run: echo "Job done" | |
| build-for-ios: | |
| name: Build for iOS | |
| runs-on: macos-14-xlarge | |
| concurrency: | |
| group: preview-ios-${{ github.ref }} | |
| cancel-in-progress: true | |
| steps: | |
| - name: 🔍 Check if iOS build should run | |
| id: check_build | |
| run: | | |
| BUILD=false | |
| if [ "${{ github.event_name }}" == "push" ]; then | |
| if [[ "${{ github.event.head_commit.message }}" == *"[build-ios]"* ]] || [[ "${{ github.event.head_commit.message }}" == *"[build-native]"* ]]; then | |
| BUILD=true | |
| fi | |
| elif [ "${{ github.event_name }}" == "pull_request" ]; then | |
| if [[ "${{ github.event.pull_request.title }}" == *"[build-ios]"* ]] || [[ "${{ github.event.pull_request.title }}" == *"[build-native]"* ]] || [[ "${{ github.event.pull_request.body }}" == *"[build-ios]"* ]] || [[ "${{ github.event.pull_request.body }}" == *"[build-native]"* ]]; then | |
| BUILD=true | |
| fi | |
| fi | |
| echo "build=$BUILD" >> "$GITHUB_OUTPUT" | |
| - name: 🔧 Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| if: steps.check_build.outputs.build == 'true' | |
| with: | |
| version: 9 | |
| - name: 📂 Checkout code | |
| uses: actions/checkout@v3 | |
| if: steps.check_build.outputs.build == 'true' | |
| - name: 🔧 Setup Node | |
| uses: actions/setup-node@v4 | |
| if: steps.check_build.outputs.build == 'true' | |
| with: | |
| node-version: '22.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: 'pnpm' | |
| - name: 🍏 Setup Xcode | |
| uses: maxim-lobanov/setup-xcode@v1 | |
| if: steps.check_build.outputs.build == 'true' | |
| with: | |
| xcode-version: '16.1.0' | |
| - name: 🔧 Setup EAS | |
| uses: expo/expo-github-action@v8 | |
| if: steps.check_build.outputs.build == 'true' | |
| with: | |
| eas-version: latest | |
| token: ${{ secrets.EXPO_TOKEN }} | |
| - name: 📦 Install dependencies | |
| if: steps.check_build.outputs.build == 'true' | |
| run: pnpm install --frozen-lockfile | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: 🔄 Restore .env | |
| if: steps.check_build.outputs.build == 'true' && github.event.action != 'opened' && github.event.action != 'reopened' && github.event_name == 'pull_request' | |
| working-directory: ./apps/native-ui-storybook | |
| run: | | |
| GITHUB_PAT_TOKEN=${{ secrets.DS_ACTION_READ_PAT }} ARTIFACT_NAME=${{ github.event.pull_request.base.sha }}-env-ios node ./scripts/getArtifacts.js | |
| - name: 🍎 Build iOS app | |
| if: steps.check_build.outputs.build == 'true' | |
| working-directory: ./apps/native-ui-storybook | |
| run: pnpm run build:preview:ios | |
| - name: 🔐 Create/Read .env | |
| if: steps.check_build.outputs.build == 'true' | |
| run: touch ./apps/native-ui-storybook/.env.ios && cat ./apps/native-ui-storybook/.env.ios | |
| - name: 🔄 Load .env file | |
| uses: xom9ikk/dotenv@v2 | |
| if: steps.check_build.outputs.build == 'true' | |
| with: | |
| path: ./apps/native-ui-storybook | |
| mode: 'ios' | |
| - name: ⬆️ Upload new bundle to Appetize | |
| uses: appetizeio/[email protected] | |
| id: appetizeio_github_action_appetize | |
| if: steps.check_build.outputs.build == 'true' && (github.event.action == 'opened' || github.event.action == 'reopened' || (!env.IOS_API_KEY && github.event_name == 'pull_request')) | |
| with: | |
| apiToken: ${{ secrets.APPETIZE_API_TOKEN }} | |
| appFile: /Users/runner/work/design-systems/design-systems/apps/native-ui-storybook/build/native-ui.tar.gz | |
| platform: 'ios' | |
| - name: 📝 Add output to .env | |
| if: steps.check_build.outputs.build == 'true' && (github.event.action == 'opened' || github.event.action == 'reopened' || !env.IOS_API_KEY) | |
| working-directory: ./apps/native-ui-storybook | |
| run: | | |
| if [ "${{ github.event_name }}" == "push" ]; then | |
| echo "IOS_API_KEY=${{ secrets.APPETIZE_PUBLIC_KEY_IOS }}" >> .env.ios | |
| elif [ ${{steps.appetizeio_github_action_appetize.outputs.publicKey}} ]; then | |
| echo "IOS_API_KEY=${{ steps.appetizeio_github_action_appetize.outputs.publicKey }}" >> .env.ios | |
| else | |
| echo "No public key found" | |
| fi | |
| - name: 🔄 Reload .env file | |
| uses: xom9ikk/dotenv@v2 | |
| if: steps.check_build.outputs.build == 'true' | |
| with: | |
| path: ./apps/native-ui-storybook | |
| mode: 'ios' | |
| - name: 💾 Save .env | |
| uses: actions/upload-artifact@v4 | |
| if: steps.check_build.outputs.build == 'true' && github.event_name == 'pull_request' && env.IOS_API_KEY | |
| with: | |
| name: ${{ github.event.pull_request.base.sha }}-env-ios | |
| path: ./apps/native-ui-storybook/.env.ios | |
| include-hidden-files: true | |
| overwrite: true | |
| - name: ⬆️ Upload updated bundle to Appetize | |
| uses: appetizeio/[email protected] | |
| if: steps.check_build.outputs.build == 'true' && github.event.action != 'opened' && env.IOS_API_KEY | |
| with: | |
| apiToken: ${{ secrets.APPETIZE_API_TOKEN }} | |
| publicKey: ${{ env.IOS_API_KEY }} | |
| appFile: /Users/runner/work/design-systems/design-systems/apps/native-ui-storybook/build/native-ui.tar.gz | |
| platform: 'ios' | |
| - name: ✅ Done | |
| run: echo "Job done" | |
| build-for-web: | |
| name: Build for Web | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-for-android | |
| - build-for-ios | |
| if: ${{ needs.build-for-android.result != 'failure' && needs.build-for-ios.result != 'failure' }} | |
| concurrency: | |
| group: preview-web-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
| steps: | |
| - name: 📝 Echo needs | |
| run: | | |
| echo "Needs: ${{ toJson(needs) }}" | |
| - name: 🔧 Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: 📂 Checkout code | |
| uses: actions/checkout@v4 | |
| - name: 🔧 Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: 'pnpm' | |
| - name: 🔍 Extract branch name | |
| shell: bash | |
| run: echo "branch=$(echo ${GITHUB_HEAD_REF##*/})" >> "$GITHUB_OUTPUT" | |
| id: extract_branch | |
| - name: 📦 Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: 📦 Install Vercel CLI | |
| run: pnpm install --global vercel@latest | |
| - name: 🔄 Pull Vercel Environment Information | |
| run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | |
| - name: 📝 Log commit message and PR details | |
| run: | | |
| echo "Commit message: ${{ github.event.head_commit.message }}" | |
| echo "PR Title: ${{ github.event.pull_request.title }}" | |
| echo "PR Body: ${{ github.event.pull_request.body }}" | |
| # Conditional steps for Android | |
| - name: 🔄 Restore Android .env | |
| if: | | |
| (github.event_name == 'push' && (contains(github.event.head_commit.message, '[build-android]') || contains(github.event.head_commit.message, '[build-native]'))) || | |
| (github.event_name != 'push' && (contains(github.event.pull_request.title, '[build-android]') || contains(github.event.pull_request.title, '[build-native]') || contains(github.event.pull_request.body, '[build-android]') || contains(github.event.pull_request.body, '[build-native]'))) | |
| working-directory: ./apps/native-ui-storybook | |
| run: | | |
| GITHUB_PAT_TOKEN=${{ secrets.DS_ACTION_READ_PAT }} ARTIFACT_NAME=${{ github.event.pull_request.base.sha }}-env-android node ./scripts/getArtifacts.js | |
| - name: 🔄 Load .env.android file | |
| if: | | |
| (github.event_name == 'push' && (contains(github.event.head_commit.message, '[build-android]') || contains(github.event.head_commit.message, '[build-native]'))) || | |
| (github.event_name != 'push' && (contains(github.event.pull_request.title, '[build-android]') || contains(github.event.pull_request.title, '[build-native]') || contains(github.event.pull_request.body, '[build-android]') || contains(github.event.pull_request.body, '[build-native]'))) | |
| uses: xom9ikk/dotenv@v2 | |
| with: | |
| path: ./apps/native-ui-storybook | |
| mode: 'android' | |
| - name: 🔐 Create local .env and add Android key | |
| if: | | |
| (github.event_name == 'push' && (contains(github.event.head_commit.message, '[build-android]') || contains(github.event.head_commit.message, '[build-native]'))) || | |
| (github.event_name != 'push' && (contains(github.event.pull_request.title, '[build-android]') || contains(github.event.pull_request.title, '[build-native]') || contains(github.event.pull_request.body, '[build-android]') || contains(github.event.pull_request.body, '[build-native]'))) | |
| working-directory: ./packages/native-ui | |
| run: | | |
| echo "ANDROID_API_KEY=${{ env.ANDROID_API_KEY }}" >> .env | |
| # Conditional steps for iOS | |
| - name: 🔄 Restore iOS .env | |
| if: | | |
| (github.event_name == 'push' && (contains(github.event.head_commit.message, '[build-ios]') || contains(github.event.head_commit.message, '[build-native]'))) || | |
| (github.event_name != 'push' && (contains(github.event.pull_request.title, '[build-ios]') || contains(github.event.pull_request.title, '[build-native]') || contains(github.event.pull_request.body, '[build-ios]') || contains(github.event.pull_request.body, '[build-native]'))) | |
| working-directory: ./apps/native-ui-storybook | |
| run: | | |
| GITHUB_PAT_TOKEN=${{ secrets.DS_ACTION_READ_PAT }} ARTIFACT_NAME=${{ github.event.pull_request.base.sha }}-env-ios node ./scripts/getArtifacts.js | |
| - name: 🔄 Load .env.ios file | |
| if: | | |
| (github.event_name == 'push' && (contains(github.event.head_commit.message, '[build-ios]') || contains(github.event.head_commit.message, '[build-native]'))) || | |
| (github.event_name != 'push' && (contains(github.event.pull_request.title, '[build-ios]') || contains(github.event.pull_request.title, '[build-native]') || contains(github.event.pull_request.body, '[build-ios]') || contains(github.event.pull_request.body, '[build-native]'))) | |
| uses: xom9ikk/dotenv@v2 | |
| with: | |
| path: ./apps/native-ui-storybook | |
| mode: 'ios' | |
| - name: 🔐 Create local .env and add iOS key | |
| if: | | |
| (github.event_name == 'push' && (contains(github.event.head_commit.message, '[build-ios]') || contains(github.event.head_commit.message, '[build-native]'))) || | |
| (github.event_name != 'push' && (contains(github.event.pull_request.title, '[build-ios]') || contains(github.event.pull_request.title, '[build-native]') || contains(github.event.pull_request.body, '[build-ios]') || contains(github.event.pull_request.body, '[build-native]'))) | |
| working-directory: ./packages/native-ui | |
| run: | | |
| echo "IOS_API_KEY=${{ env.IOS_API_KEY }}" >> .env | |
| - name: 🔐 Create local production .env | |
| working-directory: ./packages/native-ui | |
| run: | | |
| title="${{ github.event.pull_request.title }}" | |
| body="${{ github.event.pull_request.body }}" | |
| commit_message="${{ github.event.head_commit.message }}" | |
| if [ "${{ github.event_name }}" == "push" ]; then | |
| if [[ "$commit_message" == *"[build-native]"* ]]; then | |
| echo "ANDROID_API_KEY=${{ secrets.APPETIZE_PUBLIC_KEY_ANDROID }}" >> .env | |
| echo "IOS_API_KEY=${{ secrets.APPETIZE_PUBLIC_KEY_IOS }}" >> .env | |
| else | |
| if [[ "$commit_message" == *"[build-android]"* ]]; then | |
| echo "ANDROID_API_KEY=${{ secrets.APPETIZE_PUBLIC_KEY_ANDROID }}" >> .env | |
| fi | |
| if [[ "$commit_message" == *"[build-ios]"* ]]; then | |
| echo "IOS_API_KEY=${{ secrets.APPETIZE_PUBLIC_KEY_IOS }}" >> .env | |
| fi | |
| fi | |
| else | |
| # For PRs, only add keys if builds were requested | |
| if [[ "$title" == *"[build-native]"* ]] || [[ "$body" == *"[build-native]"* ]]; then | |
| echo "ANDROID_API_KEY=${{ env.ANDROID_API_KEY }}" >> .env | |
| echo "IOS_API_KEY=${{ env.IOS_API_KEY }}" >> .env | |
| else | |
| if [[ "$title" == *"[build-android]"* ]] || [[ "$body" == *"[build-android]"* ]]; then | |
| echo "ANDROID_API_KEY=${{ env.ANDROID_API_KEY }}" >> .env | |
| fi | |
| if [[ "$title" == *"[build-ios]"* ]] || [[ "$body" == *"[build-ios]"* ]]; then | |
| echo "IOS_API_KEY=${{ env.IOS_API_KEY }}" >> .env | |
| fi | |
| fi | |
| fi | |
| - name: 🔄 Pull Vercel Environment Information | |
| run: | | |
| if [ "${{ github.event_name }}" == "pull_request" ]; then | |
| vercel pull --yes --environment=preview --git-branch=${{ steps.extract_branch.outputs.branch }} --token=${{ secrets.VERCEL_TOKEN }} | |
| else | |
| vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} | |
| fi | |
| - name: 🏗 Build Project Artifacts | |
| run: | | |
| if [ "${{ github.event_name }}" == "pull_request" ]; then | |
| vercel build --token=${{ secrets.VERCEL_TOKEN }} | |
| else | |
| vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} | |
| fi | |
| - name: 🚀 Deploy Project Artifacts to Vercel | |
| run: | | |
| if [ "${{ github.event_name }}" == "pull_request" ]; then | |
| vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --meta githubCommitRef=${{ github.head_ref }} --meta githubCommitSha=${{ github.sha }} > ./vercel-deploy.log | |
| else | |
| vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} --meta githubCommitSha=${{ github.sha }} > ./vercel-deploy.log | |
| fi | |
| - name: 🔍 Extract Deployment URL | |
| if: github.event_name == 'pull_request' | |
| id: extract_deployment_url | |
| run: | | |
| echo "deployment-url=$(cat ./vercel-deploy.log)" >> "$GITHUB_OUTPUT" | |
| - name: 💬 Find Comment | |
| uses: peter-evans/find-comment@v3 | |
| if: github.event_name == 'pull_request' | |
| id: fc | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-author: 'github-actions[bot]' | |
| body-includes: Storybook Preview | |
| - name: 💬 Create or update comment | |
| uses: peter-evans/create-or-update-comment@v4 | |
| if: github.event_name == 'pull_request' | |
| with: | |
| comment-id: ${{ steps.fc.outputs.comment-id }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: | | |
| ## 🖥️ Native UI - Storybook Preview | |
| Visit the Storybook preview URL to see the changes in action. | |
| - Preview: [${{ steps.extract_deployment_url.outputs.deployment-url }}](${{ steps.extract_deployment_url.outputs.deployment-url }}) | |
| ## 📱 Appetize Previews | |
| You can view the apps using the link above and choosing the device from the top action bar. Alternatively, you can use the direct links below. | |
| - [Android](https://appetize.io/embed/${{ env.ANDROID_API_KEY }}) | |
| - [iOS](https://appetize.io/embed/${{ env.IOS_API_KEY }}) | |
| --- | |
| Last updated from commit ${{ github.sha }} | |
| edit-mode: replace |