1
0
mirror of https://github.com/jaredtao/TaoQuick.git synced 2025-01-31 21:22:58 +08:00

132 lines
4.7 KiB
YAML
Raw Normal View History

2019-12-07 15:45:19 +08:00
name: MacOS
on:
push:
paths-ignore:
- 'README.md'
- 'LICENSE'
pull_request:
paths-ignore:
- 'README.md'
- 'LICENSE'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
qt_ver: [5.12.6]
qt_arch: [clang_64]
env:
targetName: TaoQuickApp
steps:
- name: cacheQt
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}}
2020-06-15 09:08:00 +08:00
# - name: setupQt
# 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"
2019-12-07 15:45:19 +08:00
- name: Install Qt
2020-06-15 09:08:00 +08:00
# if: steps.MacosCacheQt.outputs.cache-hit != 'true'
uses: jurplel/install-qt-action@v2.6.3
2019-12-07 15:45:19 +08:00
with:
version: ${{ matrix.qt_ver }}
2020-06-15 09:08:00 +08:00
cached: ${{ steps.MacosCacheQt.outputs.cache-hit }}
2019-12-07 15:45:19 +08:00
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: build macos
run: |
qmake
make
# tag 打包
- name: package
if: startsWith(github.event.ref, 'refs/tags/')
run: |
# 拷贝依赖
2019-12-07 16:46:15 +08:00
macdeployqt bin/release/${targetName}.app -qmldir=. -verbose=1 -dmg
2019-12-07 15:45:19 +08:00
# tag 查询github-Release
- name: queryRelease
id: queryReleaseMacos
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
# 没查到,输出
echo "::set-output name=needCreateRelease::true"
return
}
[string]$latestUpUrl = $response.upload_url
Write-Host 'latestUpUrl:'$latestUpUrl
if ($latestUpUrl.Length -eq 0) {
# 没查到,输出
echo "::set-output name=needCreateRelease::true"
}
# tag 创建github-Release
- name: createReleaseWin
id: createReleaseWin
if: startsWith(github.event.ref, 'refs/tags/') && steps.queryReleaseMacos.outputs.needCreateRelease == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/create-release@v1.0.0
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ github.event.head_commit.message }}
draft: false
prerelease: false
# 重定向upload_url到环境变量uploadUrl。
- name: getLatestTagRelease
# tag 上一步无论成功还是失败都执行
if: startsWith(github.event.ref, 'refs/tags/')
shell: pwsh
env:
githubFullName: ${{ github.event.repository.full_name }}
upUrl: ${{ steps.queryReleaseMacos.outputs.upload_url }}
ref: ${{ github.event.ref }}
run: |
# upUrl不为空导出就完事
if (${env:upUrl}.Length -gt 0) {
$v=${env:upUrl}
echo "::set-env name=uploadUrl::$v"
return
}
[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: uploadRelease
id: uploadRelease
if: startsWith(github.event.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/upload-release-asset@v1.0.1
with:
upload_url: ${{ env.uploadUrl }}
2019-12-07 16:46:15 +08:00
asset_path: ./bin/release/${{ env.targetName }}.dmg
2019-12-07 15:45:19 +08:00
asset_name: ${{ runner.os }}-${{ env.targetName }}.dmg
asset_content_type: application/applefile