diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..64de6b4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,84 @@ +name: build + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + tag: + description: 'Release tag to upload assets to' + required: true + default: 'v1.0.0' + +jobs: + create-release: + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.tag.outputs.value }} + steps: + - name: Resolve tag + id: tag + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "value=${{ inputs.tag }}" >> $GITHUB_OUTPUT + else + echo "value=${{ github.ref_name }}" >> $GITHUB_OUTPUT + fi + + - name: Ensure release exists + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release view "${{ steps.tag.outputs.value }}" --repo "${{ github.repository }}" 2>/dev/null || \ + gh release create "${{ steps.tag.outputs.value }}" \ + --repo "${{ github.repository }}" \ + --title "${{ steps.tag.outputs.value }}" \ + --generate-notes + + build: + needs: create-release + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + artifact: WarehouseMaster.exe + - os: macos-latest + artifact: WarehouseMaster-macos + - os: ubuntu-latest + artifact: WarehouseMaster-linux + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install system deps (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update -qq + sudo apt-get install -y libxcb-xinerama0 libgl1 libegl1 + + - name: Install Python deps + run: pip install pyinstaller -r requirements.txt + + - name: Build + env: + QT_QPA_PLATFORM: offscreen + run: pyinstaller WarehouseMaster.spec + + - name: Rename artifact (macOS/Linux) + if: runner.os != 'Windows' + shell: bash + run: mv dist/WarehouseMaster "dist/${{ matrix.artifact }}" + + - name: Upload to release + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release upload "${{ needs.create-release.outputs.tag }}" "dist/${{ matrix.artifact }}" --clobber