diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml new file mode 100644 index 0000000..4c409b5 --- /dev/null +++ b/.github/actions/setup-env/action.yml @@ -0,0 +1,94 @@ +name: 'Checkout and setup' +description: 'Checks out code and sets up environment' +inputs: + node: + description: 'Node.js version' + required: false + default: '20' + runs-on: + description: 'Runner OS' + required: false + default: 'windows-2022' + electron: + description: 'Electron version' + required: true + replace-version: + description: 'Replace electron version?' + required: false + default: 'false' + +runs: + using: "composite" + steps: + # - name: Checkout code + # uses: actions/checkout@v4 + + - name: Setup NodeJS + uses: actions/setup-node@v4 + with: + node-version: inputs.node + cache: 'npm' + cache-dependency-path: package-lock.json + + - name: Cache node modules + id: cache-nodemodules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + path: node_modules + key: ${{ inputs.runs-on }}-${{ inputs.electron }}-${{ hashFiles('package-lock.json') }} + + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' # SDK Version to use; x will use the latest version of the 8.0 channel + + - name: Versions + shell: bash + run: | + node -v && npm -v && dotnet --version && node -p process.platform && node -p process.arch + + - name: "Read JSON" + uses: actions/github-script@v7 + id: check-env + with: + result-encoding: string + script: | + try { + const fs = require('fs') + const jsonString = fs.readFileSync('package.json') + var json = JSON.parse(jsonString); + core.exportVariable('json_electron_version', json.devDependencies.electron.toString()) + } catch(err) { + core.error("Error while reading or parsing package.json") + core.setFailed(err) + } + + - name: setup electron version + shell: bash + if: ${{ inputs.replace-version == 'true' }} + run: | + sed -i -e 's/${{ env.json_electron_version}}/${{ inputs.electron }}/g' package.json + + # - if: runner.os == 'Windows' + # uses: agracio/github-substring-action@v1.0.0 + # id: electron_version + # with: + # value: "${{ matrix.electron }}" + # length_from_start: 2 + + # - if: runner.os == 'Windows' + # name: Check electron-edge-js Windows pre-built files + # id: check_windows_build + # uses: andstor/file-existence-action@v3 + # with: + # files: "lib/native/win32/${{ runner.arch }}/${{ steps.electron_version.outputs.substring }}.0.0/edge_coreclr.node, lib/native/win32/${{ runner.arch }}/${{ steps.electron_version.outputs.substring }}.0.0/edge_nativeclr.node" + # fail: true + # ignore_case: true + + - name: npm install + shell: bash + run: npm ci + env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9923331..e1765a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,62 +18,50 @@ jobs: name: build Electron-${{ matrix.electron }} steps: + - name: Checkout code uses: actions/checkout@v4 - - - name: "Read JSON" - uses: actions/github-script@v7 - id: check-env - with: - result-encoding: string - script: | - try { - const fs = require('fs') - const jsonString = fs.readFileSync('package.json') - var json = JSON.parse(jsonString); - core.setFailed(json.devDependencies.electron) - } catch(err) { - core.error("Error while reading or parsing the JSON") - core.setFailed(err) - } - - - name: Setup NodeJS - uses: actions/setup-node@v4 - with: - node-version: '20' - cache: 'npm' - cache-dependency-path: package-lock.json - - - name: Cache node modules - id: cache-nodemodules - uses: actions/cache@v4 - env: - cache-name: cache-node-modules - with: - path: node_modules - key: ${{ matrix.electron }}-${{ hashFiles('package-lock.json') }} - - - name: Setup dotnet - uses: actions/setup-dotnet@v4 + - name: Setup env + uses: ./github/action/setup-env with: - dotnet-version: '8.0.x' # SDK Version to use; x will use the latest version of the 8.0 channel - - - name: Versions - run: | - node -v && npm -v && dotnet --version && node -p process.platform && node -p process.arch - - - name: setup electron version - shell: bash - run: | - sed -i -e 's/"electron": "=31.6.0"/"electron": "=${{ matrix.electron }}"/g' package.json + electron: ${{ matrix.electron }} + + - name: Exit + run: exit 1 + # - name: Setup NodeJS + # uses: actions/setup-node@v4 + # with: + # node-version: '20' + # cache: 'npm' + # cache-dependency-path: package-lock.json + + # - name: Cache node modules + # id: cache-nodemodules + # uses: actions/cache@v4 + # env: + # cache-name: cache-node-modules + # with: + # path: node_modules + # key: ${{ matrix.electron }}-${{ hashFiles('package-lock.json') }} + + + # - name: Setup dotnet + # uses: actions/setup-dotnet@v4 + # with: + # dotnet-version: '8.0.x' # SDK Version to use; x will use the latest version of the 8.0 channel + + # - name: Versions + # run: | + # node -v && npm -v && dotnet --version && node -p process.platform && node -p process.arch + + # - name: setup electron version + # shell: bash + # run: | + # sed -i -e 's/"electron": "=31.6.0"/"electron": "=${{ matrix.electron }}"/g' package.json - - name: npm install - run: | - npm i - npm i -g node-gyp - env: - DOTNET_CLI_TELEMETRY_OPTOUT: 1 + - name: install node-gyp + run: npm i -g node-gyp - uses: agracio/github-substring-action@v1.0.0 id: electron_version @@ -86,9 +74,6 @@ jobs: mkdir "release\ia32\${{ matrix.electron }}" mkdir "release\x64\${{ matrix.electron }}" mkdir "release\arm64\${{ matrix.electron }}" - cmd /c if not exist "lib\native\win32\ia32\${{ steps.electron_version.outputs.substring }}.0.0" mkdir "lib\native\win32\ia32\${{ steps.electron_version.outputs.substring }}.0.0" - cmd /c if not exist "lib\native\win32\x64\${{ steps.electron_version.outputs.substring }}.0.0" mkdir "lib\native\win32\x64\${{ steps.electron_version.outputs.substring }}.0.0" - cmd /c if not exist "lib\native\win32\arm64\${{ steps.electron_version.outputs.substring }}.0.0" mkdir "lib\native\win32\arm64\${{ steps.electron_version.outputs.substring }}.0.0" - name: Build ia32 timeout-minutes: 30