mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 19:44:59 +00:00
chore: github api add token (#91)
* chore: update mac build script * chore: github api add token
This commit is contained in:
parent
3acc7a8ae6
commit
17096b6e62
2 changed files with 23 additions and 9 deletions
23
.github/workflows/macos.yml
vendored
23
.github/workflows/macos.yml
vendored
|
@ -56,7 +56,6 @@ jobs:
|
|||
ci/mac/publish_for_mac.sh ../build
|
||||
# tag 打包
|
||||
- name: Package
|
||||
id: package
|
||||
if: startsWith(github.event.ref, 'refs/tags/')
|
||||
shell: pwsh
|
||||
env:
|
||||
|
@ -66,10 +65,6 @@ jobs:
|
|||
[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/')
|
||||
|
@ -102,14 +97,26 @@ 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}
|
||||
$response = Invoke-RestMethod -Uri $url -Method Get
|
||||
# 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
|
||||
- name: Upload Release
|
||||
id: uploadRelease
|
||||
|
@ -119,6 +126,6 @@ jobs:
|
|||
uses: actions/upload-release-asset@v1.0.1
|
||||
with:
|
||||
upload_url: ${{ env.uploadUrl }}
|
||||
asset_path: ci\build\${{ steps.package.env.packageName }}.zip
|
||||
asset_name: ${{ steps.package.env.packageName }}.zip
|
||||
asset_path: ci/build/${{ env.packageName }}.zip
|
||||
asset_name: ${{ env.packageName }}.zip
|
||||
asset_content_type: application/zip
|
9
.github/workflows/windows.yml
vendored
9
.github/workflows/windows.yml
vendored
|
@ -127,10 +127,17 @@ 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}
|
||||
$response = Invoke-RestMethod -Uri $url -Method Get
|
||||
# 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"
|
||||
|
|
Loading…
Add table
Reference in a new issue