|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +env: |
| 4 | + APP_NAME: COMTool |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - "v*.*.*" |
| 10 | + |
| 11 | +jobs: |
| 12 | + hatch-build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Setup Python 3.10 |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: '3.10' |
| 23 | + cache: 'pip' |
| 24 | + |
| 25 | + - name: Install Dependencies |
| 26 | + run: pip install build |
| 27 | + |
| 28 | + - name: Build Distribution |
| 29 | + run: python -m build |
| 30 | + |
| 31 | + - name: Upload sdist |
| 32 | + uses: actions/upload-artifact@v4 |
| 33 | + with: |
| 34 | + name: sdist |
| 35 | + path: dist/*.tar.gz |
| 36 | + compression-level: 0 |
| 37 | + |
| 38 | + - name: Upload wheel |
| 39 | + uses: actions/upload-artifact@v4 |
| 40 | + with: |
| 41 | + name: wheel |
| 42 | + path: dist/*.whl |
| 43 | + compression-level: 0 |
| 44 | + |
| 45 | + nuitka-build: |
| 46 | + strategy: |
| 47 | + matrix: |
| 48 | + os: [ubuntu-20.04, windows-latest, macos-latest] |
| 49 | + include: |
| 50 | + - os: ubuntu-20.04 |
| 51 | + arch: x86_64 |
| 52 | + platform: linux |
| 53 | + ext: tar.gz |
| 54 | + - os: windows-latest |
| 55 | + arch: x86_64 |
| 56 | + platform: windows |
| 57 | + ext: zip |
| 58 | + - os: macos-latest |
| 59 | + arch: x86_64 |
| 60 | + platform: darwin |
| 61 | + ext: tar.gz |
| 62 | + |
| 63 | + runs-on: ${{ matrix.os }} |
| 64 | + |
| 65 | + steps: |
| 66 | + - name: Checkout |
| 67 | + uses: actions/checkout@v4 |
| 68 | + |
| 69 | + - name: Setup Python 3.10 |
| 70 | + uses: actions/setup-python@v5 |
| 71 | + with: |
| 72 | + python-version: '3.10' |
| 73 | + cache: 'pip' |
| 74 | + |
| 75 | + - name: Install Dependencies |
| 76 | + run: pip install . |
| 77 | + |
| 78 | + - name: Build Executable |
| 79 | + uses: Nuitka/Nuitka-Action@main |
| 80 | + with: |
| 81 | + nuitka-version: main |
| 82 | + script-name: src/comtool/__main__.py |
| 83 | + onefile: true |
| 84 | + output-file: ${{ env.APP_NAME }} |
| 85 | + |
| 86 | + - name: Package Binary |
| 87 | + shell: bash |
| 88 | + run: | |
| 89 | + if [ "${{ matrix.os }}" = "windows-latest" ]; then |
| 90 | + cd build |
| 91 | + 7z a ../${{ env.APP_NAME }}-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.ext }} ${{ env.APP_NAME }}.exe |
| 92 | + else |
| 93 | + tar -czvf ${{ env.APP_NAME }}-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.ext }} -C build ${{ env.APP_NAME }} |
| 94 | + fi |
| 95 | +
|
| 96 | + - name: Upload Artifact |
| 97 | + uses: actions/upload-artifact@v4 |
| 98 | + with: |
| 99 | + name: ${{ runner.os }} Build |
| 100 | + path: ${{ env.APP_NAME }}-${{ matrix.arch }}-${{ matrix.platform }}.${{ matrix.ext }} |
| 101 | + compression-level: 0 |
| 102 | + |
| 103 | + release: |
| 104 | + needs: [hatch-build, nuitka-build] |
| 105 | + |
| 106 | + runs-on: ubuntu-latest |
| 107 | + |
| 108 | + permissions: |
| 109 | + contents: write |
| 110 | + |
| 111 | + steps: |
| 112 | + - name: Download Artifacts |
| 113 | + uses: actions/download-artifact@v4 |
| 114 | + with: |
| 115 | + path: artifacts |
| 116 | + merge-multiple: true |
| 117 | + |
| 118 | + - name: Draft Release |
| 119 | + uses: softprops/action-gh-release@v1 |
| 120 | + with: |
| 121 | + draft: true |
| 122 | + files: artifacts/* |
| 123 | + env: |
| 124 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments