mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-03 06:08:39 +00:00
chore: update windows and mac yml
This commit is contained in:
parent
d4c7279fbf
commit
2e17ba8355
4 changed files with 58 additions and 125 deletions
156
.github/workflows/macos.yml
vendored
156
.github/workflows/macos.yml
vendored
|
@ -13,135 +13,65 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: macos-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest]
|
qt-ver: [5.12.6]
|
||||||
qt_ver: [5.12.6]
|
qt-target: [desktop]
|
||||||
qt_arch: [clang_64]
|
qt-arch-install: clang_64
|
||||||
|
clang-arch: x64
|
||||||
env:
|
env:
|
||||||
targetName: QtScrcpy
|
target-name: QtScrcpy
|
||||||
|
qt-install-path: ${{ github.workspace }}/${{ matrix.qt-ver }}
|
||||||
|
plantform-des: mac
|
||||||
steps:
|
steps:
|
||||||
- name: Cache Qt
|
- name: Cache Qt
|
||||||
id: MacosCacheQt
|
id: cache-qt
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}}
|
path: ${{ env.qt-install-path }}/${{ matrix.qt-arch-install }}
|
||||||
key: ${{ runner.os }}-Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}}
|
key: ${{ runner.os }}/${{ matrix.qt-ver }}/${{ matrix.qt-arch-install }}
|
||||||
- name: Setup Qt
|
|
||||||
if: steps.MacosCacheQt.outputs.cache-hit == 'true'
|
|
||||||
shell: pwsh
|
|
||||||
env:
|
|
||||||
QtPath: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}}
|
|
||||||
run: |
|
|
||||||
$qt_Path=${env:QtPath}
|
|
||||||
echo "::set-env name=Qt5_Dir::$qt_Path"
|
|
||||||
echo "::add-path::$qt_Path/bin"
|
|
||||||
- name: Install Qt
|
- name: Install Qt
|
||||||
if: steps.MacosCacheQt.outputs.cache-hit != 'true'
|
|
||||||
uses: jurplel/install-qt-action@v2.0.0
|
uses: jurplel/install-qt-action@v2.0.0
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.qt_ver }}
|
version: ${{ matrix.qt-ver }}
|
||||||
|
cached: ${{ steps.cache-qt.outputs.cache-hit }}
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
# 编译
|
# 编译
|
||||||
- name: Build MacOS
|
- name: Build MacOS
|
||||||
|
env:
|
||||||
|
ENV_QT_PATH: ${{ env.qt-install-path }}
|
||||||
|
run: ci/mac/build_for_mac.sh release
|
||||||
|
# 获取ref最后一个/后的内容
|
||||||
|
- name: Get the version
|
||||||
|
shell: bash
|
||||||
|
id: get-version
|
||||||
|
# ${ GITHUB_REF/refs\/tags\// }是linux shell ${}的变量替换语法
|
||||||
|
run: echo ::set-output name=version::${GITHUB_REF##*/}
|
||||||
|
# 打包
|
||||||
|
- name: Package
|
||||||
|
env:
|
||||||
|
ENV_QT_PATH: ${{ env.qt-install-path }}
|
||||||
|
publish_name: ${{ env.target-name }}-${{ env.plantform-des }}-${{ matrix.clang-arch }}-${{ steps.get-version.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
export ENV_QT_CLANG=$(pwd)/${{env.Qt5_Dir}}
|
|
||||||
ci/mac/build_for_mac.sh release
|
|
||||||
# 发布
|
|
||||||
- name: Publish
|
|
||||||
if: startsWith(github.event.ref, 'refs/tags/')
|
|
||||||
run: |
|
|
||||||
export ENV_QT_CLANG=$(pwd)/${{env.Qt5_Dir}}
|
|
||||||
ci/mac/publish_for_mac.sh ../build
|
ci/mac/publish_for_mac.sh ../build
|
||||||
ci/mac/package_for_mac.sh
|
ci/mac/package_for_mac.sh
|
||||||
# tag 打包
|
mv ci/build/QtScrcpy.app ci/build/${{ publish_name }}.app
|
||||||
- name: Package
|
mv ci/build/QtScrcpy.dmg ci/build/${{ publish_name }}.dmg
|
||||||
if: startsWith(github.event.ref, 'refs/tags/')
|
echo "::set-env name=artifact-name::${{ env.publish_name }}.app"
|
||||||
shell: pwsh
|
- uses: actions/upload-artifact@v1
|
||||||
env:
|
|
||||||
ref: ${{ github.event.ref }}
|
|
||||||
run: |
|
|
||||||
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
|
|
||||||
[string]$name = 'QtScrcpy-mac-x64-' + ${tag}
|
|
||||||
# 打包zip
|
|
||||||
Compress-Archive -Path ci\build\QtScrcpy.dmg ci\build\${name}.zip
|
|
||||||
# 查询Release
|
|
||||||
- name: Query Release
|
|
||||||
if: startsWith(github.event.ref, 'refs/tags/')
|
|
||||||
shell: pwsh
|
|
||||||
env:
|
|
||||||
githubFullName: ${{ github.event.repository.full_name }}
|
|
||||||
ref: ${{ github.event.ref }}
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
|
|
||||||
[string]$url = 'https://api.github.com/repos/' + ${env:githubFullName} + '/releases/tags/' + ${tag}
|
|
||||||
|
|
||||||
$token = ${env:github_token}
|
|
||||||
$authInfo = ("{0}" -f $token)
|
|
||||||
$authInfo = [System.Text.Encoding]::UTF8.GetBytes($authInfo)
|
|
||||||
$authInfo = [System.Convert]::ToBase64String($authInfo)
|
|
||||||
$headers = @{Authorization=("${env:GITHUB_ACTOR} {0}" -f $authInfo)}
|
|
||||||
|
|
||||||
$response={}
|
|
||||||
try {
|
|
||||||
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
|
|
||||||
} catch {
|
|
||||||
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
|
|
||||||
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
|
|
||||||
# 没查到
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
[string]$latestUpUrl = $response.upload_url
|
|
||||||
Write-Host 'latestUpUrl:'$latestUpUrl
|
|
||||||
if ($latestUpUrl.Length -eq 0) {
|
|
||||||
# 没查到
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
# 获取上传url
|
|
||||||
- name: Get Release Url
|
|
||||||
if: startsWith(github.event.ref, 'refs/tags/')
|
|
||||||
shell: pwsh
|
|
||||||
env:
|
|
||||||
githubFullName: ${{ github.event.repository.full_name }}
|
|
||||||
ref: ${{ github.event.ref }}
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
|
|
||||||
[string]$url = 'https://api.github.com/repos/' + ${env:githubFullName} + '/releases/tags/' + ${tag}
|
|
||||||
|
|
||||||
# github token防止api rate limite,否则一个小时只能60个api请求
|
|
||||||
$token = ${env:github_token}
|
|
||||||
$authInfo = ("{0}" -f $token)
|
|
||||||
$authInfo = [System.Text.Encoding]::UTF8.GetBytes($authInfo)
|
|
||||||
$authInfo = [System.Convert]::ToBase64String($authInfo)
|
|
||||||
$headers = @{Authorization=("${env:GITHUB_ACTOR} {0}" -f $authInfo)}
|
|
||||||
|
|
||||||
$response = Invoke-RestMethod -Uri $url -ContentType 'text/json' -Headers $headers -Method Get
|
|
||||||
Write-Host 'headers:'$headers
|
|
||||||
Write-Host 'response:'$response
|
|
||||||
[string]$latestUpUrl = $response.upload_url
|
|
||||||
Write-Host 'latestUpUrl:'$latestUpUrl
|
|
||||||
echo "::set-env name=uploadUrl::$latestUpUrl"
|
|
||||||
Write-Host 'env uploadUrl:'${env:uploadUrl}
|
|
||||||
[string]$name = 'QtScrcpy-mac-x64-' + ${tag}
|
|
||||||
# 记录环境变量packageName给后续step
|
|
||||||
echo "::set-env name=packageName::$name"
|
|
||||||
# 打印环境变量packageName
|
|
||||||
Write-Host 'packageName:'${env:packageName}
|
|
||||||
# tag 上传Release
|
|
||||||
- name: Upload Release
|
|
||||||
id: uploadRelease
|
|
||||||
if: startsWith(github.event.ref, 'refs/tags/')
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
uses: actions/upload-release-asset@v1.0.1
|
|
||||||
with:
|
with:
|
||||||
upload_url: ${{ env.uploadUrl }}
|
name: ${{ env.artifact-name }}.zip
|
||||||
asset_path: ci/build/${{ env.packageName }}.zip
|
path: ci\build\${{ env.artifact-name }}
|
||||||
asset_name: ${{ env.packageName }}.zip
|
# Upload to release
|
||||||
asset_content_type: application/zip
|
- 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\${{ env.publish_name }}.dmg
|
||||||
|
asset_name: ${{ env.publish_name }}.dmg
|
||||||
|
tag: ${{ github.ref }}
|
||||||
|
overwrite: true
|
15
.github/workflows/windows.yml
vendored
15
.github/workflows/windows.yml
vendored
|
@ -82,17 +82,18 @@ jobs:
|
||||||
# tag 打包
|
# tag 打包
|
||||||
- name: Package
|
- name: Package
|
||||||
env:
|
env:
|
||||||
publish_dir: ${{ env.target-name }}-${{ env.plantform-des }}-${{ matrix.msvc-arch }}-${{ steps.get-version.outputs.version }}
|
ENV_QT_PATH: ${{ env.qt-install-path }}
|
||||||
|
publish_name: ${{ env.target-name }}-${{ env.plantform-des }}-${{ matrix.msvc-arch }}-${{ steps.get-version.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
cmd.exe /c ci\win\publish_for_win.bat ${{ matrix.msvc-arch }} ..\build\${{ env.publish_dir }}
|
cmd.exe /c ci\win\publish_for_win.bat ${{ matrix.msvc-arch }} ..\build\${{ env.publish_name }}
|
||||||
# 打包zip
|
# 打包zip
|
||||||
Compress-Archive -Path ci\build\${{ env.publish_dir }} ci\build\${{ env.publish_dir }}.zip
|
Compress-Archive -Path ci\build\${{ env.publish_name }} ci\build\${{ env.publish_name }}.zip
|
||||||
echo "::set-env name=artifact-name::${{ env.publish_dir }}"
|
echo "::set-env name=artifact-name::${{ env.publish_name }}"
|
||||||
# 上传artifacts
|
# 上传artifacts
|
||||||
# https://help.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts
|
# https://help.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts
|
||||||
- uses: actions/upload-artifact@v1
|
- uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: ${{ env.artifact-name }}
|
name: ${{ env.artifact-name }}.zip
|
||||||
path: ci\build\${{ env.artifact-name }}
|
path: ci\build\${{ env.artifact-name }}
|
||||||
# Upload to release
|
# Upload to release
|
||||||
- name: Upload Release
|
- name: Upload Release
|
||||||
|
@ -100,7 +101,7 @@ jobs:
|
||||||
uses: svenstaro/upload-release-action@v1-release
|
uses: svenstaro/upload-release-action@v1-release
|
||||||
with:
|
with:
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
file: ci\build\${{ env.publish_dir }}.zip
|
file: ci\build\${{ env.publish_name }}.zip
|
||||||
asset_name: ${{ env.publish_dir }}.zip
|
asset_name: ${{ env.publish_name }}.zip
|
||||||
tag: ${{ github.ref }}
|
tag: ${{ github.ref }}
|
||||||
overwrite: true
|
overwrite: true
|
|
@ -6,8 +6,9 @@ echo check ENV
|
||||||
echo ---------------------------------------------------------------
|
echo ---------------------------------------------------------------
|
||||||
|
|
||||||
# 从环境变量获取必要参数
|
# 从环境变量获取必要参数
|
||||||
# 例如 /Users/barry/Qt5.12.5/5.12.5/clang_64
|
# 例如 /Users/barry/Qt5.12.5/5.12.5
|
||||||
echo ENV_QT_CLANG $ENV_QT_CLANG
|
echo ENV_QT_PATH $ENV_QT_PATH
|
||||||
|
qt_clang_path=$ENV_QT_PATH/clang_64
|
||||||
|
|
||||||
# 获取绝对路径,保证其他目录执行此脚本依然正确
|
# 获取绝对路径,保证其他目录执行此脚本依然正确
|
||||||
{
|
{
|
||||||
|
@ -39,7 +40,7 @@ fi
|
||||||
echo current build mode: $build_mode
|
echo current build mode: $build_mode
|
||||||
|
|
||||||
# 环境变量设置
|
# 环境变量设置
|
||||||
export PATH=$ENV_QT_CLANG/bin:$PATH
|
export PATH=$qt_clang_path/bin:$PATH
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
|
|
|
@ -6,7 +6,8 @@ echo ---------------------------------------------------------------
|
||||||
|
|
||||||
# 从环境变量获取必要参数
|
# 从环境变量获取必要参数
|
||||||
# 例如 /Users/barry/Qt5.12.5/5.12.5
|
# 例如 /Users/barry/Qt5.12.5/5.12.5
|
||||||
echo ENV_QT_CLANG $ENV_QT_CLANG
|
echo ENV_QT_PATH $ENV_QT_PATH
|
||||||
|
qt_clang_path=$ENV_QT_PATH/clang_64
|
||||||
|
|
||||||
# 获取绝对路径,保证其他目录执行此脚本依然正确
|
# 获取绝对路径,保证其他目录执行此脚本依然正确
|
||||||
{
|
{
|
||||||
|
@ -31,7 +32,7 @@ keymap_path=$script_path/../../keymap
|
||||||
publish_path=$script_path/$publish_dir
|
publish_path=$script_path/$publish_dir
|
||||||
release_path=$script_path/../../output/mac/release
|
release_path=$script_path/../../output/mac/release
|
||||||
|
|
||||||
export PATH=$ENV_QT_CLANG/bin:$PATH
|
export PATH=$qt_clang_path/bin:$PATH
|
||||||
|
|
||||||
if [ -d "$publish_path" ]; then
|
if [ -d "$publish_path" ]; then
|
||||||
rm -rf $publish_path
|
rm -rf $publish_path
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue