diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..03b3439 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,63 @@ +name: MacOS +on: + push: + paths: + - '*.pro' + - 'src/**' + - '.github/workflows/macos.yml' + pull_request: + paths: + - '*.pro' + - 'src/**' + - '.github/workflows/macos.yml' +jobs: + build: + name: Build + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-10.15,macos-11.0] + qt_ver: [5.9.9,5.12.10,5.15.2,6.2.2] + qt_arch: [clang_64] + env: + targetName: example + steps: + # macos 11.0 默认环境变了,要指定 + - name: prepare env + if: ${{ matrix.os == 'macos-11.0' }} + run: | + softwareupdate --all --install --force + sudo xcode-select --print-path + sudo xcode-select --switch /Library/Developer/CommandLineTools + - name: Install Qt + uses: jurplel/install-qt-action@v2 + with: + version: ${{ matrix.qt_ver }} + cached: 'false' + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: build macos + run: | + qmake + make + # 打包 + - name: package + run: | + # 拷贝依赖 + macdeployqt bin/release/${targetName}.app -qmldir=. -verbose=1 -dmg + # 上传artifacts + - uses: actions/upload-artifact@v2 + with: + name: ${{ env.targetName }}_${{ matrix.os }}_${{matrix.qt_ver}}.zip + path: bin/release/${{ env.targetName }}.app + # tag 上传Release + - name: uploadRelease + if: startsWith(github.event.ref, 'refs/tags/') + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: bin/release/${{ env.targetName }}.dmg + asset_name: ${{ env.targetName }}_${{ matrix.os }}_${{ matrix.qt_ver }}.dmg + tag: ${{ github.ref }} + overwrite: true \ No newline at end of file diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..2edbabf --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,42 @@ +name: Ubuntu +# Qt官方没有linux平台的x86包 +on: + push: + paths: + - '*.pro' + - 'src/**' + - '.github/workflows/ubuntu.yml' + pull_request: + paths: + - '*.pro' + - 'src/**' + - '.github/workflows/ubuntu.yml' +jobs: + build: + name: Build + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04,ubuntu-20.04] + qt_ver: [5.9.9,5.12.10,5.15.2,6.2.2] + qt_arch: [gcc_64] + exclude: + # Qt6.2.2 need GLIBC_2.28, ubuntu 18.04 have not. + - os: ubuntu-18.04 + qt_ver: 6.2.2 + qt_arch: gcc_64 + steps: + - name: Install Qt + uses: jurplel/install-qt-action@v2 + with: + version: ${{ matrix.qt_ver }} + cached: 'false' + - name: ubuntu install GL library + run: sudo apt-get install -y libglew-dev libglfw3-dev + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: build ubuntu + run: | + qmake + make \ No newline at end of file diff --git a/.github/workflows/windows-mingw.yml b/.github/workflows/windows-mingw.yml new file mode 100644 index 0000000..401d74b --- /dev/null +++ b/.github/workflows/windows-mingw.yml @@ -0,0 +1,86 @@ +name: Windows MinGW +on: + push: + paths: + - '*.pro' + - 'src/**' + - '.github/workflows/windows-mingw.yml' + pull_request: + paths: + - '*.pro' + - 'src/**' + - '.github/workflows/windows-mingw.yml' +jobs: + build: + name: Build + runs-on: windows-2019 + strategy: + matrix: + include: + - qt_arch: win32_mingw81 + qt_ver: 5.15.2 + qt_tools: "tools_mingw,8.1.0-1-202004170606,qt.tools.win32_mingw810" + qt_tools_mingw_install: mingw810_32 + - qt_arch: win64_mingw81 + qt_ver: 5.15.2 + qt_tools: "tools_mingw,8.1.0-1-202004170606,qt.tools.win64_mingw810" + qt_tools_mingw_install: mingw810_64 + env: + targetName: example.exe + steps: + - name: Install Qt + uses: jurplel/install-qt-action@v2 + with: + version: ${{ matrix.qt_ver }} + aqtversion: '==2.0.5' + arch: ${{ matrix.qt_arch }} + tools: ${{ matrix.qt_tools }} + cached: 'false' + - uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: Qt 5 environment configuration + if: ${{ startsWith( matrix.qt_ver, 5 ) }} + shell: pwsh + run: | + Write-Output "${{ env.Qt5_DIR }}/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + Write-Output "${{ env.Qt5_DIR }}/../../Tools/${{ matrix.qt_tools_mingw_install }}/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: Qt 6 environment configuration + if: ${{ startsWith( matrix.qt_ver, 6 ) }} + shell: pwsh + run: | + Write-Output "${{ env.Qt6_DIR }}/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + Write-Output "${{ env.Qt6_DIR }}/../../Tools/${{ matrix.qt_tools_mingw_install }}/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: where is qmake & where is mingw32-make + shell: pwsh + run: | + Get-Command -Name 'qmake' | Format-List + Get-Command -Name 'mingw32-make' | Format-List + - name: mingw-build + id: build + shell: cmd + run: | + qmake + mingw32-make + - name: package + id: package + env: + archiveName: ${{ matrix.qt_ver }}-${{ matrix.qt_target }}-${{ matrix.qt_arch }} + shell: pwsh + run: | + & scripts\windows-mingw-publish.ps1 ${env:archiveName} ${env:targetName} + $name = ${env:archiveName} + echo "::set-output name=packageName::$name" + - uses: actions/upload-artifact@v2 + with: + name: ${{ steps.package.outputs.packageName }} + path: ${{ steps.package.outputs.packageName }} + - name: uploadRelease + if: startsWith(github.event.ref, 'refs/tags/') + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ steps.package.outputs.packageName }}.zip + asset_name: ${{ steps.package.outputs.packageName }}.zip + tag: ${{ github.ref }} + overwrite: true \ No newline at end of file