-
Notifications
You must be signed in to change notification settings - Fork 13
157 lines (135 loc) · 6.08 KB
/
release-and-publish-core.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: release-and-publish-core
on:
push:
branches: [ "release-core" ]
paths:
- 'source/**'
- '.github/workflows/release-and-publish-core.yml'
pull_request:
branches: [ "release-core" ]
paths:
- 'source/**'
- '.github/workflows/drelease-and-publish-core.yml'
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
# 跳过提交信息开头为doc:或者docs:的提交
if: "!startsWith(github.event.head_commit.message, 'doc:') && !startsWith(github.event.head_commit.message, 'docs:')"
runs-on: self-hosted
outputs:
version: ${{ steps.get_version.outputs._version }}
steps:
- uses: actions/checkout@v3
- name: test env
run: |
dir
echo "github.workspace: ${{github.workspace}}"
echo "github.ref: ${{github.ref}}"
dir ${{github.workspace}}
- name: clone third party submodule
run: git submodule update --init --recursive
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Get the Version
id: get_version
run: |
$version = (Get-Content -Path ${{github.workspace}}/build/bin/Release/version -TotalCount 1).Trim()
echo "dll version: $version"
echo "_version=$version" >> $env:GITHUB_OUTPUT
- name: zip all dll
run: |
$version = '${{steps.get_version.outputs._version}}'
echo "dll version: $version"
Compress-Archive -Path ${{github.workspace}}/build/bin/Release/cvAutoTrack.dll -DestinationPath ${{github.workspace}}/build/bin/Release/cvAutoTrack-$version.zip
$files = $(ls ${{github.workspace}}/build/bin/Release/opencv_*.dll)
foreach ($file_str in $files)
{
$file = New-Object System.IO.FileInfo("$file_str")
$fileNmae = $file.BaseName
$hash = $(Get-FileHash -Path $file_str -Algorithm MD5).Hash
Compress-Archive -Path $file -DestinationPath ${{github.workspace}}/build/bin/Release/$fileNmae-$hash.zip
}
- name: Upload a Build Artifact for Release
uses: actions/upload-artifact@v3
with:
name: cvAutoTrack
path: ${{github.workspace}}/build/bin/Release/cvAutoTrack-*.zip
if-no-files-found: 'warn'
- name: Upload a Build Artifact for Core pdb
uses: actions/upload-artifact@v3
with:
name: cvAutoTrack pdb
path: ${{github.workspace}}/build/bin/Release/cvAutoTrack.pdb
if-no-files-found: 'warn'
- name: Upload a Build Artifact for Release.Depends
uses: actions/upload-artifact@v3
with:
name: cvAutoTrack.Depends
path: ${{github.workspace}}/build/bin/Release/opencv_*.zip
if-no-files-found: 'warn'
push-file:
if: github.ref == 'refs/heads/release-core'
needs: build
runs-on: self-hosted
env:
Version: ${{ needs.build.outputs.version }}
loginToken: ${{ secrets.AlistLoginToken }}
UpdataToken: ${{ secrets.TianLiUpdateServiceToken }}
steps:
- name: Download a Build Artifact for Core
uses: actions/download-artifact@v3
with:
name: cvAutoTrack
path: ${{github.workspace}}/Release/
- name: Download a Build Artifact for Depends
uses: actions/download-artifact@v3
with:
name: cvAutoTrack.Depends
path: ${{github.workspace}}/Release/
- name: push core file
run: |
. ${{github.workspace}}/ci/AlistProxy.ps1
$version = '${{ needs.build.outputs.version }}'
$login_password = '${{ env.loginToken }}'
Write-Host "Login ..."
$token = Get-LoginToken -username 'GitAction' -password $login_password
$file = Get-ChildItem ${{github.workspace}}/Release/cvAutoTrack-*.zip
$upload_core_paths = @('/sync/TianLiUpdateService.tianyi/cvAutoTrack.Core/',
'/sync/TianLiUpdateService.object/cvAutoTrack.Core/',
'/sync/TianLiUpdateService.local/cvAutoTrack.Core/')
Write-Host "upload file: $file"
Put-FileToAlist -token $token -file $file -target_filename $file.Name -upload_paths $upload_core_paths
- name: push deps file
run: |
. ${{github.workspace}}/ci/AlistProxy.ps1
$version = '${{ needs.build.outputs.version }}'
$login_password = '${{ env.loginToken }}'
Write-Host "Login ..."
$token = Get-LoginToken -username 'GitAction' -password $login_password
$files = Get-ChildItem -Path '${{github.workspace}}/Release/opencv_*' -Filter '*.zip'
$upload_deps_paths = @('/sync/TianLiUpdateService.tianyi/cvAutoTrack.Core/deps/',
'/sync/TianLiUpdateService.object/cvAutoTrack.Core/deps/',
'/sync/TianLiUpdateService.local/cvAutoTrack.Core/deps/')
foreach ($file in $files) {
Write-Host "upload file: $file"
Put-FileToAlist -token $token -file $file -target_filename $file.Name -upload_paths $upload_deps_paths
}
- name: push version
run: |
. ${{github.workspace}}/ci/UpdateServiceProxy.ps1
$deps_files = Get-ChildItem -Path '${{github.workspace}}/Release/opencv_*' -Filter '*.zip'
$parent_dir_url = "https://download.weixitianli.com/d/TianLiUpdateService/cvAutoTrack.Core/deps/"
$depsJson = GenDepsJson -deps_files $deps_files -parent_dir_url $parent_dir_url
$version = '${{ needs.build.outputs.version }}'
$cvAutoTrackFile = Get-ChildItem ${{github.workspace}}/Release/cvAutoTrack-*.zip
$log = "Auto Build"
$downloadUrl = "https://download.weixitianli.com/d/TianLiUpdateService/cvAutoTrack.Core/cvAutoTrack-" + $version + ".zip"
$jsonBody = GenVersionPostBody -version $version -cvAutoTrackFile $cvAutoTrackFile -log $log -downloadUrl $downloadUrl -depsJson $depsJson
echo $jsonBody > ${{github.workspace}}/Release/version.json
$token = '${{ env.UpdataToken }}'
$info = PostVersion -token $token -jsonBody $jsonBody
Write-Host "PostVersion: $info"