Skip to content

Commit

Permalink
ci: add GitHub actions script (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
ba0gu0 authored Jul 11, 2024
1 parent ce742a1 commit 0b76e3d
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 2 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/Release-Linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Release-Linux

on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag to release'
required: true

jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
architecture: [x64, arm64] # 添加架构

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Verify Python Version
run: python --version

- name: Enable Corepack
run: corepack enable

- name: Set Yarn Version
run: corepack prepare yarn

- name: Install dependencies
run: yarn install

- name: Lint code
run: |
yarn lint || (echo "Linting issues found, trying to fix..." && yarn lint-fix)
- name: Build the project for x64
if: matrix.architecture == 'x64'
run: yarn make --arch=x64 --verbose

- name: Build the project for arm64
if: matrix.architecture == 'arm64'
run: yarn make --arch=arm64 --verbose

- name: Find built assets RPM
id: find_assets_rpm
run: |
ASSET_PATH=$(find ./out/make -path './node_modules' -prune -o -name '*.rpm' -print | head -n 1)
ABSOLUTE_ASSET_PATH=$(realpath "$ASSET_PATH")
echo "ASSET_RPM_PATH=$ABSOLUTE_ASSET_PATH" >> $GITHUB_ENV
BASENAME=$(basename "$ASSET_PATH")
echo "ASSET_RPM_BASENAME=$BASENAME" >> $GITHUB_ENV
shell: bash

- name: Find built assets DEB
id: find_assets_deb
run: |
ASSET_PATH=$(find ./out/make -path './node_modules' -prune -o -name '*.deb' -print | head -n 1)
ABSOLUTE_ASSET_PATH=$(realpath "$ASSET_PATH")
echo "ASSET_DEB_PATH=$ABSOLUTE_ASSET_PATH" >> $GITHUB_ENV
BASENAME=$(basename "$ASSET_PATH")
echo "ASSET_DEB_BASENAME=$BASENAME" >> $GITHUB_ENV
shell: bash

- name: Upload Artifacts RPM
id: upload-artifact-rpm
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET_RPM_BASENAME }}
path: ${{ env.ASSET_RPM_PATH }}
overwrite: true

- name: Upload Artifacts DEB
id: upload-artifact-deb
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET_DEB_BASENAME }}
path: ${{ env.ASSET_DEB_PATH }}
overwrite: true

- name: Create and Upload Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag_name }}
name: ${{ env.ASSET_RPM_BASENAME }}
files: ${{ env.ASSET_RPM_PATH }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Create and Upload Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag_name }}
name: ${{ env.ASSET_DEB_BASENAME }}
files: ${{ env.ASSET_DEB_PATH }}
token: ${{ secrets.GITHUB_TOKEN }}
78 changes: 78 additions & 0 deletions .github/workflows/Release-Macos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Release-Macos

on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag to release'
required: true

jobs:
release:
runs-on: macos-latest
strategy:
matrix:
architecture: [x64, arm64]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Verify Python Version
run: python --version

- name: Enable Corepack
run: corepack enable

- name: Set Yarn Version
run: corepack prepare yarn

- name: Install dependencies
run: yarn install

- name: Lint code
run: |
yarn lint || (echo "Linting issues found, trying to fix..." && yarn lint-fix)
- name: Build the project for x64
if: matrix.architecture == 'x64'
run: yarn make --arch=x64 --verbose

- name: Build the project for arm64
if: matrix.architecture == 'arm64'
run: yarn make --arch=arm64 --verbose

- name: Find built asset on macOS
id: find_asset
run: |
ASSET_PATH=$(find ./out/make -path './node_modules' -prune -o -name '*.dmg' -print | head -n 1)
ABSOLUTE_ASSET_PATH=$(realpath "$ASSET_PATH")
echo "ASSET_PATH=$ABSOLUTE_ASSET_PATH" >> $GITHUB_ENV
BASENAME=$(basename "$ASSET_PATH")
echo "ASSET_BASENAME=$BASENAME" >> $GITHUB_ENV
shell: bash

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET_BASENAME }}
path: ${{ env.ASSET_PATH }}
overwrite: true

- name: Create and Upload Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag_name }}
name: ${{ env.ASSET_BASENAME }}
files: ${{ env.ASSET_PATH }}
token: ${{ secrets.GITHUB_TOKEN }}
131 changes: 131 additions & 0 deletions .github/workflows/Release-Windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Release-Windows

on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag to release'
required: true


jobs:
release:
runs-on: windows-latest
strategy:
matrix:
architecture: [x64, arm64, i386] # Add architecture

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Verify Python Version
run: python --version

- name: Enable Corepack
run: corepack enable

- name: Set Yarn Version
run: corepack prepare yarn

