|
| 1 | +name: New Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + if: startsWith(github.ref, 'refs/tags/') |
| 14 | + |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Build Changelog |
| 19 | + id: github_release |
| 20 | + uses: mikepenz/release-changelog-builder-action@v3 |
| 21 | + env: |
| 22 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + with: |
| 24 | + configurationJson: | |
| 25 | + { |
| 26 | + "template": "## What's Changed\n\n<details>\n<summary>Uncategorized</summary>\n\n#{{UNCATEGORIZED}}\n</details>\n\nIf you find this project useful, please consider [sponsoring](https://ko-fi.com/vietanhdev) its development.", |
| 27 | + "categories": [ |
| 28 | + { |
| 29 | + "title": "## 🚀 Features", |
| 30 | + "labels": ["feature"] |
| 31 | + }, |
| 32 | + { |
| 33 | + "title": "## 🐛 Fixes", |
| 34 | + "labels": ["fix"] |
| 35 | + }, |
| 36 | + { |
| 37 | + "title": "## 💬 Other", |
| 38 | + "labels": ["other"] |
| 39 | + } |
| 40 | + ] |
| 41 | + } |
| 42 | +
|
| 43 | + - name: Create Release |
| 44 | + id: create_release |
| 45 | + |
| 46 | + with: |
| 47 | + body: ${{steps.github_release.outputs.changelog}} |
| 48 | + draft: true |
| 49 | + prerelease: true |
| 50 | + |
| 51 | + - name: Create release url file |
| 52 | + run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt |
| 53 | + |
| 54 | + - name: Save release url file for publish |
| 55 | + uses: actions/upload-artifact@v1 |
| 56 | + with: |
| 57 | + name: release_url |
| 58 | + path: release_url.txt |
| 59 | + |
| 60 | + publish: |
| 61 | + needs: [release] |
| 62 | + |
| 63 | + strategy: |
| 64 | + matrix: |
| 65 | + os: [macos-latest, ubuntu-latest, windows-latest] |
| 66 | + |
| 67 | + runs-on: ${{ matrix.os }} |
| 68 | + |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v2 |
| 71 | + with: |
| 72 | + submodules: true |
| 73 | + |
| 74 | + - uses: conda-incubator/setup-miniconda@v2 |
| 75 | + with: |
| 76 | + auto-update-conda: true |
| 77 | + python-version: '3.7' |
| 78 | + |
| 79 | + - name: Set preferred device to CPU |
| 80 | + shell: bash -l {0} |
| 81 | + run: >- |
| 82 | + sed -i'' -e 's/\_\_preferred_device\_\_[ ]*=[ ]*\"[A-Za-z0-9]*\"/__preferred_device__ = "CPU"/g' anylabeling/app_info.py |
| 83 | +
|
| 84 | + - name: Install main |
| 85 | + shell: bash -l {0} |
| 86 | + run: | |
| 87 | + pip install . |
| 88 | +
|
| 89 | + - name: Install PyQt5 for macOS |
| 90 | + shell: bash -l {0} |
| 91 | + run: | |
| 92 | + conda install -c conda-forge pyqt==5.15.7 |
| 93 | + if: runner.os == 'macOS' |
| 94 | + |
| 95 | + - name: Run pyinstaller |
| 96 | + shell: bash -l {0} |
| 97 | + run: | |
| 98 | + pip install pyinstaller |
| 99 | + pyinstaller anylabeling.spec |
| 100 | +
|
| 101 | + - name: Load release url file from release job |
| 102 | + uses: actions/download-artifact@v1 |
| 103 | + with: |
| 104 | + name: release_url |
| 105 | + |
| 106 | + - name: Get release file name & upload url |
| 107 | + id: get_release_info |
| 108 | + run: | |
| 109 | + echo "::set-output name=upload_url::$(cat release_url/release_url.txt)" |
| 110 | +
|
| 111 | + - name: Upload release executable on macOS & Linux |
| 112 | + id: upload_release_executable_macos_linux |
| 113 | + uses: actions/upload-release-asset@v1 |
| 114 | + env: |
| 115 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 116 | + with: |
| 117 | + upload_url: ${{ steps.get_release_info.outputs.upload_url }} |
| 118 | + asset_path: ./dist/anylabeling |
| 119 | + asset_name: AnyLabeling-${{ runner.os }} |
| 120 | + asset_content_type: application/octet-stream |
| 121 | + if: runner.os != 'Windows' |
| 122 | + |
| 123 | + - name: Upload release executable on Windows |
| 124 | + id: upload_release_executable_windows |
| 125 | + uses: actions/upload-release-asset@v1 |
| 126 | + env: |
| 127 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 128 | + with: |
| 129 | + upload_url: ${{ steps.get_release_info.outputs.upload_url }} |
| 130 | + asset_path: ./dist/anylabeling.exe |
| 131 | + asset_name: AnyLabeling.exe |
| 132 | + asset_content_type: application/octet-stream |
| 133 | + if: runner.os == 'Windows' |
| 134 | + |
| 135 | + - name: Create dmg for macOS |
| 136 | + run: | |
| 137 | + npm install -g create-dmg |
| 138 | + cd dist |
| 139 | + create-dmg AnyLabeling.app || test -f AnyLabeling\ 0.0.0.dmg |
| 140 | + mv AnyLabeling\ 0.0.0.dmg AnyLabeling.dmg |
| 141 | + if: runner.os == 'macOS' |
| 142 | + |
| 143 | + - name: Upload release app on macOS |
| 144 | + id: upload_release_app_macos |
| 145 | + uses: actions/upload-release-asset@v1 |
| 146 | + env: |
| 147 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 148 | + with: |
| 149 | + upload_url: ${{ steps.get_release_info.outputs.upload_url }} |
| 150 | + asset_path: ./dist/AnyLabeling.dmg |
| 151 | + asset_name: AnyLabeling.dmg |
| 152 | + asset_content_type: application/octet-stream |
| 153 | + if: runner.os == 'macOS' |
| 154 | + |
| 155 | + publish-gpu: |
| 156 | + needs: [release] |
| 157 | + |
| 158 | + strategy: |
| 159 | + matrix: |
| 160 | + os: [macos-latest, ubuntu-latest, windows-latest] |
| 161 | + |
| 162 | + runs-on: ${{ matrix.os }} |
| 163 | + |
| 164 | + steps: |
| 165 | + - uses: actions/checkout@v2 |
| 166 | + with: |
| 167 | + submodules: true |
| 168 | + |
| 169 | + - uses: conda-incubator/setup-miniconda@v2 |
| 170 | + with: |
| 171 | + auto-update-conda: true |
| 172 | + python-version: '3.7' |
| 173 | + |
| 174 | + - name: Set preferred device to GPU |
| 175 | + shell: bash -l {0} |
| 176 | + run: >- |
| 177 | + sed -i'' -e 's/\_\_preferred_device\_\_[ ]*=[ ]*\"[A-Za-z0-9]*\"/__preferred_device__ = "GPU"/g' anylabeling/app_info.py |
| 178 | +
|
| 179 | + - name: Install main |
| 180 | + shell: bash -l {0} |
| 181 | + run: | |
| 182 | + pip install . |
| 183 | +
|
| 184 | + - name: Install PyQt5 for macOS |
| 185 | + shell: bash -l {0} |
| 186 | + run: | |
| 187 | + conda install -c conda-forge pyqt==5.15.7 |
| 188 | + if: runner.os == 'macOS' |
| 189 | + |
| 190 | + - name: Run pyinstaller |
| 191 | + shell: bash -l {0} |
| 192 | + run: | |
| 193 | + pip install pyinstaller |
| 194 | + pyinstaller anylabeling.spec |
| 195 | +
|
| 196 | + - name: Load release url file from release job |
| 197 | + uses: actions/download-artifact@v1 |
| 198 | + with: |
| 199 | + name: release_url |
| 200 | + |
| 201 | + - name: Get release file name & upload url |
| 202 | + id: get_release_info |
| 203 | + run: | |
| 204 | + echo "::set-output name=upload_url::$(cat release_url/release_url.txt)" |
| 205 | +
|
| 206 | + - name: Upload release executable on macOS & Linux |
| 207 | + id: upload_release_executable_macos_linux |
| 208 | + uses: actions/upload-release-asset@v1 |
| 209 | + env: |
| 210 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 211 | + with: |
| 212 | + upload_url: ${{ steps.get_release_info.outputs.upload_url }} |
| 213 | + asset_path: ./dist/anylabeling |
| 214 | + asset_name: AnyLabeling-${{ runner.os }}-GPU |
| 215 | + asset_content_type: application/octet-stream |
| 216 | + if: runner.os != 'Windows' |
| 217 | + |
| 218 | + - name: Upload release executable on Windows |
| 219 | + id: upload_release_executable_windows |
| 220 | + uses: actions/upload-release-asset@v1 |
| 221 | + env: |
| 222 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 223 | + with: |
| 224 | + upload_url: ${{ steps.get_release_info.outputs.upload_url }} |
| 225 | + asset_path: ./dist/anylabeling.exe |
| 226 | + asset_name: AnyLabeling-GPU.exe |
| 227 | + asset_content_type: application/octet-stream |
| 228 | + if: runner.os == 'Windows' |
| 229 | + |
| 230 | + - name: Create dmg for macOS |
| 231 | + run: | |
| 232 | + npm install -g create-dmg |
| 233 | + cd dist |
| 234 | + create-dmg AnyLabeling.app || test -f AnyLabeling\ 0.0.0.dmg |
| 235 | + mv AnyLabeling\ 0.0.0.dmg AnyLabeling-GPU.dmg |
| 236 | + if: runner.os == 'macOS' |
| 237 | + |
| 238 | + - name: Upload release app on macOS |
| 239 | + id: upload_release_app_macos |
| 240 | + uses: actions/upload-release-asset@v1 |
| 241 | + env: |
| 242 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 243 | + with: |
| 244 | + upload_url: ${{ steps.get_release_info.outputs.upload_url }} |
| 245 | + asset_path: ./dist/AnyLabeling-GPU.dmg |
| 246 | + asset_name: AnyLabeling-GPU.dmg |
| 247 | + asset_content_type: application/octet-stream |
| 248 | + if: runner.os == 'macOS' |
0 commit comments