Browse Source

build: reuse build job with publish secrets

Keeley Hammond 1 year ago
parent
commit
65bd2db0f5
3 changed files with 125 additions and 50 deletions
  1. 23 21
      .circleci/config.yml
  2. 70 29
      .github/workflows/macos-build.yml
  3. 32 0
      .github/workflows/macos-publish.yml

+ 23 - 21
.circleci/config.yml

@@ -49,28 +49,30 @@ jobs:
     docker:
       - image: cimg/node:16.14
     steps:
-      - checkout
-      - path-filtering/set-parameters:
-          base-revision: main
-          mapping: |
-            ^((?!docs/).)*$ run-build-mac true
-            ^((?!docs/).)*$ run-build-linux true
-            docs/.* run-docs-only true
-            ^((?!docs/).)*$ run-docs-only false
       - run:
-          command: |
-            cd .circleci/config
-            yarn
-            export CIRCLECI_BINARY="$HOME/circleci"
-            curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/main/install.sh | DESTDIR=$CIRCLECI_BINARY bash
-            node build.js
-          name: Pack config.yml
-      - run:
-          name: Set params
-          command: node .circleci/config/params.js
-      - continuation/continue:
-          configuration_path: .circleci/config-staging/built.yml
-          parameters: /tmp/pipeline-parameters.json
+          command: echo "CircleCI disabled."
+      # - checkout
+      # - path-filtering/set-parameters:
+      #     base-revision: main
+      #     mapping: |
+      #       ^((?!docs/).)*$ run-build-mac true
+      #       ^((?!docs/).)*$ run-build-linux true
+      #       docs/.* run-docs-only true
+      #       ^((?!docs/).)*$ run-docs-only false
+      # - run:
+      #     command: |
+      #       cd .circleci/config
+      #       yarn
+      #       export CIRCLECI_BINARY="$HOME/circleci"
+      #       curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/main/install.sh | DESTDIR=$CIRCLECI_BINARY bash
+      #       node build.js
+      #     name: Pack config.yml
+      # - run:
+      #     name: Set params
+      #     command: node .circleci/config/params.js
+      # - continuation/continue:
+      #     configuration_path: .circleci/config-staging/built.yml
+      #     parameters: /tmp/pipeline-parameters.json
 
 # Initial setup workflow
 workflows:

+ 70 - 29
.github/workflows/macos-build.yml

@@ -1,40 +1,32 @@
 name: Build MacOS
 
 on:
-  workflow_dispatch:
+  workflow_call:
     inputs:
-      macos-publish-arch-limit:
-        description: 'The allowed arches for macos-publish'
-        type: choice
-        default: all
-        options: ["all", "osx-x64", "osx-arm64", "mas-x64", "mas-arm64"]
-      upload-to-storage:
-        description: 'True to print to STDOUT'
-        required: true
-        default: '0'
+      environment:
+        required: false
         type: string
-      run-macos-publish:
-        description: 'Run the publish jobs vs just the build jobs'
-        type: boolean
-        default: false
+        default: ''
 
 env:
+  # Disable pre-compiled headers to reduce out size - only useful for rebuilds
+  GN_BUILDFLAG_ARGS: 'enable_precompiled_headers = false'
   GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac --custom-var=host_cpu=arm64'
   IS_RELEASE: false
-  # GENERATE_SYMBOLS: true only on release builds
-  GENERATE_SYMBOLS: false
-  AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }}
-  AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }}
-  AZURE_STORAGE_CONTAINER_NAME: ${{ secrets.AZURE_STORAGE_CONTAINER_NAME }}
-  ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
-  # TODO: this should be set to the correct GN_CONFIG for the build type.
   GN_CONFIG: //electron/build/args/testing.gn
-  # Disable pre-compiled headers to reduce out size - only useful for rebuilds
-  GN_BUILDFLAG_ARGS: 'enable_precompiled_headers = false'
+  STRIP_BINARIES: false
+  GENERATE_SYMBOLS: false
+  UPLOAD_TO_STORAGE: '0'
 
 jobs:
   checkout:
     runs-on: LargeLinuxRunner
+    environment: ${{ inputs.environment }}
+    env:
+      AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }}
+      AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }}
+      AZURE_STORAGE_CONTAINER_NAME: ${{ secrets.AZURE_STORAGE_CONTAINER_NAME }}
+      ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
     steps:
     - name: Checkout Electron
       uses: actions/checkout@v4
@@ -150,6 +142,12 @@ jobs:
   build:
     runs-on: macos-13-xlarge
     needs: checkout
+    environment: ${{ inputs.environment }}
+    env:
+      AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }}
+      AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }}
+      AZURE_STORAGE_CONTAINER_NAME: ${{ secrets.AZURE_STORAGE_CONTAINER_NAME }}
+      ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
     steps:
     - name: Load Build Tools
       run: |
@@ -358,10 +356,48 @@ jobs:
         export BUILD_PATH="$(pwd)/out/Default"
         e build electron:licenses
         e build electron:electron_version_file
