Skip to content

Commit

Permalink
feat: mac action (barry-ran#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
barry-ran authored Feb 22, 2020
1 parent c3e548a commit a6f516e
Show file tree
Hide file tree
Showing 21 changed files with 816 additions and 189 deletions.
124 changes: 124 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: MacOS
on:
push:
paths:
- 'QtScrcpy/**'
- '!QtScrcpy/res/**'
- '.github/workflows/**'
pull_request:
paths:
- 'QtScrcpy/**'
- '!QtScrcpy/res/**'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
qt_ver: [5.12.6]
qt_arch: [clang_64]
env:
targetName: QtScrcpy
steps:
- name: Cache Qt
id: MacosCacheQt
uses: actions/cache@v1
with:
path: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}}
key: ${{ runner.os }}-Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}}
- 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
if: steps.MacosCacheQt.outputs.cache-hit != 'true'
uses: jurplel/[email protected]
with:
version: ${{ matrix.qt_ver }}

- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Build MacOS
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
# tag 打包
- name: Package
id: package
if: startsWith(github.event.ref, 'refs/tags/')
shell: pwsh
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.app ci\build\${name}.zip
# 记录环境变量packageName给后续step
echo "::set-env name=packageName::$name"
# 打印环境变量packageName
Write-Host 'packageName:'${env:packageName}
# 查询Release
- name: Query Release
if: startsWith(github.event.ref, 'refs/tags/')
shell: pwsh
env:
githubFullName: ${{ github.event.repository.full_name }}
ref: ${{ github.event.ref }}
run: |
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
[string]$url = 'https://api.github.com/repos/' + ${env:githubFullName} + '/releases/tags/' + ${tag}
$response={}
try {
$response = Invoke-RestMethod -Uri $url -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 }}
run: |
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
[string]$url = 'https://api.github.com/repos/' + ${env:githubFullName} + '/releases/tags/' + ${tag}
$response = Invoke-RestMethod -Uri $url -Method Get
[string]$latestUpUrl = $response.upload_url
Write-Host 'latestUpUrl:'$latestUpUrl
echo "::set-env name=uploadUrl::$latestUpUrl"
Write-Host 'env uploadUrl:'${env:uploadUrl}
# tag 上传Release
- name: Upload Release
id: uploadRelease
if: startsWith(github.event.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/[email protected]
with:
upload_url: ${{ env.uploadUrl }}
asset_path: ci\build\${{ steps.package.env.packageName }}.zip
asset_name: ${{ steps.package.env.packageName }}.zip
asset_content_type: application/zip
149 changes: 149 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Windows
on:
# push代码时触发workflow
push:
paths:
- 'QtScrcpy/**'
- '!QtScrcpy/res/**'
- '.github/workflows/**'
# pull_request时触发workflow
pull_request:
paths:
- 'QtScrcpy/**'
- '!QtScrcpy/res/**'
jobs:
build:
name: Build
# 运行平台, windows-latest目前是windows server 2019,选择2016是2016安装的是vs2017
# https://github.com/actions/virtual-environments/blob/master/images/win/Windows2019-Readme.md
# https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
runs-on: windows-2016
strategy:
# 矩阵配置
matrix:
qt_ver: [5.12.6]
qt_target: [desktop]
# mingw用不了
# qt_arch: [win64_msvc2017_64, win32_msvc2017, win32_mingw53,win32_mingw73]
qt_arch: [win64_msvc2017_64, win32_msvc2017]
# 额外设置msvc_arch
include:
- qt_arch: win64_msvc2017_64
msvc_arch: x64
qt_arch_install: msvc2017_64
- qt_arch: win32_msvc2017
msvc_arch: x86
qt_arch_install: msvc2017
env:
targetName: QtScrcpy.exe
# 步骤
steps:
- name: Cache Qt
id: WindowsCacheQt
uses: actions/cache@v1
with:
path: ../../Qt5/${{matrix.qt_ver}}/${{matrix.qt_arch_install}}
key: ${{ runner.os }}-Qt5.12.6/${{matrix.qt_ver}}/${{matrix.qt_arch}}
- name: Setup Qt
if: steps.WindowsCacheQt.outputs.cache-hit == 'true'
shell: pwsh
env:
QtPath: ../../Qt5/${{matrix.qt_ver}}/${{matrix.qt_arch_install}}
run: |
$qt_Path=${env:QtPath}
echo "::set-env name=Qt5_Dir::$qt_Path"
echo "::add-path::$qt_Path/bin"
# 安装Qt
- name: Install Qt
if: steps.WindowsCacheQt.outputs.cache-hit != 'true'
# 使用外部action。这个action专门用来安装Qt
uses: jurplel/[email protected]
with:
# Version of Qt to install
version: ${{ matrix.qt_ver }}
# Target platform for build
target: ${{ matrix.qt_target }}
# Architecture for Windows/Android
arch: ${{ matrix.qt_arch }}
# 拉取代码
- uses: actions/checkout@v1
with:
fetch-depth: 1
# 编译msvc
- name: Build MSVC
shell: cmd
env:
ENV_VCVARSALL: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat'
ENV_QT_PATH: 'd:\a\Qt5\5.12.6'
run: |
call "ci\win\build_for_win.bat" release ${{ matrix.msvc_arch }}
# tag 打包
- name: Package
if: startsWith(github.event.ref, 'refs/tags/')
env:
publish_dir: QtScrcpy-win-${{matrix.msvc_arch}}
ref: ${{ github.event.ref }}
shell: pwsh
run: |
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
[string]$full_publish_dir = ${env:publish_dir} + '-' + ${tag}
cmd.exe /c ci\win\publish_for_win.bat ${{matrix.msvc_arch}} ..\build\$full_publish_dir
# 打包zip
Compress-Archive -Path ci\build\$full_publish_dir ci\build\${full_publish_dir}.zip
# 记录环境变量packageName给后续step
$name = $full_publish_dir
echo "::set-env name=packageName::$name"
# 打印环境变量packageName
Write-Host 'packageName:'${env:packageName}
# 查询Release
- name: Query Release
if: startsWith(github.event.ref, 'refs/tags/')
shell: pwsh
env:
githubFullName: ${{ github.event.repository.full_name }}
ref: ${{ github.event.ref }}
run: |
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
[string]$url = 'https://api.github.com/repos/' + ${env:githubFullName} + '/releases/tags/' + ${tag}
$response={}
try {
$response = Invoke-RestMethod -Uri $url -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 }}
run: |
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
[string]$url = 'https://api.github.com/repos/' + ${env:githubFullName} + '/releases/tags/' + ${tag}
$response = Invoke-RestMethod -Uri $url -Method Get
[string]$latestUpUrl = $response.upload_url
Write-Host 'latestUpUrl:'$latestUpUrl
echo "::set-env name=uploadUrl::$latestUpUrl"
Write-Host 'env uploadUrl:'${env:uploadUrl}
# tag 上传Release
- name: Upload Release
id: uploadRelease
if: startsWith(github.event.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/[email protected]
with:
upload_url: ${{ env.uploadUrl }}
asset_path: ci\build\${{ env.packageName }}.zip
asset_name: ${{ env.packageName }}.zip
asset_content_type: application/zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
/build/
build-*
*.DS_Store
userdata.ini
2 changes: 1 addition & 1 deletion QtScrcpy/QtScrcpy.pro
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ macos {
QMAKE_BUNDLE_DATA += APP_FFMPEG

APP_CONFIG.files = $$files($$PWD/../config/config.ini)
APP_CONFIG.path = Contents/MacOS
APP_CONFIG.path = Contents/MacOS/config
QMAKE_BUNDLE_DATA += APP_CONFIG

# mac application icon
Expand Down
22 changes: 19 additions & 3 deletions QtScrcpy/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,22 @@ void Dialog::initUI()
ui->bitRateBox->addItem("6000000");
ui->bitRateBox->addItem("8000000");
ui->bitRateBox->addItem("10000000");
ui->bitRateBox->setCurrentIndex(2);
ui->bitRateBox->setCurrentIndex(Config::getInstance().getBitRateIndex());

ui->maxSizeBox->addItem("640");
ui->maxSizeBox->addItem("720");
ui->maxSizeBox->addItem("1080");
ui->maxSizeBox->addItem("1280");
ui->maxSizeBox->addItem("1920");
ui->maxSizeBox->addItem(tr("original"));
ui->maxSizeBox->setCurrentIndex(2);
ui->maxSizeBox->setCurrentIndex(Config::getInstance().getMaxSizeIndex());

ui->formatBox->addItem("mp4");
ui->formatBox->addItem("mkv");
ui->formatBox->setCurrentIndex(Config::getInstance().getRecordFormatIndex());

ui->recordPathEdt->setText(Config::getInstance().getRecordPath());
}
}

