build: 添加 Github Actions `.github/workflows/build-and-upload.yml`,用于自动打包上传安装包

pull/360/head
王良 2 months ago
parent 84187aaa41
commit 19976cd119

@ -0,0 +1,166 @@
name: "Build And Upload"
on:
release:
types: [ created ]
jobs:
# job 1
build-and-upload:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [
windows-latest,
ubuntu-latest,
macos-latest
]
node: [
16
]
lerna: [
6
]
steps:
# step 1.1
- uses: actions/checkout@v4.1.7
# step 1.2
- name: "Setup Node.js environment"
uses: actions/setup-node@v4.0.3
with:
node-version: ${{ matrix.node }}
registry-url: https://npm.pkg.github.com/
# step 1.3
- name: "Get package info"
id: package-info
uses: luizfelipelaviola/get-package-info@v1
with:
path: ./packages/mitmproxy
# step 1.4
- name: "Print"
run: |
echo "version = ${{ steps.package-info.outputs.version }}";
echo "github.event.release.upload_url = ${{ github.event.release.upload_url }}";
echo "ref = ${{ github.event.ref }}";
echo "tags = ${{ github.tags }}";
# step 1.5
- name: "npm install lerna/yarn"
run: |
echo "======================================================================";
dir || ls;
echo "======================================================================";
echo "npm install lerna@${{ matrix.lerna }} -g";
echo "----------";
npm install lerna@${{ matrix.lerna }} -g;
echo "======================================================================";
echo "npm install yarn";
echo "----------";
npm install yarn;
# step 1.6
- name: "npm -v | lerna -v | yarn -v"
run: |
echo "======================================================================";
echo "lerna -v";
echo "----------";
lerna -v;
echo "======================================================================";
echo "npm -v";
echo "----------";
npm -v;
echo "======================================================================";
echo "yarn -v";
echo "----------";
yarn -v;
# step 1.7
- name: "lerna bootstrap"
run: |
echo "======================================================================";
dir || ls;
echo "======================================================================";
echo "lerna bootstrap --npm-client=yarn";
echo "----------";
lerna bootstrap --npm-client=yarn;
# step 1.8
- name: "npm run electron:build"
run: |
echo "======================================================================";
dir || ls;
echo "======================================================================";
echo "cd packages/gui";
echo "----------";
cd packages/gui;
echo "======================================================================";
dir || ls;
echo "======================================================================";
echo "npm run electron:build";
echo "----------";
npm run electron:build;
echo "======================================================================";
cd dist_electron;
dir || ls;
cd ../../../;
# step 1.9
# -----------------------------------------
# step 1.9.1
- name: "Upload Asset DevSidecar.exe"
uses: actions/upload-release-asset@v1
if: ${{ github.event_name == 'release' && github.event.action == 'created' && matrix.os == 'windows-latest' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}.exe
asset_name: "DevSidecar-${{ steps.package-info.outputs.version }}.exe"
asset_content_type: application/x-msdownload
# step 1.9.2
- name: "Upload Asset DevSidecar.deb"
uses: actions/upload-release-asset@v1
if: ${{ github.event_name == 'release' && github.event.action == 'created' && matrix.os == 'ubuntu-latest' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}.deb
asset_name: "DevSidecar-${{ steps.package-info.outputs.version }}.deb"
asset_content_type: application/x-msdownload
# step 1.9.3
- name: "Upload Asset DevSidecar.AppImage"
uses: actions/upload-release-asset@v1
if: ${{ github.event_name == 'release' && github.event.action == 'created' && matrix.os == 'ubuntu-latest' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}.AppImage
asset_name: "DevSidecar-${{ steps.package-info.outputs.version }}.AppImage"
asset_content_type: application/x-msdownload
# step 1.9.4
- name: "Upload Asset DevSidecar.dmg "
uses: actions/upload-release-asset@v1
if: ${{ github.event_name == 'release' && github.event.action == 'created' && (matrix.os == 'macos-11' || matrix.os == 'macos-12' || matrix.os == 'macos-13' || matrix.os == 'macos-latest') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./packages/gui/dist_electron/DevSidecar-${{ steps.package-info.outputs.version }}.dmg
asset_name: "DevSidecar-${{ steps.package-info.outputs.version }}.dmg"
asset_content_type: application/x-msdownload

@ -55,6 +55,7 @@
"electron": "17.1.0", "electron": "17.1.0",
"electron-devtools-installer": "^3.1.0", "electron-devtools-installer": "^3.1.0",
"electron-icon-builder": "^2.0.1", "electron-icon-builder": "^2.0.1",
"electron-builder": "^23.0.3",
"eslint": "^6.7.2", "eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2", "eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",

Loading…
Cancel
Save