diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..6daaa04d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,145 @@ +name: Bundle with Pyinstaller +on: + push: + branches: '*' + tags: 'v*' + +jobs: + frontend: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.set_tag.outputs.tag }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - id: set_tag + run: | + if ${{ startsWith(github.ref, 'refs/tags/v') }}; then + echo "tag=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT" + else + echo "tag=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" + fi + + - uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Build Frontend + working-directory: frontend + run: | + npm install + npm run build + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: frontend + path: frontend/dist + + backend: + needs: frontend + strategy: + matrix: + os: [macos, ubuntu, windows] + runs-on: ${{ matrix.os }}-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Download Frontend + uses: actions/download-artifact@v4 + with: + name: frontend + path: frontend/dist + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install Dependencies (Host Native) + if: matrix.os != 'macos' + run: | + python3 -m venv venv + ${{ matrix.os == 'windows' && 'venv\\Scripts\\activate' || 'source venv/bin/activate' }} + pip3 install -r requirements.txt + pip3 install pyinstaller + + - name: Install Dependencies (macOS Universal) + if: matrix.os == 'macos' + run: | + python3 -m venv venv + source venv/bin/activate + pip3 download --no-cache-dir --only-binary=:all: \ + --platform=macosx_10_13_universal2 \ + -d downloads \ + -r requirements.txt \ + pyinstaller + pip3 install --upgrade --no-cache-dir --no-index --only-binary=:all: \ + --find-links downloads \ + -r requirements.txt \ + pyinstaller + + - name: Bundle blivechat (Linux) + if: matrix.os == 'ubuntu' + run: | + source venv/bin/activate + pyinstaller --noconfirm \ + --add-data="data:data" \ + --add-data="log:log" \ + --add-data="frontend/dist:frontend/dist" \ + --name blivechat \ + --contents-directory . \ + main.py + + - name: Bundle blivechat (macOS Universal) + if: matrix.os == 'macos' + run: | + source venv/bin/activate + pyinstaller --noconfirm \ + --add-data="data:data" \ + --add-data="log:log" \ + --add-data="frontend/dist:frontend/dist" \ + --name blivechat \ + --contents-directory . \ + --target-arch universal2 \ + main.py + + - name: Bundle blivechat (Windows) + if: matrix.os == 'windows' + run: | + venv\\Scripts\\activate + pyinstaller --noconfirm ` + --add-data="data;data" ` + --add-data="log;log" ` + --add-data="frontend\dist;frontend\dist" ` + --name blivechat ` + --contents-directory . ` + main.py + + - name: Package Bundle + working-directory: dist + run: 7z a -tzip blivechat-${{ needs.frontend.outputs.tag }}-${{ matrix.os }}-x64.zip blivechat + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: blivechat-${{ matrix.os }}-x64 + path: dist/blivechat-*.zip + + release: + needs: backend + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download Artifact + uses: actions/download-artifact@v4 + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + files: ./**/blivechat-*.zip