void Dialog::execAdbCmd()
{
Expand Down Expand Up @@ -358,3 +359,18 @@ void Dialog::on_recordScreenCheck_clicked(bool checked)
ui->recordScreenCheck->setChecked(false);
}
}

void Dialog::on_bitRateBox_activated(int index)
{
Config::getInstance().setBitRateIndex(index);
}

void Dialog::on_maxSizeBox_activated(int index)
{
Config::getInstance().setMaxSizeIndex(index);
}

void Dialog::on_formatBox_activated(int index)
{
Config::getInstance().setRecordFormatIndex(index);
}
6 changes: 6 additions & 0 deletions QtScrcpy/dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ private slots:

void on_recordScreenCheck_clicked(bool checked);

void on_bitRateBox_activated(int index);

void on_maxSizeBox_activated(int index);

void on_formatBox_activated(int index);

private:
bool checkAdbRun();
void initUI();
Expand Down
5 changes: 3 additions & 2 deletions QtScrcpy/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ int main(int argc, char *argv[])
qputenv("QTSCRCPY_ADB_PATH", "../../../../third_party/adb/win/adb.exe");
qputenv("QTSCRCPY_SERVER_PATH", "../../../../third_party/scrcpy-server");
qputenv("QTSCRCPY_KEYMAP_PATH", "../../../../keymap");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../../config/config.ini");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../../config");
#endif

