Skip to content

Commit

Permalink
dev(narugo): add cli builder
Browse files Browse the repository at this point in the history
  • Loading branch information
narugo1992 committed Dec 25, 2023
1 parent b70a5c0 commit 8040f9f
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/badge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
python-version: [ 3.8 ]
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3.3.0
with:
fetch-depth: 20
submodules: 'recursive'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
swap-size-gb: 8
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3.3.0
with:
fetch-depth: 20
submodules: 'recursive'
Expand Down
131 changes: 129 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
run: |
echo "IS_PYPY=1" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3.3.0
with:
fetch-depth: 20
submodules: 'recursive'
Expand Down Expand Up @@ -109,4 +109,131 @@ jobs:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
fail_ci_if_error: false

build_cli:
name: CLI Build
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
strategy:
fail-fast: false
matrix:
os:
- 'ubuntu-20.04'
- 'windows-2019'
- 'macos-11'
python-version:
- '3.8.0'

steps:
- name: Get system version for Linux
if: ${{ contains(matrix.os, 'ubuntu') }}
shell: bash
run: |
echo "OS_NAME=Linux" >> $GITHUB_ENV
echo "IS_WIN=" >> $GITHUB_ENV
echo "IS_MAC=" >> $GITHUB_ENV
- name: Get system version for Windows
if: ${{ contains(matrix.os, 'windows') }}
shell: bash
run: |
echo "OS_NAME=Windows" >> $GITHUB_ENV
echo "IS_WIN=1" >> $GITHUB_ENV
echo "IS_MAC=" >> $GITHUB_ENV
- name: Get system version for MacOS
if: ${{ contains(matrix.os, 'macos') }}
shell: bash
run: |
echo "OS_NAME=MacOS" >> $GITHUB_ENV
echo "IS_WIN=" >> $GITHUB_ENV
echo "IS_MAC=1" >> $GITHUB_ENV
- name: Set environment for Cpython
if: ${{ !contains(matrix.python-version, 'pypy') }}
shell: bash
run: |
echo "IS_PYPY=" >> $GITHUB_ENV
- name: Set environment for PyPy
if: ${{ contains(matrix.python-version, 'pypy') }}
shell: bash
run: |
echo "IS_PYPY=1" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v3.3.0
with:
fetch-depth: 20
submodules: 'recursive'
- name: Set up system dependencies on Linux
if: ${{ env.OS_NAME == 'Linux' }}
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y tree cloc wget curl make zip
- name: Set up system dependencies on Windows
if: ${{ env.OS_NAME == 'Windows' }}
shell: bash
run: |
choco install tree cloc wget curl make zip
- name: Set up system dependencies on MacOS
if: ${{ env.OS_NAME == 'MacOS' }}
run: |
brew install tree cloc wget curl make zip
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-build.txt
- name: Test the basic environment
shell: bash
run: |
python -V
pip --version
pip list
tree .
- name: Get package version
shell: bash
run: |
python -c 'from hfutils.config.meta import __VERSION__;print(__VERSION__)'
echo "PACKAGE_VERSION=$(python -c 'from hfutils.config.meta import __VERSION__;print(__VERSION__)')" >> $GITHUB_ENV
echo "GIT_COMMIT_ID=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_ENV
echo "PYTHON_VERSION=$(python -V | xargs -n 1 | tail -1)" >> $GITHUB_ENV
echo "CPU_ARCH=$(uname -m)" >> $GITHUB_ENV
- name: Get CLI name
shell: bash
run: |
echo "ZIP_NAME=hfutils-v${{ env.PACKAGE_VERSION }}-${{ env.OS_NAME }}-${{ env.CPU_ARCH }}-${{ env.GIT_COMMIT_ID }}-standalone" >> $GITHUB_ENV
echo "CLI_NAME=hfutils-v${{ env.PACKAGE_VERSION }}-${{ env.OS_NAME }}-${{ env.CPU_ARCH }}" >> $GITHUB_ENV
- name: Build standalone cli on Linux and MacOS
if: ${{ env.OS_NAME != 'Windows' }}
shell: bash
run: |
make build
mkdir -p dist/${{ env.CLI_NAME }}
cp dist/hfutils dist/${{ env.CLI_NAME }}/hfutils
cd dist
zip -r ${{ env.ZIP_NAME }}.zip ${{ env.CLI_NAME }}
cd ..
ls -al dist
dist/hfutils -v
dist/hfutils -h
- name: Build standalone CLI on Windows
if: ${{ env.OS_NAME == 'Windows' }}
shell: bash
run: |
make build
mkdir -p dist/${{ env.CLI_NAME }}
cp dist/hfutils.exe dist/${{ env.CLI_NAME }}/hfutils.exe
cd dist
zip -r ${{ env.ZIP_NAME }}.zip ${{ env.CLI_NAME }}
cd ..
ls -al dist
dist/hfutils -v
dist/hfutils -h
- uses: actions/upload-artifact@v2
with:
name: hfutils-v${{ env.PACKAGE_VERSION }}-${{ env.OS_NAME }}-${{ env.CPU_ARCH }}-${{ env.GIT_COMMIT_ID }}
path: dist
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ COV_TYPES ?= xml term-missing

package:
$(PYTHON) -m build --sdist --wheel --outdir ${DIST_DIR}
build:
pyinstaller -D -F -n hfutils -c hfutils_cli.py
clean:
rm -rf ${DIST_DIR} ${BUILD_DIR} *.egg-info
rm -rf build dist hfutils.spec

test: unittest

Expand Down
4 changes: 4 additions & 0 deletions hfutils_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from hfutils.entry import hfutilscli

if __name__ == '__main__':
hfutilscli()
1 change: 1 addition & 0 deletions requirements-build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyinstaller>=4.7,<5

0 comments on commit 8040f9f

Please sign in to comment.