|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: '*' |
| 6 | + tags: 'v*' |
| 7 | + pull_request: |
| 8 | + branches: '*' |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-linux: |
| 12 | + name: Linux Build |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + - name: Setup Python |
| 17 | + uses: actions/setup-python@v2.2.2 |
| 18 | + with: |
| 19 | + python-version: '3.x' |
| 20 | + architecture: 'x64' |
| 21 | + - name: Run test |
| 22 | + run: python setup.py test |
| 23 | + # we do not use the available GitHub action as that does not support building |
| 24 | + # entrypoints that are not located in the root folder of the repo at the moment |
| 25 | + - name: Create binary |
| 26 | + run: | |
| 27 | + pip install . |
| 28 | + python -m nuitka --assume-yes-for-downloads --standalone --onefile --linux-onefile-icon /usr/share/pixmaps/python3.xpm teamscale_precommit_client/precommit_client.py |
| 29 | + mv precommit_client.bin teamscale-cli |
| 30 | + - name: 'Upload Artifact' |
| 31 | + if: ${{ always() }} |
| 32 | + uses: actions/upload-artifact@v2 |
| 33 | + with: |
| 34 | + name: target-linux |
| 35 | + path: ./teamscale-cli |
| 36 | + retention-days: 5 |
| 37 | + |
| 38 | + build-windows: |
| 39 | + name: Windows Build |
| 40 | + runs-on: windows-2019 |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v2 |
| 43 | + - name: Setup Python |
| 44 | + uses: actions/setup-python@v2.2.2 |
| 45 | + with: |
| 46 | + python-version: '3.x' |
| 47 | + architecture: 'x64' |
| 48 | + # Disabled since tests currently fail on Windows, see TS-27090 |
| 49 | + #- name: Run test |
| 50 | + # run: python setup.py test |
| 51 | + - name: Set up MinGW |
| 52 | + uses: egor-tensin/setup-mingw@v2 |
| 53 | + with: |
| 54 | + platform: x64 |
| 55 | + # We do not use --onefile for Windows builds as unpacking the exe to a temp directory |
| 56 | + # is _super_ slow on Windows and performance is key for precommit |
| 57 | + - name: Create binary |
| 58 | + run: | |
| 59 | + pip install . |
| 60 | + python -m nuitka --assume-yes-for-downloads --mingw64 --standalone teamscale_precommit_client/precommit_client.py |
| 61 | + mv ./precommit_client.dist ./teamscale-cli |
| 62 | + mv ./teamscale-cli/precommit_client.exe ./teamscale-cli/teamscale-cli.exe |
| 63 | + mkdir target |
| 64 | + mv teamscale-cli target |
| 65 | + - name: 'Upload Artifact' |
| 66 | + if: ${{ always() }} |
| 67 | + uses: actions/upload-artifact@v2 |
| 68 | + with: |
| 69 | + name: target-windows |
| 70 | + path: ./target |
| 71 | + retention-days: 5 |
| 72 | + |
| 73 | + release: |
| 74 | + if: startsWith(github.ref, 'refs/tags/v') |
| 75 | + needs: |
| 76 | + - build-windows |
| 77 | + - build-linux |
| 78 | + name: Create Release |
| 79 | + runs-on: ubuntu-latest |
| 80 | + steps: |
| 81 | + - uses: actions/download-artifact@v2 |
| 82 | + - name: Package |
| 83 | + run: | |
| 84 | + (cd ./target-linux && chmod +x ./teamscale-cli && zip ../teamscale-cli-linux.zip ./teamscale-cli) |
| 85 | + (cd ./target-windows && zip -r ../teamscale-cli-windows.zip .) |
| 86 | + - name: Upload Release Assets |
| 87 | + id: create_release |
| 88 | + uses: svenstaro/upload-release-action@v2 |
| 89 | + with: |
| 90 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + tag: ${{ github.ref }} |
| 92 | + file: teamscale-cli-*.zip |
| 93 | + file_glob: true |
| 94 | + overwrite: true |
0 commit comments