Skip to content

Revert "optimize: 优化 Github Actions,升级 luizfelipelaviola/get-package-… #321

Revert "optimize: 优化 Github Actions,升级 luizfelipelaviola/get-package-…

Revert "optimize: 优化 Github Actions,升级 luizfelipelaviola/get-package-… #321

name: Test And Upload
on:
push:
branches:
- master
- 1.x
- test
pull_request:
branches:
- master
- 1.x
jobs:
test-and-upload:
runs-on: ${{ matrix.os }}-latest
env:
ELECTRON_CACHE: ${{ github.workspace }}/.cache/electron
ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder
strategy:
fail-fast: false
matrix:
os:
- windows
- ubuntu
- macos
node:
- 22
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: 'Setup Node.js "${{ matrix.node }}.x" environment'
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
registry-url: https://npm.pkg.github.com/
cache: pnpm
- name: Setup Python environment (Mac) Because of electron-builder install-app-deps requires Python setup tools
if: matrix.os == 'macos'
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Get package info
id: package-info
uses: luizfelipelaviola/get-package-info@v1
with:
path: ./packages/mitmproxy
- name: Print
run: |
echo "version = ${{ steps.package-info.outputs.version }}";
echo "github.ref_type = ${{ github.ref_type }}";
echo "github.ref = ${{ github.ref }}";
echo "github.ref_name = ${{ github.ref_name }}";
- name: 'npm -v | pnpm -v | python --version'
run: |
echo "======================================================================";
echo "npm -v";
echo "--------------------";
npm -v;
echo "======================================================================";
echo "pnpm -v";
echo "--------------------";
pnpm -v;
echo "======================================================================";
echo "python --version";
echo "--------------------";
python --version;
- name: Setup electron cahce
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.cache/electron
key: ${{ runner.os }}-electron-cache-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-electron-cache-
- name: Setup electron-builder cahce
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.cache/electron-builder
key: ${{ runner.os }}-electron-builder-cache-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-electron-builder-cache-
- name: "'pnpm install --force' Because we need to install optional dependencies"
run: |
echo "======================================================================";
dir || ls -lah;
echo "======================================================================";
echo "pnpm install";
echo "--------------------";
pnpm install;
- name: 'npm run electron:build'
run: |
echo "======================================================================";
echo "cd packages/gui";
echo "--------------------";
cd packages/gui;
dir || ls -lah;
echo "======================================================================";
echo "npm run electron:build";
echo "--------------------";
npm run electron:build;
- name: 'Print dir "packages/gui/dist_electron/"'
run: |
echo "======================================================================";
echo "cd packages/gui/dist_electron";
echo "--------------------";
cd packages/gui/dist_electron;
dir || ls -lah;
# Rename artifacts
- name: 'Rename artifacts - Windows'
if: ${{ matrix.os == 'windows' }}
run: |
cd packages/gui/dist_electron;
ren DevSidecar-${{ steps.package-info.outputs.version }}-ia32.exe DevSidecar-${{ steps.package-info.outputs.version }}-windows-ia32.exe;
ren DevSidecar-${{ steps.package-info.outputs.version }}-x64.exe DevSidecar-${{ steps.package-info.outputs.version }}-windows-x64.exe;
ren DevSidecar-${{ steps.package-info.outputs.version }}-arm64.exe DevSidecar-${{ steps.package-info.outputs.version }}-windows-arm64.exe;
dir;
- name: 'Rename artifacts - Linux'
if: ${{ matrix.os == 'ubuntu' }}
run: |
cd packages/gui/dist_electron;
mv DevSidecar-${{ steps.package-info.outputs.version }}-amd64.deb DevSidecar-${{ steps.package-info.outputs.version }}-linux-amd64.deb;
mv DevSidecar-${{ steps.package-info.outputs.version }}-arm64.deb DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.deb;
mv DevSidecar-${{ steps.package-info.outputs.version }}-x86_64.AppImage DevSidecar-${{ steps.package-info.outputs.version }}-linux-x86_64.AppImage;
mv DevSidecar-${{ steps.package-info.outputs.version }}-arm64.AppImage DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.AppImage;
ls -lah;
- name: 'Rename artifacts - macOS'
if: ${{ matrix.os == 'macos' }}
run: |
cd packages/gui/dist_electron;
mv DevSidecar-${{ steps.package-info.outputs.version }}-universal.dmg DevSidecar-${{ steps.package-info.outputs.version }}-macos-universal.dmg;
ls -lah;
#region Upload artifacts - Windows
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-windows-ia32.exe'
uses: actions/upload-artifact@v4.4.0
if: ${{ matrix.os == 'windows' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-windows-ia32.exe
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-windows-ia32.exe'
if-no-files-found: error
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-windows-x64.exe'
uses: actions/upload-artifact@v4.4.0
if: ${{ matrix.os == 'windows' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-windows-x64.exe
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-windows-x64.exe'
if-no-files-found: error
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-windows-arm64.exe'
uses: actions/upload-artifact@v4.4.0
if: ${{ matrix.os == 'windows' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-windows-arm64.exe
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-windows-arm64.exe'
if-no-files-found: error
#endregion Upload artifacts - Windows
#region Upload artifacts - Linux
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-linux-amd64.deb'
uses: actions/upload-artifact@v4.4.0
if: ${{ matrix.os == 'ubuntu' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-linux-amd64.deb
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-amd64.deb'
if-no-files-found: error
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.deb'
uses: actions/upload-artifact@v4.4.0
if: ${{ matrix.os == 'ubuntu' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.deb
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.deb'
if-no-files-found: error
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-linux-x86_64.AppImage'
uses: actions/upload-artifact@v4.4.0
if: ${{ matrix.os == 'ubuntu' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-linux-x86_64.AppImage
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-x86_64.AppImage'
if-no-files-found: error
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.AppImage'
uses: actions/upload-artifact@v4.4.0
if: ${{ matrix.os == 'ubuntu' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.AppImage
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-linux-arm64.AppImage'
if-no-files-found: error
#endregion Upload artifacts - Linux
# Upload artifacts - macOS
- name: 'Upload DevSidecar-${{ steps.package-info.outputs.version }}-macos-universal.dmg'
uses: actions/upload-artifact@v4.4.0
if: ${{ matrix.os == 'macos' }}
with:
path: packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}-macos-universal.dmg
name: 'DevSidecar-${{ steps.package-info.outputs.version }}-macos-universal.dmg'
if-no-files-found: error