summaryrefslogtreecommitdiff
path: root/.github/workflows/pyinstaller-release.yaml
blob: ca73b6a34dc755f2b0327ee1121a7bea7aabd4f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Build Release

on:
  release:
    types: [created]

jobs:
  webpack:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install Webpack dependencies
        working-directory: ./static
        run: npm ci

      - name: Run Webpack
        working-directory: ./static
        run: npx webpack

      - name: Verify dist directory
        working-directory: ./static
        run: |
          ls -la dist || { echo "Error: dist directory not found"; exit 1; }

      - name: Upload frontend bundle
        uses: actions/upload-artifact@v4
        with:
          name: frontend-bundle
          path: ./static/dist

  pyinstaller:
    needs: webpack
    runs-on: ubuntu-latest
    strategy:
      matrix:
        arch: [x64, aarch64]
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Download frontend bundle
        uses: actions/download-artifact@v4
        with:
          name: frontend-bundle
          path: ./static/dist

      - name: Set up QEMU for cross-architecture
        if: matrix.arch == 'aarch64'
        uses: docker/setup-qemu-action@v3
        with:
          platforms: arm64

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.10'

      - name: Install Python dependencies
        run: |
          python -m pip install --upgrade pip
          pip install pyinstaller
          pip install -r requirements.txt

      - name: Install system dependencies for arm64
        if: matrix.arch == 'aarch64'
        run: |
          sudo apt-get update
          sudo apt-get install -y zlib1g-dev libffi-dev libssl-dev

      - name: Run PyInstaller
        env:
          TARGET_ARCH: ${{ matrix.arch }}
        run: |
          ARCHITECTURE=${{ matrix.arch }} pyinstaller pix.spec

      - name: Rename the executable
        run: |
          mv ./dist/pix ./dist/pixpy-${{ matrix.arch }}

      - name: Upload executables
        uses: actions/upload-artifact@v4
        with:
          name: pixpy-${{ matrix.arch }}
          path: ./dist/pixpy-${{ matrix.arch }}

  release:
    needs: pyinstaller
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Download executables
        uses: actions/download-artifact@v4
        with:
          pattern: pixpy-*
          path: ./dist
          merge-multiple: true

      - name: Create Release and Upload Assets
        uses: softprops/action-gh-release@v2
        with:
          files: |
            ./dist/pixpy-*
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}