#ifdef Q_OS_LINUX
qputenv("QTSCRCPY_ADB_PATH", "../../../third_party/adb/linux/adb");
qputenv("QTSCRCPY_SERVER_PATH", "../../../third_party/scrcpy-server");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../config/config.ini");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../config");
#endif

//加载样式表
Expand All @@ -77,6 +77,7 @@ int main(int argc, char *argv[])
g_mainDlg->setWindowTitle(Config::getInstance().getTitle());
g_mainDlg->show();

qInfo(QObject::tr("This software is completely open source and free, you can download it at the following address:").toUtf8());
qInfo(QString("QtScrcpy %1 <https://github.com/barry-ran/QtScrcpy>").arg(QCoreApplication::applicationVersion()).toUtf8());

int ret = a.exec();
Expand Down
Binary file modified QtScrcpy/res/i18n/QtScrcpy_en.qm
Binary file not shown.
10 changes: 9 additions & 1 deletion QtScrcpy/res/i18n/QtScrcpy_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</message>
<message>
<location filename="../../dialog.ui" line="144"/>
<location filename="../../dialog.cpp" line="293"/>
<location filename="../../dialog.cpp" line="294"/>
<source>select path</source>
<translation>select path</translation>
</message>
Expand Down Expand Up @@ -203,6 +203,14 @@
<translation>original</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../../main.cpp" line="80"/>
<source>This software is completely open source and free, you can download it at the following address:</source>
<translation>This software is completely open source and free, you can download it at the following address:</translation>
</message>
</context>
<context>
<name>ToolForm</name>
<message>
Expand Down
Binary file modified QtScrcpy/res/i18n/QtScrcpy_zh.qm
Binary file not shown.
Loading

0 comments on commit a6f516e

Please sign in to comment.