DeFiCh/wallet

View on GitHub
.github/workflows/eas-publish.yml

Summary

Maintainability
Test Coverage
name: EAS Publish

on:
  release:
    types: [created]

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  version:
    name: Version
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.version.outputs.result }}
    steps:
      - uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
        id: version
        with:
          script: |
            const semver = context.ref.replace('refs/tags/v', '')
            if (semver.match(/^[0-9]+\.[0-9]+\.[0-9]+$/)) {
              return semver
            }

            throw new Error('not semver')
          result-encoding: string

  eas-release-android:
    name: EAS Release Android
    environment: EAS Release
    runs-on: ubuntu-latest
    needs: [version]
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
      - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
        with:
          node-version: 20

      - uses: expo/expo-github-action@4479f0b3692e25169fa71a02c30d6586ec2f5601 # tag=v7.2.0
        with:
          eas-version: latest
          expo-version: latest
          packager: npm
          token: ${{ secrets.EXPO_TOKEN }}

      - run: npm ci

      - run: |
          git config --global user.email "github-bot@defichain.com"
          git config --global user.name "defichain-bot"
          npx standard-version --release-as ${{needs.version.outputs.version}}

      - name: EAS Build - Android
        run: eas build --platform android --non-interactive --wait --clear-cache
        env:
          EAS_PROJECT_ID: ${{ secrets.EAS_PROJECT_ID }}

      - run: sleep 10s

      - name: EAS Submit - Android - Setup
        run: echo "$ANDROID_SERVICE_ACCOUNT_JSON" > ANDROID_SERVICE_ACCOUNT.json
        env:
          ANDROID_SERVICE_ACCOUNT_JSON: ${{ secrets.ANDROID_SERVICE_ACCOUNT_JSON }}

      - name: EAS Submit - Android - Submit
        run: eas submit --platform android --latest
        env:
          EAS_PROJECT_ID: ${{ secrets.EAS_PROJECT_ID }}

      - name: EAS Submit - Android - Cleanup
        run: rm ANDROID_SERVICE_ACCOUNT.json
        if: always()

  eas-release-ios:
    name: EAS Release iOS
    environment: EAS Release
    runs-on: ubuntu-latest
    needs: [version]
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
      - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
        with:
          node-version: 20

      - uses: expo/expo-github-action@4479f0b3692e25169fa71a02c30d6586ec2f5601 # tag=v7.2.0
        with:
          eas-version: latest
          expo-version: latest
          packager: npm
          token: ${{ secrets.EXPO_TOKEN }}

      - run: npm ci

      - run: |
          git config --global user.email "github-bot@defichain.com"
          git config --global user.name "defichain-bot"
          npx standard-version --release-as ${{needs.version.outputs.version}}

      - name: EAS Build - iOS
        run: eas build --platform ios --non-interactive --wait --clear-cache
        env:
          EAS_PROJECT_ID: ${{ secrets.EAS_PROJECT_ID }}

      - run: sleep 10s

      # TODO(fuxingloh): replace this in the future
      - name: EAS Submit - iOS - Setup
        run: |
          sed -i "s/EAS_APPLE_ID/$APPLE_ID/" eas.json
          sed -i "s/EAS_ASC_APP_ID/$ASC_APP_ID/" eas.json
        env:
          APPLE_ID: ${{ secrets.APPLE_ID }}
          ASC_APP_ID: ${{ secrets.ASC_APP_ID }}

      - name: EAS Submit - iOS - Submit
        run: eas submit --platform ios --latest
        env:
          EXPO_APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.EXPO_APPLE_APP_SPECIFIC_PASSWORD }}
          EAS_PROJECT_ID: ${{ secrets.EAS_PROJECT_ID }}

      - name: EAS Submit - iOS - Cleanup
        run: rm eas.json
        if: always()