QtScrcpy/.github/workflows/windows.yml
Barry 5e1cc1b44f feat: add cmake (#544)
* feat: cmake win

* fix: win bug

* feat: mac

* feat: mac

* feat: linux

* feat: remove old cmake

* fix: build bug

* feat: ci mac build

* feat: language

* feat: build win

* fix: win buid error

* fix: mac build error

* fix: mac publish error

* feat: test

* feat: remove ubuntu 16

* feat: cmake build on ubuntu

* fix: ubuntu build error

* feat: test

* fix: build error on ubuntu

* fix: build error

* fix: build error

* fix

* fix

* fix: 1

* fix: 2

* fix: 3

* f

* a

* b

* 1

Co-authored-by: 冉坤 <rankun@bytedance.com>
2022-01-09 15:43:52 +08:00

114 lines
No EOL
4.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Windows
# 触发规则详解 https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
on:
push:
paths:
- 'QtScrcpy/**'
- '!QtScrcpy/res/**'
- '.github/workflows/windows.yml'
- 'ci/win**'
pull_request:
paths:
- 'QtScrcpy/**'
- '!QtScrcpy/res/**'
- '.github/workflows/windows.yml'
- 'ci/win**'
jobs:
build:
name: Build
# windows-latest目前是windows server 2019
# windows server 2019安装的是vs2019windows server 2016安装的是vs2017
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: windows-2019
# 矩阵配置 https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
strategy:
matrix:
qt-ver: [5.15.1]
qt-arch: [win64_msvc2019_64, win32_msvc2019]
# 配置qt-arch的额外设置msvc-archqt-arch-install
include:
- qt-arch: win64_msvc2019_64
msvc-arch: x64
qt-arch-install: msvc2019_64
- qt-arch: win32_msvc2019
msvc-arch: x86
qt-arch-install: msvc2019
# job env,所有steps都可以访问
# 不同级别env详解 https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#env
# 使用表达式语法${{}}访问上下文 https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions
env:
target-name: QtScrcpy
vcvarsall-path: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat'
vcinstall-path: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC'
qt-install-path: ${{ github.workspace }}/${{ matrix.qt-ver }}
plantform-des: win
# 步骤
steps:
- name: Cache Qt
id: cache-qt
uses: actions/cache@v1
with:
path: ${{ env.qt-install-path }}/${{ matrix.qt-arch-install }}
key: ${{ runner.os }}/${{ matrix.qt-ver }}/${{ matrix.qt-arch }}
# 安装Qt
- name: Install Qt
# 使用外部action。这个action专门用来安装Qt
uses: jurplel/install-qt-action@v2.13.0
with:
# Version of Qt to install
version: ${{ matrix.qt-ver }}
# Target platform for build
target: desktop
# Architecture for Windows/Android
arch: ${{ matrix.qt-arch }}
cached: ${{ steps.cache-qt.outputs.cache-hit }}
# 拉取代码
- uses: actions/checkout@v1
with:
fetch-depth: 1
# 编译msvc
- name: Build MSVC
# shell介绍 https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell
shell: cmd
env:
ENV_VCVARSALL: ${{ env.vcvarsall-path }}
ENV_QT_PATH: ${{ env.qt-install-path }}
run: |
call python ci\generate-version.py
call "ci\win\build_for_win.bat" RelWithDebInfo ${{ matrix.msvc-arch }}
# 获取ref最后一个/后的内容
- name: Get the version
shell: bash
id: get-version
# ${ GITHUB_REF/refs\/tags\// }是linux shell ${}的变量替换语法
run: echo ::set-output name=version::${GITHUB_REF##*/}
# tag 打包
- name: Package
id: package
env:
ENV_VCVARSALL: ${{ env.vcvarsall-path }}
ENV_VCINSTALL: ${{ env.vcinstall-path }}
ENV_QT_PATH: ${{ env.qt-install-path }}
publish_name: ${{ env.target-name }}-${{ env.plantform-des }}-${{ matrix.msvc-arch }}-${{ steps.get-version.outputs.version }}
run: |
cmd.exe /c ci\win\publish_for_win.bat ${{ matrix.msvc-arch }} ..\build\${{ env.publish_name }}
# 打包zip
Compress-Archive -Path ci\build\${{ env.publish_name }} ci\build\${{ env.publish_name }}.zip
echo "::set-output name=package-name::${{ env.publish_name }}"
# 上传artifacts
# https://help.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts
- uses: actions/upload-artifact@v1
with:
name: ${{ steps.package.outputs.package-name }}.zip
path: ci\build\${{ steps.package.outputs.package-name }}
# Upload to release
- name: Upload Release
if: startsWith(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ci\build\${{ steps.package.outputs.package-name }}.zip
asset_name: ${{ steps.package.outputs.package-name }}.zip
tag: ${{ github.ref }}
overwrite: true