-        electron/script/zip-symbols.py -b $BUILD_PATH
-      # TODO(vertedinde): handle creating ffmpeg and hunspell for release builds
-      # The current generated_artifacts_<< artifact.key >> name was taken from CircleCI
-      # tp ensure we don't break anything, but we may be able to improve that.
+        if [ "$IS_RELEASE" == "true" ]; then
+          DELETE_DSYMS_AFTER_ZIP=1 electron/script/zip-symbols.py -b $BUILD_PATH
+        else
+          electron/script/zip-symbols.py -b $BUILD_PATH
+        fi
+    # Only generate ffmpeg, hunspell, and typescript definitions for release builds
+    - name: Generate ffmpeg
+      run: |
+        if [ "$IS_RELEASE" == "true" ]; then
+          cd src
+          gn gen out/ffmpeg --args="import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true $GN_EXTRA_ARGS"
+          autoninja -C out/ffmpeg electron:electron_ffmpeg_zip -j $NUMBER_OF_NINJA_PROCESSES
+        fi
+    - name: Generate Hunspell Dictionaries
+      run: |
+        if [ "$IS_RELEASE" == "true" ]; then
+          cd src
+          if [ "$SKIP_DIST_ZIP" != "1" ]; then
+            autoninja -C out/Default electron:hunspell_dictionaries_zip -j $NUMBER_OF_NINJA_PROCESSES
+          fi
+        fi
+    - name: Generate TypeScript Definitions
+      run: |
+        if [ "$IS_RELEASE" == "true" ]; then
+          cd src/electron
+          node script/yarn create-typescript-definitions
+        fi
+    # TODO(vertedinde): Don't actually upload the dist to Azure/GH yet,
+    # this should be one of the last things we turn on
+    - name: Publish Electron Dist
+      run: |
+        rm -rf src/out/Default/obj
+        cd src/electron
+        if [ "$UPLOAD_TO_STORAGE" == "1" ]; then
+          echo 'Uploading Electron release distribution to Azure'
+          # script/release/uploaders/upload.py --verbose --upload_to_storage
+        else
+          echo 'Uploading Electron release distribution to GitHub releases'
+          # script/release/uploaders/upload.py --verbose
+        fi
+    # The current generated_artifacts_<< artifact.key >> name was taken from CircleCI
+    # tp ensure we don't break anything, but we may be able to improve that.
     - name: Move all Generated Artifacts to Upload Folder
       run: ./src/electron/script/actions/move-artifacts.sh
     - name: Upload Generated Artifacts
@@ -450,7 +486,11 @@ jobs:
         export BUILD_PATH="$(pwd)/out/Default"
         e build electron:licenses
         e build electron:electron_version_file
-        electron/script/zip-symbols.py -b $BUILD_PATH
+        if [ "$IS_RELEASE" == "true" ]; then
+          DELETE_DSYMS_AFTER_ZIP=1 electron/script/zip-symbols.py -b $BUILD_PATH
+        else
+          electron/script/zip-symbols.py -b $BUILD_PATH
+        fi
     - name: Move all Generated Artifacts to Upload Folder (mas)
       run: ./src/electron/script/actions/move-artifacts.sh
     - name: Upload Generated Artifacts
@@ -479,6 +519,7 @@ jobs:
           src/v8/tools/builtins-pgo
         key: ${{ runner.os }}-build-artifacts-mas-${{ github.sha }}
   test:
+    # if: ${{ env.IS_RELEASE != true }} TODO FIX THIS
     runs-on: macos-13-xlarge
     needs: build
     strategy:
@@ -571,4 +612,4 @@ jobs:
         ELECTRON_SKIP_NATIVE_MODULE_TESTS: true
       run: |
         cd src/electron
-        node script/yarn test --runners=main --trace-uncaught --enable-logging
+        node script/yarn test --runners=main --trace-uncaught --enable-logging

+ 32 - 0
.github/workflows/macos-publish.yml

@@ -0,0 +1,32 @@
+name: Publish MacOS
+
+on:
+  workflow_dispatch:
+    inputs:
+      macos-publish-arch-limit:
+        description: 'The allowed arches for macos-publish'
+        type: choice
+        default: all
+        options: ["all", "osx-x64", "osx-arm64", "mas-x64", "mas-arm64"]
+      upload-to-storage:
+        description: 'Uploads to Azure storage'
+        required: false 
+        default: '0'
+        type: string
+      run-macos-publish:
+        description: 'Run the publish jobs vs just the build jobs'
+        type: boolean
+        default: false
+
+jobs:
+  publish:
+    uses: electron/electron/.github/workflows/macos-build.yml@gh-macos-publish
+    with:
+      environment: production-release
+    # secrets:
+    #   IS_RELEASE: ${{ secrets.IS_RELEASE }}
+    #   GN_CONFIG: ${{ secrets.GN_CONFIG }}
+    #   STRIP_BINARIES: ${{ secrets.STRIP_BINARIES }}
+    #   GENERATE_SYMBOLS: ${{ secrets.GENERATE_SYMBOLS }}
+    #   CHECK_DIST_MANIFEST: ${{ secrets.CHECK_DIST_MANIFEST }}
+    #   UPLOAD_TO_STORAGE: ${{ secrets.UPLOAD_TO_STORAGE }}