From 623063211bc4668c65a331e583b4fa0d3c452cab Mon Sep 17 00:00:00 2001 From: lukadd16 Date: Sat, 15 Apr 2023 23:03:26 -0400 Subject: [PATCH] build: added workflow to build & upload artifacts for various platforms In theory this workflow should generate binaries for Windows, macOS and Linux. The universal2 target for macOS might not work with Python 3.9 See: - https://github.com/actions/runner-images/issues/4133#issuecomment-1316890437 - https://github.com/pyinstaller/pyinstaller/issues/5315#issuecomment-1145163115 --- .github/workflows/build.yaml | 68 ++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yaml | 8 ++++- .gitignore | 3 +- 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..fdc23bf --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,68 @@ +name: Artifacts + +on: + push: + tags: + - '*' + branches: + - main + pull_request: + branches: + - main + +defaults: + run: + shell: bash + +jobs: + unix-build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - uses: actions/checkout@v3 + + - name: Setup Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9 + + - name: Generate Binary + run: | + python -m pip install --upgrade pip + pip install poetry + poetry install + OS=$(uname -s | tr A-Z a-z) + VERSION=$(poetry version) | cut -d " " -f 2 + pyinstaller --target-architecture=universal2 --noconsole --clean --noconfirm --onefile run_away/__main__.py --name "run-away-$VERSION-$OS" --add-data "run_away/resources:resources" + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + path: dist/run-away.* + + windows-build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9 + + - name: Generate Binary + run: | + python -m pip install --upgrade pip + pip install poetry + poetry install + VERSION=$(poetry version) | cut -d " " -f 2 + pyinstaller --noconsole --clean --noconfirm --onefile run_away/__main__.py --name "run-away-$VERSION-windows" --add-data "run_away/resources;resources" + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + path: dist/run-away.* diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cedb6bc..7d403f9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,27 +12,33 @@ on: jobs: lint: runs-on: ubuntu-latest + steps: - uses: actions/checkout@v3 - - name: Set up Python 3.9 + + - name: Setup Python 3.9 uses: actions/setup-python@v3 with: python-version: 3.9 + - name: Install dependencies run: | python -m pip install --upgrade pip pip install poetry poetry install + - name: Lint with ruff (errors) uses: chartboost/ruff-action@v1 with: version: 0.0.255 args: --format=github --select=E9,F7,F63,F82 --show-source + - name: Lint with ruff (warnings) uses: chartboost/ruff-action@v1 with: version: 0.0.255 args: --exit-zero + - name: Check formatting with black uses: psf/black@stable with: diff --git a/.gitignore b/.gitignore index 252dab2..70c4352 100644 --- a/.gitignore +++ b/.gitignore @@ -166,4 +166,5 @@ cython_debug/ .vscode/settings.json # PyInstaller -!*.spec +!run-away.spec +!run-away-debug.spec