Skip to content

Commit

Permalink
updating GitHub pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed Sep 16, 2024
1 parent 5f04056 commit 6288312
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 54 deletions.
94 changes: 94 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
# 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
93 changes: 39 additions & 54 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
id: electron_version
Expand All @@ -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
Expand Down

0 comments on commit 6288312

Please sign in to comment.