ci(build): optimize workflow

This commit is contained in:
Chenx Dust
2025-03-25 15:06:04 +08:00
parent b8cc697663
commit e08f14fb9c

View File

@@ -2,8 +2,9 @@ name: Build
on:
release:
types: [ published ]
types: [ created ]
push:
tags-ignore: [ 'v*' ]
pull_request:
workflow_dispatch:
inputs:
@@ -61,6 +62,7 @@ jobs:
- name: Download and copy files
env:
VCINSTALLDIR: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC'
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
run: |
mkdir "${{ env.DISPLAY_NAME }}"
cd "${{ env.DISPLAY_NAME }}"
@@ -76,6 +78,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
with:
name: ${{ env.ARCHIVE_NAME }}
path: ${{ env.ARCHIVE_NAME }}.zip
@@ -132,6 +135,7 @@ jobs:
- name: Download and copy files
env:
VCINSTALLDIR: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC'
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
run: |
mkdir "${{ env.DISPLAY_NAME }}"
cd "${{ env.DISPLAY_NAME }}"
@@ -147,6 +151,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
with:
name: ${{ env.ARCHIVE_NAME }}
path: ${{ env.ARCHIVE_NAME }}.zip
@@ -187,6 +192,7 @@ jobs:
cmake --build build --target ${{ env.TARGET_NAME }} --parallel $(nproc)
- name: Download and copy files
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
run: |
cp -R build/${{ env.TARGET_NAME }}.app .
curl -LO https://github.com/Mythologyli/zju-connect/releases/latest/download/zju-connect-darwin-amd64.zip
@@ -196,6 +202,7 @@ jobs:
macdeployqt ${{ env.TARGET_NAME }}.app
- name: Package dmg file
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
run: |
brew install create-dmg
mkdir dmg-build
@@ -210,6 +217,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
with:
name: ${{ env.ARCHIVE_NAME }}
path: ${{ env.ARCHIVE_NAME }}.dmg
@@ -250,6 +258,7 @@ jobs:
cmake --build build --target ${{ env.TARGET_NAME }} --parallel $(nproc)
- name: Download and copy files
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
run: |
cp -R build/${{ env.TARGET_NAME }}.app .
curl -LO https://github.com/Mythologyli/zju-connect/releases/latest/download/zju-connect-darwin-arm64.zip
@@ -259,6 +268,7 @@ jobs:
macdeployqt ${{ env.TARGET_NAME }}.app
- name: Package dmg file
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
run: |
brew install create-dmg
mkdir dmg-build
@@ -273,6 +283,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
with:
name: ${{ env.ARCHIVE_NAME }}
path: ${{ env.ARCHIVE_NAME }}.dmg
@@ -315,12 +326,13 @@ jobs:
- name: Restore cached openssl
id: cache-openssl
uses: actions/cache@v4
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
with:
path: openssl
key: ${{ runner.os }}-${{ runner.arch }}-openssl-${{ env.LINUX_OPENSSL_VERSION }}
- name: Build openssl
if: steps.cache-openssl.outputs.cache-hit != 'true'
if: (github.event_name == 'release' || github.event_name == 'workflow_dispatch') && steps.cache-openssl.outputs.cache-hit != 'true'
run: |
# For package in Ubuntu 20.04, we have to install openssl 3.
wget -O openssl.tar.gz https://www.openssl.org/source/openssl-${{ env.LINUX_OPENSSL_VERSION }}.tar.gz
@@ -332,6 +344,7 @@ jobs:
openssl version
- name: Download and copy files
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
run: |
sudo cp -R ${GITHUB_WORKSPACE}/openssl /usr/local/
echo '/usr/local/openssl/lib64' | sudo tee /etc/ld.so.conf.d/openssl.conf > /dev/null
@@ -369,6 +382,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
with:
name: ${{ env.ARCHIVE_NAME }}
path: ${{ env.ARCHIVE_NAME }}.AppImage
@@ -409,6 +423,7 @@ jobs:
cmake --build build --target ${{ env.TARGET_NAME }} --parallel $(nproc)
- name: Download and copy files
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
run: |
sudo apt install -y libxcb-cursor0 fuse
@@ -439,6 +454,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
with:
name: ${{ env.ARCHIVE_NAME }}
path: ${{ env.ARCHIVE_NAME }}.AppImage