- name: Install dependencies
shell: pwsh
run: |
$retries = 5
$count = 0
do {
yarn install
$exitCode = $?
if ($exitCode -eq 0) {
break
}
$count++
Write-Output "Retrying ($count/$retries)..."
Start-Sleep -Seconds 10
} while ($count -lt $retries)
- name: Lint code
run: |
yarn lint || (echo "Linting issues found, trying to fix..." && yarn lint-fix)
- name: Build the project for x64
if: matrix.architecture == 'x64'
run: yarn make --arch=x64 --verbose

- name: Build the project for arm64
if: matrix.architecture == 'arm64'
run: yarn make --arch=arm64 --verbose

- name: Build the project for arm64
if: matrix.architecture == 'i386'
run: yarn make --arch=ia32 --verbose

- name: Find built asset on Windows arm64
if: matrix.architecture == 'arm64'
id: find_asset_arm64
run: |
$assetPath = (Get-ChildItem -Path out/make -Recurse -Filter *.exe | Select-Object -First 1).FullName
$basename = [System.IO.Path]::GetFileNameWithoutExtension($assetPath)
$extension = [System.IO.Path]::GetExtension($assetPath)
$newBasename = ($basename -replace ' ', '-') + "-arm64" + $extension
$newFilePath = (Join-Path -Path (Get-Item $assetPath).DirectoryName -ChildPath $newBasename)
Rename-Item -Path $assetPath -NewName $newBasename
$escapedFilePath = $newFilePath -replace '\\', '\\\\'
echo "ASSET_BASENAME=$newBasename" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "ASSET_PATH=$escapedFilePath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh

- name: Find built asset on Windows x64
if: matrix.architecture == 'x64'
id: find_asset_x64
run: |
$assetPath = (Get-ChildItem -Path out/make -Recurse -Filter *.exe | Select-Object -First 1).FullName
$basename = [System.IO.Path]::GetFileNameWithoutExtension($assetPath)
$extension = [System.IO.Path]::GetExtension($assetPath)
$newBasename = ($basename -replace ' ', '-') + "-x64" + $extension
$newFilePath = (Join-Path -Path (Get-Item $assetPath).DirectoryName -ChildPath $newBasename)
Rename-Item -Path $assetPath -NewName $newBasename
$escapedFilePath = $newFilePath -replace '\\', '\\\\'
echo "ASSET_BASENAME=$newBasename" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "ASSET_PATH=$escapedFilePath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh

- name: Find built asset on Windows x86
if: matrix.architecture == 'i386'
id: find_asset_x86
run: |
$assetPath = (Get-ChildItem -Path out/make -Recurse -Filter *.exe | Select-Object -First 1).FullName
$basename = [System.IO.Path]::GetFileNameWithoutExtension($assetPath)
$extension = [System.IO.Path]::GetExtension($assetPath)
$newBasename = ($basename -replace ' ', '-') + "-x86" + $extension
$newFilePath = (Join-Path -Path (Get-Item $assetPath).DirectoryName -ChildPath $newBasename)
Rename-Item -Path $assetPath -NewName $newBasename
$escapedFilePath = $newFilePath -replace '\\', '\\\\'
echo "ASSET_BASENAME=$newBasename" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "ASSET_PATH=$escapedFilePath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET_BASENAME }}
path: ${{ env.ASSET_PATH }}
overwrite: true

- name: Create and Upload Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag_name }}
name: ${{ env.ASSET_BASENAME }}
files: ${{ env.ASSET_PATH }}
token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
asar: true,
appBundleId: "io.github.pd4d10.debugtron",
icon: "assets/icon",
executableName: "debugtron"
},
makers: [
{ name: "@electron-forge/maker-squirrel", config: {} },
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"electron-squirrel-startup": "^1.0.0",
"registry-js": "^1.16.0",
"simple-plist": "^1.3.1",
"electron-redux": "2.0.0-alpha.9",
"uuid": "^9.0.1"
},
"devDependencies": {
Expand All @@ -50,7 +51,6 @@
"@types/uuid": "^9.0.8",
"electron": "^30.0.2",
"electron-devtools-installer": "^3.2.0",
"electron-redux": "2.0.0-alpha.9",
"electron-update-notification": "^0.1.0",
"get-port": "^7.1.0",
"ini": "^4.1.2",
Expand All @@ -71,6 +71,5 @@
"universal-analytics": "^0.5.3",
"vite": "^5.2.11"
},
"packageManager": "yarn@4.1.0+sha256.81a00df816059803e6b5148acf03ce313cad36b7f6e5af6efa040a15981a6ffb",
"productName": "Debugtron"
}

0 comments on commit 0b76e3d

Please sign in to comment.