mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-21 20:15:04 +00:00
feat: mac package dmg
This commit is contained in:
parent
905880530f
commit
4f013e58b5
6 changed files with 117 additions and 3 deletions
17
.github/workflows/macos.yml
vendored
17
.github/workflows/macos.yml
vendored
|
@ -46,15 +46,18 @@ jobs:
|
|||
- 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/')
|
||||
|
@ -65,7 +68,7 @@ jobs:
|
|||
[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
|
||||
Compress-Archive -Path ci\build\QtScrcpy.dmg ci\build\${name}.zip
|
||||
# 查询Release
|
||||
- name: Query Release
|
||||
if: startsWith(github.event.ref, 'refs/tags/')
|
||||
|
@ -73,12 +76,20 @@ jobs:
|
|||
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 -Method Get
|
||||
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
|
||||
} catch {
|
||||
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
|
||||
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
|
||||
|
@ -102,12 +113,14 @@ jobs:
|
|||
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
|
||||
|
|
10
.github/workflows/windows.yml
vendored
10
.github/workflows/windows.yml
vendored
|
@ -103,12 +103,20 @@ jobs:
|
|||
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 -Method Get
|
||||
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
|
||||
} catch {
|
||||
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
|
||||
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
|
||||
|
|
BIN
ci/mac/package/dmg-background.jpg
Normal file
BIN
ci/mac/package/dmg-background.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
55
ci/mac/package/package.py
Normal file
55
ci/mac/package/package.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
import dmgbuild
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
|
||||
current_file_path = os.path.dirname(os.path.realpath(__file__))
|
||||
dmg_settings_path = '%s/dmg-settings.json' % current_file_path
|
||||
dmg_background_img = '%s/dmg-background.jpg' % current_file_path
|
||||
app_path = '%s/../../build/QtScrcpy.app' % current_file_path
|
||||
dmg_path = '%s/../../build/QtScrcpy.dmg' % current_file_path
|
||||
app_name = 'QtScrcpy'
|
||||
|
||||
def console_print(msg):
|
||||
print(msg)
|
||||
sys.stdout.flush()
|
||||
|
||||
def generate_dmg_info():
|
||||
with open(dmg_settings_path, 'w') as file:
|
||||
info = {
|
||||
'title': app_name,
|
||||
'icon-size': 120,
|
||||
'background': dmg_background_img,
|
||||
'format': 'UDZO',
|
||||
'compression-level': 9,
|
||||
'window': {
|
||||
'position': {'x': 400, 'y': 200},
|
||||
'size': {'width': 780, 'height': 480}
|
||||
},
|
||||
'contents': [
|
||||
{
|
||||
'x': 223,
|
||||
'y': 227,
|
||||
'type': 'file',
|
||||
'path': app_path
|
||||
},
|
||||
{
|
||||
'x': 550,
|
||||
'y': 227,
|
||||
'type': 'link',
|
||||
'path': '/Applications'
|
||||
}
|
||||
]
|
||||
}
|
||||
json.dump(info, file)
|
||||
|
||||
if __name__ == '__main__':
|
||||
console_print('generate dmg info')
|
||||
generate_dmg_info()
|
||||
console_print('build dmg: %s' % dmg_path)
|
||||
dmgbuild.build_dmg(dmg_path, app_name, dmg_settings_path)
|
||||
if not os.path.exists(dmg_path):
|
||||
console_print('fail to create %s' % dmg_path)
|
||||
sys.exit(1)
|
||||
|
||||
sys.exit(0)
|
1
ci/mac/package/requirements.txt
Normal file
1
ci/mac/package/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
dmgbuild==1.3.3
|
37
ci/mac/package_for_mac.sh
Executable file
37
ci/mac/package_for_mac.sh
Executable file
|
@ -0,0 +1,37 @@
|
|||
# 获取绝对路径,保证其他目录执行此脚本依然正确
|
||||
{
|
||||
cd $(dirname "$0")
|
||||
script_path=$(pwd)
|
||||
cd -
|
||||
} &> /dev/null # disable output
|
||||
# 设置当前目录,cd的目录影响接下来执行程序的工作目录
|
||||
old_cd=$(pwd)
|
||||
cd $(dirname "$0")
|
||||
|
||||
echo
|
||||
echo
|
||||
echo ---------------------------------------------------------------
|
||||
echo pip install requirements
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
pip install -r $script_path/package/requirements.txt
|
||||
if [ $? -ne 0 ] ;then
|
||||
echo "pip install requirements failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo
|
||||
echo ---------------------------------------------------------------
|
||||
echo create package
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
python $script_path/package/package.py
|
||||
if [ $? -ne 0 ] ;then
|
||||
echo "create package failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 恢复当前目录
|
||||
cd $old_cd
|
||||
exit 0
|
Loading…
Add table
Reference in a new issue