|
| 1 | +name: Build and release version as draft |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + |
| 10 | + release: |
| 11 | + name: Create Release |
| 12 | + runs-on: ubuntu-latest |
| 13 | + outputs: |
| 14 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 15 | + version: ${{ steps.get_version.outputs.version }} |
| 16 | + name: 'DSEP4TP' |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-tags: true |
| 22 | + sparse-checkout: | |
| 23 | + CHANGELOG.md |
| 24 | +
|
| 25 | + - name: Get Version |
| 26 | + id: get_version |
| 27 | + run: echo "version=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT" |
| 28 | + |
| 29 | + - name: "Check if release exists" |
| 30 | + uses: actions/github-script@v7 |
| 31 | + id: check_release |
| 32 | + with: |
| 33 | + result-encoding: string |
| 34 | + script: | |
| 35 | + const tag = '${{ steps.get_version.outputs.version }}'; |
| 36 | + let exists = false; |
| 37 | + try { |
| 38 | + const releases = await github.rest.repos.listReleases(context.repo); |
| 39 | + exists = releases.data.some((r) => r.tag_name == tag ); |
| 40 | + } |
| 41 | + catch { core.setFailed(err); } |
| 42 | + console.log("Release for tag", tag, "already exists:", exists); |
| 43 | + core.setOutput('release_exists', exists); |
| 44 | +
|
| 45 | + - name: "Get release notes" |
| 46 | + if: ${{ steps.check_release.outputs.release_exists == 'false' }} |
| 47 | + uses: mpaperno/ghaction-get-release-notes@v1 |
| 48 | + id: release_notes |
| 49 | + with: |
| 50 | + version_tag: ${{ steps.get_version.outputs.version }} |
| 51 | + fallback_to_latest: true |
| 52 | + |
| 53 | + - name: Create Release |
| 54 | + id: create_release |
| 55 | + uses: ncipollo/release-action@v1 |
| 56 | + with: |
| 57 | + tag: v${{ steps.get_version.outputs.version }} |
| 58 | + name: ${{ steps.release_notes.outputs.release_title }} |
| 59 | + body: ${{ steps.release_notes.outputs.release_notes }} |
| 60 | + draft: true |
| 61 | + prerelease: true |
| 62 | + allowUpdates: true |
| 63 | + updateOnlyUnreleased: true |
| 64 | + skipIfReleaseExists: false |
| 65 | + removeArtifacts: true |
| 66 | + omitBodyDuringUpdate: true |
| 67 | + omitDraftDuringUpdate: true |
| 68 | + omitNameDuringUpdate: true |
| 69 | + omitPrereleaseDuringUpdate: true |
| 70 | + |
| 71 | + build: |
| 72 | + name: Build |
| 73 | + needs: release |
| 74 | + strategy: |
| 75 | + fail-fast: false |
| 76 | + matrix: |
| 77 | + os: [ |
| 78 | + windows-latest, |
| 79 | + macos-latest, |
| 80 | + # macos-13, |
| 81 | + ubuntu-latest |
| 82 | + ] |
| 83 | + runs-on: ${{ matrix.os }} |
| 84 | + steps: |
| 85 | + - name: Checkout repository |
| 86 | + uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Install Qt |
| 89 | + uses: jurplel/install-qt-action@v4 |
| 90 | + with: |
| 91 | + version: 6.5.* |
| 92 | + tools: ${{ startsWith(matrix.os, 'windows') && 'tools_ninja tools_opensslv3_x64' || 'tools_ninja' }} |
| 93 | + # modules: 'qtwebsockets' |
| 94 | + |
| 95 | + - name: Configure MSVC |
| 96 | + if: ${{ startsWith(matrix.os, 'windows') }} |
| 97 | + # https://github.com/ilammy/msvc-dev-cmd |
| 98 | + uses: ilammy/msvc-dev-cmd@v1 |
| 99 | + with: |
| 100 | + arch: x64 |
| 101 | + toolset: 14.29 |
| 102 | + |
| 103 | + - name: Configure CMake |
| 104 | + env: |
| 105 | + QTHOME: '${{ env.IQTA_TOOLS }}/..' |
| 106 | + run: | |
| 107 | + cmake -G "Ninja" -B ./build-Release -S ./src -DCMAKE_PREFIX_PATH:PATH=${QT_ROOT_DIR} -DCMAKE_BUILD_TYPE=Release -DTPClient_BUILD_SHARED_LIBS:BOOL=OFF |
| 108 | +
|
| 109 | + - name: Build |
| 110 | + run: cmake --build ./build-Release --target ${{ needs.release.outputs.name }} install |
| 111 | + |
| 112 | + - name: Mac extra deploy step |
| 113 | + if: ${{ startsWith(matrix.os, 'macos') }} |
| 114 | + run: cmake --build ./build-Release --target deployqt |
| 115 | + |
| 116 | + - name: Install Info-zip |
| 117 | + if: ${{ startsWith(matrix.os, 'windows') }} |
| 118 | + run: | |
| 119 | + choco install zip |
| 120 | +
|
| 121 | + - name: Make distro |
| 122 | + run: | |
| 123 | + cd build |
| 124 | + node ./distro.mjs |
| 125 | +
|
| 126 | + - id: get_os_arch |
| 127 | + uses: actions/github-script@v7 |
| 128 | + with: |
| 129 | + result-encoding: string |
| 130 | + script: return `${process.env.RUNNER_OS}-${process.arch}` |
| 131 | + |
| 132 | + - name: Upload assets |
| 133 | + id: upload-release-asset |
| 134 | + uses: actions/upload-release-asset@v1 |
| 135 | + env: |
| 136 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 137 | + archive_name: ${{ needs.release.outputs.name }}-${{ steps.get_os_arch.outputs.result }}-${{ needs.release.outputs.version }}.tpp |
| 138 | + with: |
| 139 | + upload_url: ${{ needs.release.outputs.upload_url }} |
| 140 | + asset_path: ./dist/${{ env.archive_name }} |
| 141 | + asset_name: ${{ env.archive_name }} |
| 142 | + asset_content_type: application/zip |
0 commit comments