Skip to content

Commit

Permalink
feat: update Taskfile.yaml and add dist.sh script
Browse files Browse the repository at this point in the history
- Update the `dist` task in Taskfile.yaml to use a bash script `dist.sh` for building the distribution files.
- Remove the previous commands in the `dist` task and replace them with a single command that invokes the `dist.sh` script with the appropriate arguments.
- Update the `setup` task in Taskfile.yaml to create a conda environment with Python 3.11 instead of Python 3.12.

The changes were made to improve the build process and ensure compatibility with the desired Python version.
  • Loading branch information
liblaf committed Dec 7, 2023
1 parent 0e4e3f1 commit 252c553
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 26 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install GNU Softwares
uses: liblaf/template/.github/actions/install@main
with:
brew: coreutils
choco: gnuwin32-coreutils.install
- name: Install Task
uses: arduino/setup-task@v1
with:
Expand Down Expand Up @@ -77,8 +82,8 @@ jobs:
upload:
name: Upload Release Assets
needs:
- build-exe
- build-pkg
- build-exe
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
Expand All @@ -89,5 +94,6 @@ jobs:
- name: Upload Release Assets
uses: softprops/action-gh-release@master
with:
tag_name: dev
prerelease: true
files: artifacts/**/*
tag_name: dev
44 changes: 28 additions & 16 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,24 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest
outputs:
created: ${{ steps.release.outputs.releases_created }}
tag: ${{ steps.release.outputs.tag_name }}
steps:
- id: release
name: Create GitHub Release
uses: google-github-actions/release-please-action@v4
with:
release-type: python

build-pkg:
name: Build Package
needs:
- release
if: needs.release.outputs.created == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -42,10 +58,18 @@ jobs:

build-exe:
name: Build Executable
needs:
- release
if: needs.release.outputs.created == 'true'
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install GNU Softwares
uses: liblaf/template/.github/actions/install@main
with:
brew: coreutils
choco: gnuwin32-coreutils.install
- name: Install Task
uses: arduino/setup-task@v1
with:
Expand Down Expand Up @@ -77,19 +101,6 @@ jobs:
- "3.11"
- "3.12"

release:
name: Create GitHub Release
runs-on: ubuntu-latest
outputs:
created: ${{ steps.release.outputs.releases_created }}
tag: ${{ steps.release.outputs.tag_name }}
steps:
- id: release
name: Create GitHub Release
uses: google-github-actions/release-please-action@v4
with:
release-type: python

publish:
name: Publish to PyPI
needs:
Expand Down Expand Up @@ -120,9 +131,9 @@ jobs:
upload:
name: Upload Release Assets
needs:
- build-exe
- build-pkg
- release
- build-pkg
- build-exe
if: needs.release.outputs.created == 'true'
runs-on: ubuntu-latest
steps:
Expand All @@ -133,5 +144,6 @@ jobs:
- name: Upload Release Assets
uses: softprops/action-gh-release@master
with:
tag_name: ${{ needs.release.outputs.tag }}
prerelease: true
files: artifacts/**/*
tag_name: ${{ needs.release.outputs.tag }}
10 changes: 2 additions & 8 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ tasks:

dist:
cmds:
- cmd: python -m nuitka --standalone --onefile
--output-filename="aic-{{OS}}-{{ARCH}}-py{{.PYTHON_VERSION}}{{exeExt}}"
--output-dir="dist" --remove-output main.py
ignore_error: true
- cmd: pyinstaller --distpath="dist" --onefile
--name="aic-{{OS}}-{{ARCH}}-py{{.PYTHON_VERSION}}" main.py
ignore_error: true
- bash scripts/dist.sh "{{OS}}" "{{ARCH}}" "{{.PYTHON_VERSION}}" "{{exeExt}}"
vars:
PYTHON_VERSION:
sh: python scripts/python_version.py
Expand All @@ -36,7 +30,7 @@ tasks:

setup:
cmds:
- micromamba --yes --name="ai-commit-cli" create libpython-static python=3.12
- micromamba --yes --name="ai-commit-cli" create libpython-static python=3.11
- micromamba --yes --name="ai-commit-cli" run poetry install

test:
Expand Down
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
words:
- choco
- cython
- dmypy
- gomod
Expand Down
28 changes: 28 additions & 0 deletions scripts/dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail

OS=$1
ARCH=$2
PYTHON_VERSION=$3
exeExt=$4

rm --force --recursive --verbose dist
if python -m nuitka --standalone --onefile \
--output-filename="aic-$OS-$ARCH-py$PYTHON_VERSION$exeExt" \
--output-dir="dist" --remove-output main.py; then
exit 0
else
status=$?
fi

rm --force --recursive --verbose dist
if pyinstaller --distpath="dist" --onefile \
--name="aic-$OS-$ARCH-py$PYTHON_VERSION" main.py; then
exit 0
else
status=$?
fi

exit $status

0 comments on commit 252c553

Please sign in to comment.