|
| 1 | +name: Build Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - v* |
| 6 | +env: |
| 7 | + targetName: snake |
| 8 | +jobs: |
| 9 | + publish: |
| 10 | + name: Upload Release Asset |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + upload_Url: ${{ steps.create_release.outputs.upload_url }} |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v2 |
| 17 | + - name: Create Release |
| 18 | + id: create_release |
| 19 | + uses: actions/create-release@v1 |
| 20 | + env: |
| 21 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 22 | + with: |
| 23 | + tag_name: ${{ github.ref }} |
| 24 | + release_name: Release ${{ github.ref }} |
| 25 | + draft: false |
| 26 | + prerelease: false |
| 27 | + buildMac: |
| 28 | + name: Build MacOS |
| 29 | + runs-on: ${{ matrix.os }} |
| 30 | + needs: publish |
| 31 | + strategy: |
| 32 | + matrix: |
| 33 | + os: [macos-latest] |
| 34 | + qt_ver: [5.15.0] |
| 35 | + qt_arch: [clang_64] |
| 36 | + steps: |
| 37 | + - name: cacheQt |
| 38 | + id: MacosCacheQt |
| 39 | + uses: actions/cache@v1 |
| 40 | + with: |
| 41 | + path: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}} |
| 42 | + key: ${{ runner.os }}-Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}} |
| 43 | + - name: Install Qt |
| 44 | + # if: steps.MacosCacheQt.outputs.cache-hit != 'true' |
| 45 | + uses: jurplel/install-qt-action@v2 |
| 46 | + with: |
| 47 | + version: ${{ matrix.qt_ver }} |
| 48 | + cached: ${{ steps.MacosCacheQt.outputs.cache-hit }} |
| 49 | + - uses: actions/checkout@v1 |
| 50 | + with: |
| 51 | + fetch-depth: 1 |
| 52 | + - name: build macos |
| 53 | + run: | |
| 54 | + qmake |
| 55 | + make |
| 56 | + # tag 打包 |
| 57 | + - name: package |
| 58 | + if: startsWith(github.event.ref, 'refs/tags/') |
| 59 | + run: | |
| 60 | + # 拷贝依赖 |
| 61 | + macdeployqt bin/${targetName}.app -qmldir=. -verbose=1 -dmg |
| 62 | + # tag 上传Release |
| 63 | + - name: uploadRelease |
| 64 | + id: uploadRelease |
| 65 | + if: startsWith(github.event.ref, 'refs/tags/') |
| 66 | + env: |
| 67 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 68 | + uses: actions/upload-release-asset@v1 |
| 69 | + with: |
| 70 | + upload_url: ${{ needs.publish.outputs.upload_Url }} |
| 71 | + asset_path: ./bin/${{ env.targetName }}.dmg |
| 72 | + asset_name: ${{ env.targetName }}.dmg |
| 73 | + asset_content_type: application/applefile |
| 74 | + - name: uploadArtifact |
| 75 | + uses: actions/upload-artifact@v2 |
| 76 | + with: |
| 77 | + name: MacOS |
| 78 | + path: bin |
| 79 | + buildWin: |
| 80 | + name: Build Windows |
| 81 | + # 运行平台, windows-latest目前是windows server 2019 |
| 82 | + runs-on: windows-latest |
| 83 | + needs: publish |
| 84 | + strategy: |
| 85 | + # 矩阵配置 |
| 86 | + matrix: |
| 87 | + qt_ver: [5.13.0] |
| 88 | + qt_target: [desktop] |
| 89 | + # mingw用不了 |
| 90 | + # qt_arch: [win64_msvc2017_64, win32_msvc2017, win32_mingw53,win32_mingw73] |
| 91 | + qt_arch: [win64_msvc2017_64, win32_msvc2017] |
| 92 | + # 额外设置msvc_arch |
| 93 | + include: |
| 94 | + - qt_arch: win64_msvc2017_64 |
| 95 | + msvc_arch: x64 |
| 96 | + qt_arch_install: msvc2017_64 |
| 97 | + - qt_arch: win32_msvc2017 |
| 98 | + msvc_arch: x86 |
| 99 | + qt_arch_install: msvc2017 |
| 100 | + # 步骤 |
| 101 | + steps: |
| 102 | + - name: cacheQt |
| 103 | + id: WindowsCacheQt |
| 104 | + uses: actions/cache@v1 |
| 105 | + with: |
| 106 | + path: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch_install}} |
| 107 | + key: ${{ runner.os }}-Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}} |
| 108 | + - name: Install Qt |
| 109 | + # if: steps.WindowsCacheQt.outputs.cache-hit != 'true' |
| 110 | + # 使用外部action。这个action专门用来安装Qt |
| 111 | + uses: jurplel/install-qt-action@v2 |
| 112 | + with: |
| 113 | + # Version of Qt to install |
| 114 | + version: ${{ matrix.qt_ver }} |
| 115 | + # Target platform for build |
| 116 | + target: ${{ matrix.qt_target }} |
| 117 | + # Architecture for Windows/Android |
| 118 | + arch: ${{ matrix.qt_arch }} |
| 119 | + cached: ${{steps.WindowsCacheQt.outputs.cache-hit }} |
| 120 | + # 拉取代码 |
| 121 | + - uses: actions/checkout@v1 |
| 122 | + with: |
| 123 | + fetch-depth: 1 |
| 124 | + # 编译msvc |
| 125 | + - name: build-msvc |
| 126 | + shell: cmd |
| 127 | + env: |
| 128 | + vc_arch: ${{ matrix.msvc_arch }} |
| 129 | + run: | |
| 130 | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %vc_arch% |
| 131 | + qmake |
| 132 | + nmake |
| 133 | + # tag 打包 |
| 134 | + - name: package |
| 135 | + if: startsWith(github.event.ref, 'refs/tags/') |
| 136 | + env: |
| 137 | + VCINSTALLDIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC' |
| 138 | + archiveName: ${{ env.targetName }}-${{ matrix.qt_arch }} |
| 139 | + shell: pwsh |
| 140 | + run: | |
| 141 | + # 创建文件夹 |
| 142 | + New-Item -ItemType Directory ${env:archiveName} |
| 143 | + # 拷贝exe |
| 144 | + Copy-Item bin\${env:targetName}.exe ${env:archiveName}\ |
| 145 | + # 拷贝依赖 |
| 146 | + windeployqt --qmldir . ${env:archiveName}\${env:targetName}.exe |
| 147 | + # 打包zip |
| 148 | + Compress-Archive -Path ${env:archiveName} ${env:archiveName}'.zip' |
| 149 | + # 记录环境变量packageName给后续step |
| 150 | + $name = ${env:archiveName} |
| 151 | + echo "::set-env name=packageName::$name" |
| 152 | + # 打印环境变量packageName |
| 153 | + Write-Host 'packageName:'${env:packageName} |
| 154 | + # tag 上传Release |
| 155 | + - name: uploadRelease |
| 156 | + id: uploadRelease |
| 157 | + if: startsWith(github.event.ref, 'refs/tags/') |
| 158 | + env: |
| 159 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + uses: actions/upload-release-asset@v1 |
| 161 | + with: |
| 162 | + upload_url: ${{ needs.publish.outputs.upload_Url }} |
| 163 | + asset_path: ./${{ env.packageName }}.zip |
| 164 | + asset_name: ${{ env.packageName }}.zip |
| 165 | + asset_content_type: application/zip |
| 166 | + - name: uploadArtifact |
| 167 | + uses: actions/upload-artifact@v2 |
| 168 | + with: |
| 169 | + name: ${{ matrix.qt_arch }} |
| 170 | + path: bin |
| 171 | + buildAnd: |
| 172 | + name: Build Android |
| 173 | + runs-on: ${{ matrix.os }} |
| 174 | + needs: publish |
| 175 | + strategy: |
| 176 | + matrix: |
| 177 | + os: [ubuntu-latest] |
| 178 | + # 5.9.8 版本低,需要额外设置工具链。这里暂不支持。 |
| 179 | + qt_ver: [5.12.6] |
| 180 | + qt_target: [android] |
| 181 | + # android_arm64_v8a 暂时不支持. install-qt-action 依赖的aqtinstall版本为0.5*,需要升级 |
| 182 | + # qt_arch: [android_x86,android_armv7,android_arm64_v8a] |
| 183 | + qt_arch: [android_x86,android_armv7] |
| 184 | + # exclude: |
| 185 | + # - qt_ver: 5.9.8 |
| 186 | + # qt_arch: android_arm64_v8a |
| 187 | + steps: |
| 188 | + - name: Install Qt |
| 189 | + # if: steps.cacheqt.outputs.cache-hit != 'true' |
| 190 | + uses: jurplel/install-qt-action@v2 |
| 191 | + with: |
| 192 | + # Version of Qt to install |
| 193 | + version: ${{ matrix.qt_ver }} |
| 194 | + # Target platform for build |
| 195 | + target: ${{ matrix.qt_target }} |
| 196 | + # Architecture for Windows/Android |
| 197 | + arch: ${{ matrix.qt_arch }} |
| 198 | + - uses: actions/checkout@v1 |
| 199 | + with: |
| 200 | + fetch-depth: 1 |
| 201 | + - name: build android |
| 202 | + run: | |
| 203 | + export ANDROID_SDK_ROOT=$ANDROID_HOME |
| 204 | + export ANDROID_NDK_ROOT=$ANDROID_HOME/ndk-bundle |
| 205 | + qmake |
| 206 | + make |
| 207 | + - name: uploadArtifact |
| 208 | + uses: actions/upload-artifact@v2 |
| 209 | + with: |
| 210 | + name: ${{ matrix.qt_arch }} |
| 211 | + path: bin |
| 212 | + buildIos: |
| 213 | + name: Build IOS |
| 214 | + runs-on: ${{ matrix.os }} |
| 215 | + needs: publish |
| 216 | + strategy: |
| 217 | + matrix: |
| 218 | + os: [macos-latest] |
| 219 | + qt_ver: [5.12.6] |
| 220 | + qt_target: [ios] |
| 221 | + steps: |
| 222 | + - name: Install Qt |
| 223 | + # if: steps.cacheqt.outputs.cache-hit != 'true' |
| 224 | + uses: jurplel/install-qt-action@v2 |
| 225 | + with: |
| 226 | + # Version of Qt to install |
| 227 | + version: ${{ matrix.qt_ver }} |
| 228 | + # Target platform for build |
| 229 | + target: ${{ matrix.qt_target }} |
| 230 | + - uses: actions/checkout@v1 |
| 231 | + with: |
| 232 | + fetch-depth: 1 |
| 233 | + - name: build ios |
| 234 | + run: | |
| 235 | + qmake -r -spec macx-ios-clang CONFIG+=release CONFIG+=iphoneos |
| 236 | + make |
| 237 | + - name: uploadArtifact |
| 238 | + uses: actions/upload-artifact@v2 |
| 239 | + with: |
| 240 | + name: IOS |
| 241 | + path: bin |
| 242 | + buildLin: |
| 243 | + name: Build Linux |
| 244 | + runs-on: ${{ matrix.os }} |
| 245 | + needs: publish |
| 246 | + strategy: |
| 247 | + matrix: |
| 248 | + os: [ubuntu-18.04] |
| 249 | + qt_arch: [gcc_64] |
| 250 | + qt_ver: [5.15.0] |
| 251 | + steps: |
| 252 | + - name: cacheQt |
| 253 | + id: UbuntuCacheQt |
| 254 | + uses: actions/cache@v1 |
| 255 | + with: |
| 256 | + path: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}} |
| 257 | + key: ${{ runner.os }}-Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}} |
| 258 | + - name: Install Qt |
| 259 | + # if: steps.UbuntuCacheQt.outputs.cache-hit != 'true' |
| 260 | + uses: jurplel/install-qt-action@v2 |
| 261 | + with: |
| 262 | + version: ${{ matrix.qt_ver }} |
| 263 | + cached: ${{ steps.UbuntuCacheQt.outputs.cache-hit }} |
| 264 | + - name: ubuntu install GL library |
| 265 | + run: sudo apt-get install -y libglew-dev libglfw3-dev |
| 266 | + - uses: actions/checkout@v1 |
| 267 | + with: |
| 268 | + fetch-depth: 1 |
| 269 | + - name: build ubuntu |
| 270 | + run: | |
| 271 | + qmake |
| 272 | + make |
| 273 | + # tag 上传Release |
| 274 | + - name: uploadRelease |
| 275 | + id: uploadRelease |
| 276 | + if: startsWith(github.event.ref, 'refs/tags/') |
| 277 | + env: |
| 278 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 279 | + uses: actions/upload-release-asset@v1 |
| 280 | + with: |
| 281 | + upload_url: ${{ needs.publish.outputs.upload_Url }} |
| 282 | + asset_path: ./bin/${{ env.targetName }} |
| 283 | + asset_name: ${{ env.targetName }} |
| 284 | + asset_content_type: application/applefile |
| 285 | + - name: uploadArtifact |
| 286 | + uses: actions/upload-artifact@v2 |
| 287 | + with: |
| 288 | + name: Linux |
| 289 | + path: bin |
0 commit comments