|
| 1 | +name: Release Python Application |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' # Run workflow on version tags, e.g. v1.0.0 |
| 7 | + |
| 8 | +jobs: |
| 9 | + create-release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 13 | + steps: |
| 14 | + - name: Create Release |
| 15 | + id: create_release |
| 16 | + uses: actions/create-release@v1 |
| 17 | + env: |
| 18 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 19 | + with: |
| 20 | + tag_name: ${{ github.ref }} |
| 21 | + release_name: Release ${{ github.ref }} |
| 22 | + draft: false |
| 23 | + prerelease: false |
| 24 | + |
| 25 | + build-and-release: |
| 26 | + needs: create-release |
| 27 | + runs-on: ${{ matrix.os }} |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + include: |
| 31 | + - os: windows-latest |
| 32 | + asset_name: go-dispatch-proxy-gui-windows |
| 33 | + asset_extension: .zip |
| 34 | + - os: ubuntu-latest |
| 35 | + asset_name: go-dispatch-proxy-gui-linux |
| 36 | + asset_extension: .tar.gz |
| 37 | + - os: macos-latest |
| 38 | + asset_name: go-dispatch-proxy-gui-macos |
| 39 | + asset_extension: .zip |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Checkout code |
| 43 | + uses: actions/checkout@v3 |
| 44 | + |
| 45 | + - name: Set up Python |
| 46 | + uses: actions/setup-python@v4 |
| 47 | + with: |
| 48 | + python-version: '3.9' |
| 49 | + |
| 50 | + - name: Install dependencies |
| 51 | + run: | |
| 52 | + python -m pip install --upgrade pip |
| 53 | + pip install pyinstaller |
| 54 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 55 | + shell: bash |
| 56 | + |
| 57 | + - name: Build with PyInstaller |
| 58 | + run: | |
| 59 | + pyinstaller go-dispatch-proxy-gui.spec |
| 60 | +
|
| 61 | + - name: Archive Windows build |
| 62 | + if: matrix.os == 'windows-latest' |
| 63 | + run: | |
| 64 | + powershell Compress-Archive -Path dist/* -DestinationPath ${{ matrix.asset_name }}${{ matrix.asset_extension }} |
| 65 | +
|
| 66 | + - name: Archive Linux build |
| 67 | + if: matrix.os == 'ubuntu-latest' |
| 68 | + run: | |
| 69 | + tar -C dist -czvf ${{ matrix.asset_name }}${{ matrix.asset_extension }} . |
| 70 | +
|
| 71 | + - name: Archive macOS build |
| 72 | + if: matrix.os == 'macos-latest' |
| 73 | + run: | |
| 74 | + ditto -c -k --keepParent dist ${{ matrix.asset_name }}${{ matrix.asset_extension }} |
| 75 | +
|
| 76 | + - name: Upload Release Asset |
| 77 | + uses: actions/upload-release-asset@v1 |
| 78 | + env: |
| 79 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + with: |
| 81 | + upload_url: ${{ needs.create-release.outputs.upload_url }} |
| 82 | + asset_path: ./${{ matrix.asset_name }}${{ matrix.asset_extension }} |
| 83 | + asset_name: ${{ matrix.asset_name }}${{ matrix.asset_extension }} |
| 84 | + asset_content_type: application/octet-stream |
0 commit comments