From b307632e0482d536c8cf78fbbe191e3e97281f6f Mon Sep 17 00:00:00 2001 From: jsu <41497174+jsubloom@users.noreply.github.com> Date: Thu, 31 Aug 2023 21:19:08 -0500 Subject: [PATCH] modify build-local to build for all 3 platforms --- .github/workflows/build-full.yml | 20 +--- .github/workflows/build-local.yml | 176 +++++++++++++++++++++++------- .github/workflows/build.yml | 39 +++++++ 3 files changed, 180 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build-full.yml b/.github/workflows/build-full.yml index 3414517..2aaf722 100644 --- a/.github/workflows/build-full.yml +++ b/.github/workflows/build-full.yml @@ -1,4 +1,8 @@ -name: Cloud Build +# You can use this to manually trigger a cloud build on Expo EAS +# However, Expo EAS builds have a limited quota, whereas we don't have a limit when running on Github actions. +# Since getting it to run on Github actions didn't end up being too hard, there's not too much point +# to this workflow anymore +name: Cloud Build (Deprecated) on: workflow_dispatch: inputs: @@ -41,7 +45,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16.14.* - # ENHANCE: Not sure why caching errors out. It can't ever seem to find the path, no matter what I tried. cache: yarn cache-dependency-path: "**/yarn.lock" @@ -53,14 +56,6 @@ jobs: run: yarn build working-directory: packages/shared/ - # This gave an answer of 135,210 bytes. - # That's pretty close? I'm expecting 138,443 - - name: Print Yarn Lock Size - run: | - yarn_lock_size=$(stat -c %s yarn.lock) - echo "Size of yarn.lock: $yarn_lock_size bytes" - working-directory: packages/web/ - - name: 2) [web] Install dependencies # run: yarn --frozen-lockfile # TODO: --frozen-lockfile is erroring out, saying it must be updated. But it doesn't do that on my local machine. Why does it do that on the Github runner? Both seem to be using the same yarn version, 1.22.19 run: yarn @@ -81,11 +76,6 @@ jobs: eas-version: latest token: ${{ secrets.EXPO_TOKEN }} - - name: Print Folder Structure - run: | - echo "Folder structure:" - tree -L 5 --dirsfirst - # IF interested in trying local build: https://github.com/suiet/suiet/blob/63b50e4ba225b294af1018f3f98b9666738837c7/.github/workflows/build-app.yml#L9 - name: 3A) [mobile] EAS Cloud Build run: eas build --platform ${{ github.event.inputs.platform }} --profile ${{ github.event.inputs.releaseStage }} --non-interactive --no-wait diff --git a/.github/workflows/build-local.yml b/.github/workflows/build-local.yml index 7cc8dbc..9d91a7b 100644 --- a/.github/workflows/build-local.yml +++ b/.github/workflows/build-local.yml @@ -2,16 +2,7 @@ name: Local Build on: workflow_dispatch: inputs: - platform: - type: choice - description: "Which mobile platforms to build" - required: true - default: "all" - options: - - android - - ios - - all - releaseStage: + releaseChannel: type: choice description: "type of release" required: true @@ -20,13 +11,16 @@ on: - alpha - beta - release + workflow_call: + inputs: + releaseChannel: + type: string + required: true jobs: - build-local-job: - name: Build application binaries locally + build-dependencies: + name: Build dependencies runs-on: ubuntu-latest - #runs-on: macos-latest - steps: - name: Check for EXPO_TOKEN run: | @@ -42,7 +36,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16.14.* - # ENHANCE: Not sure why caching errors out. It can't ever seem to find the path, no matter what I tried. cache: yarn cache-dependency-path: "**/yarn.lock" @@ -54,9 +47,16 @@ jobs: run: yarn build working-directory: packages/shared/ + # Need to upload it so that the subsequent jobs can access it + - name: 1) [shared] Upload build + uses: actions/upload-artifact@v3 + with: + name: shared-dist + path: packages/shared/dist + # This gave an answer of 135,210 bytes. # That's pretty close? I'm expecting 138,443 - - name: Print Yarn Lock Size + - name: Debugging - Print Yarn Lock Size (Before) run: | yarn_lock_size=$(stat -c %s yarn.lock) echo "Size of yarn.lock: $yarn_lock_size bytes" @@ -67,44 +67,140 @@ jobs: run: yarn working-directory: packages/web/ + - name: Debugging - Print Yarn Lock Size (After) + run: | + yarn_lock_size=$(stat -c %s yarn.lock) + echo "Size of yarn.lock: $yarn_lock_size bytes" + working-directory: packages/web/ + - name: 2) [web] Build run: yarn build working-directory: packages/web/ - - name: 3A) [mobile] Install dependencies + # Need to upload it so that the subsequent jobs can access it + - name: 2) [web] Upload build + uses: actions/upload-artifact@v3 + with: + name: web-dist + path: packages/web/dist + + build-mobile: + name: Build ${{ matrix.platform }} binaries + needs: build-dependencies + runs-on: ${{ matrix.os }} + defaults: + run: + working-directory: packages/mobile + + strategy: + matrix: + platform: [android, ios] + include: + - os: ubuntu-latest + platform: android + - os: macos-latest + platform: ios + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16.14.* + cache: yarn + cache-dependency-path: "**/yarn.lock" + + - name: 1) [shared] Download dist folder artifact + uses: actions/download-artifact@v3 + with: + name: shared-dist + path: packages/shared/dist + + - name: 2) [web] Download dist folder artifact + uses: actions/download-artifact@v3 + with: + name: web-dist + path: packages/web/dist + + - name: 3) [${{ matrix.platform }}] Install dependencies # run: yarn --frozen-lockfile # TODO: --frozen-lockfile is erroring out, saying it must be updated. But it doesn't do that on my local machine. Why does it do that on the Github runner? Both seem to be using the same yarn version, 1.22.19 run: yarn - working-directory: packages/mobile/ - - name: 3A) [mobile] Setup EAS + - name: 3) [${{ matrix.platform }}] Setup EAS uses: expo/expo-github-action@v8 with: eas-version: latest token: ${{ secrets.EXPO_TOKEN }} - - name: Print Folder Structure - run: | - echo "Folder structure:" - tree -L 5 --dirsfirst - # Inspired by: https://github.com/suiet/suiet/blob/63b50e4ba225b294af1018f3f98b9666738837c7/.github/workflows/build-app.yml#L9 - - name: 3A) [mobile] EAS Local Build - run: eas build --local --platform ${{ github.event.inputs.platform }} --profile ${{ github.event.inputs.releaseStage }} --non-interactive - working-directory: packages/mobile/ + - name: 3) [${{ matrix.platform }}] EAS Local Build + run: eas build --local --platform ${{ matrix.platform }} --profile ${{ github.event.inputs.releaseChannel }} --non-interactive - name: Print Folder Structure run: | echo "Folder structure:" - tree -L 4 --dirsfirst - # TODO: Upload artifact if successful - # - name: 3B) [electron] Install dependencies - # run: yarn --frozen-lockfile - # working-directory: ./packages/electron - - # - name: 3B) [electron] Build - # run: yarn build - # working-directory: ./packages/electron - - - name: 3B) [electron] Temporary Placeholder - run: echo "nothing to do" - working-directory: ./packages/electron + tree -L 3 --dirsfirst + if: matrix.os == 'ubuntu-latest' + + - name: 3) [${{ matrix.platform }}] Upload binary + uses: actions/upload-artifact@v3 + with: + name: BloomReaderLite-${{ matrix.platform }}-${{ inputs.releaseChannel }} + path: packages/mobile/build-* + + build-electron: + name: Build electron binaries + needs: build-dependencies + runs-on: ubuntu-latest + defaults: + run: + working-directory: packages/electron-demo + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 16.14.* + cache: yarn + cache-dependency-path: "packages/electron-demo/yarn.lock" + + - name: 1) [shared] Download dist folder artifact + uses: actions/download-artifact@v3 + with: + name: shared-dist + path: packages/shared/dist + + - name: 2) [web] Download dist folder artifact + uses: actions/download-artifact@v3 + with: + name: web-dist + path: packages/web/dist + + - name: 3) [electron] Install dependencies + run: yarn + + - name: 3) [electron] Build + run: yarn build + + - name: 3) [electron] Upload binary + uses: actions/upload-artifact@v3 + with: + name: BloomReaderLite-electron-${{ inputs.releaseChannel }} + path: packages/electron-demo/output/* + + cleanup: + name: Cleanup + if: always() # Run even if previous jobs failed or cancelled + needs: [build-mobile, build-electron] + runs-on: ubuntu-latest + steps: + - name: Delete temporary artifacts + uses: geekyeggo/delete-artifact@v2 + with: + name: | + shared-dist + web-dist diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5c07565 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +name: Build (Automatic) +on: + push: + branches: + - master + - beta + - release + +jobs: + build-test: + if: always() # Temp testing + # if: github.ref == 'refs/heads/master' # Check the branch name + uses: ./.github/workflows/build-local.yml + secrets: inherit + with: + releaseChannel: "alpha" + + build-local: + if: always() # Temp testing + # if: github.ref == 'refs/heads/master' # Check the branch name + uses: ./.github/workflows/build-local.yml + secrets: inherit + with: + #releaseChannel: "alpha" + releaseChannel: ${{ github.ref == 'refs/heads/release' && "release" || (github.ref == 'refs/heads/beta' && "beta" || "alpha" ) }} +# ENHANCE: It'd be nice if these jobs didn't show up +# build-beta: +# if: github.ref == 'refs/heads/beta' # Check the branch name +# uses: ./.github/workflows/build-local.yml +# secrets: inherit +# with: +# releaseChannel: "beta" + +# build-release: +# if: github.ref == 'refs/heads/release' # Check the branch name +# uses: ./.github/workflows/build-local.yml +# secrets: inherit +# with: +# releaseChannel: "release"