-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from barry-ran/dev
Dev
- Loading branch information
Showing
10 changed files
with
135 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,133 +13,65 @@ on: | |
jobs: | ||
build: | ||
name: Build | ||
runs-on: ${{ matrix.os }} | ||
runs-on: macos-latest | ||
strategy: | ||
matrix: | ||
os: [macos-latest] | ||
qt_ver: [5.12.6] | ||
qt_arch: [clang_64] | ||
qt-ver: [5.12.6] | ||
qt-arch-install: [clang_64] | ||
clang-arch: [x64] | ||
env: | ||
targetName: QtScrcpy | ||
target-name: QtScrcpy | ||
qt-install-path: ${{ github.workspace }}/${{ matrix.qt-ver }} | ||
plantform-des: mac | ||
steps: | ||
- name: Cache Qt | ||
id: MacosCacheQt | ||
id: cache-qt | ||
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" | ||
path: ${{ env.qt-install-path }}/${{ matrix.qt-arch-install }} | ||
key: ${{ runner.os }}/${{ matrix.qt-ver }}/${{ matrix.qt-arch-install }} | ||
- name: Install Qt | ||
if: steps.MacosCacheQt.outputs.cache-hit != 'true' | ||
uses: jurplel/[email protected] | ||
with: | ||
version: ${{ matrix.qt_ver }} | ||
|
||
version: ${{ matrix.qt-ver }} | ||
cached: ${{ steps.cache-qt.outputs.cache-hit }} | ||
- 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 | ||
ci/mac/package_for_mac.sh | ||
# tag 打包 | ||
- name: 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.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=("barry-ran {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_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 | ||
id: package | ||
env: | ||
githubFullName: ${{ github.event.repository.full_name }} | ||
ref: ${{ github.event.ref }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
ENV_QT_PATH: ${{ env.qt-install-path }} | ||
publish_name: ${{ env.target-name }}-${{ env.plantform-des }}-${{ matrix.clang-arch }}-${{ steps.get-version.outputs.version }} | ||
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=("barry-ran {0}" -f $authInfo)} | ||
$response = Invoke-RestMethod -Uri $url -ContentType 'text/json' -Headers $headers -Method Get | ||
[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 | ||
ci/mac/publish_for_mac.sh ../build | ||
ci/mac/package_for_mac.sh | ||
mv ci/build/QtScrcpy.app ci/build/${{ env.publish_name }}.app | ||
mv ci/build/QtScrcpy.dmg ci/build/${{ env.publish_name }}.dmg | ||
echo "::set-output name=package-name::${{ env.publish_name }}" | ||
- uses: actions/upload-artifact@v1 | ||
with: | ||
name: ${{ steps.package.outputs.package-name }}.zip | ||
path: ci/build/${{ steps.package.outputs.package-name }}.app | ||
# Upload to release | ||
- name: Upload Release | ||
id: uploadRelease | ||
if: startsWith(github.event.ref, 'refs/tags/') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
uses: actions/[email protected] | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: svenstaro/upload-release-action@v1-release | ||
with: | ||
upload_url: ${{ env.uploadUrl }} | ||
asset_path: ci/build/${{ env.packageName }}.zip | ||
asset_name: ${{ env.packageName }}.zip | ||
asset_content_type: application/zip | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: ci/build/${{ steps.package.outputs.package-name }}.dmg | ||
asset_name: ${{ steps.package.outputs.package-name }}.dmg | ||
tag: ${{ github.ref }} | ||
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,35 +18,31 @@ jobs: | |
strategy: | ||
matrix: | ||
os: [ubuntu-16.04,ubuntu-18.04] | ||
qt_ver: [5.12.6] | ||
qt_arch: [gcc_64] | ||
qt-ver: [5.12.6] | ||
qt-arch-install: [gcc_64] | ||
gcc-arch: [x64] | ||
env: | ||
target-name: QtScrcpy | ||
qt-install-path: ${{ github.workspace }}/${{ matrix.qt-ver }} | ||
plantform-des: ubuntu | ||
steps: | ||
- name: Cache Qt | ||
id: UbuntuCacheQt | ||
id: cache-qt | ||
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.UbuntuCacheQt.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" | ||
path: ${{ env.qt-install-path }}/${{ matrix.qt-arch-install }} | ||
key: ${{ runner.os }}/${{ matrix.qt-ver }}/${{ matrix.qt-arch-install }} | ||
- name: Install Qt | ||
if: steps.UbuntuCacheQt.outputs.cache-hit != 'true' | ||
uses: jurplel/[email protected] | ||
with: | ||
version: ${{ matrix.qt_ver }} | ||
version: ${{ matrix.qt-ver }} | ||
cached: ${{ steps.cache-qt.outputs.cache-hit }} | ||
- name: Ubuntu install GL library | ||
run: sudo apt-get install -y libglew-dev libglfw3-dev | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- name: Build Ubuntu | ||
run: | | ||
export ENV_QT_GCC=$(pwd)/${{env.Qt5_Dir}} | ||
ci/linux/build_for_ubuntu.sh release | ||
env: | ||
ENV_QT_PATH: ${{ env.qt-install-path }} | ||
run: ci/linux/build_for_ubuntu.sh release |
Oops, something went wrong.