Skip to content

Commit

Permalink
devops: Initial work on porting the release workflow to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
renatav committed Jun 26, 2024
1 parent e95e25f commit c1e3c72
Show file tree
Hide file tree
Showing 3 changed files with 248 additions and 140 deletions.
271 changes: 132 additions & 139 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,139 +1,132 @@
on:
push: {}
pull_request:
types: [closed]
release:
types: [published]

jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip, setuptools, and wheel
run: |
pip install --upgrade pip setuptools wheel
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libhdf5-serial-dev zlib1g-dev libatlas-base-dev lcov swig3.0 libpcsclite-dev
mkdir -p ~/bin/ && ln -s /usr/bin/swig3.0 ~/bin/swig && export PATH=~/bin/:$PATH
pip install wheel # Ensure wheel is installed
pip install -e .[ci,test,yubikey]
- name: Setup GitHub user
run: |
git config --global user.name oll-bot
git config --global user.email developers@openlawlib.org
- name: Run pre-commit and test with pytest
run: |
pre-commit run --all-files
pytest taf/tests
build-and-test-executables:
needs: run-tests
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
if: ${{ needs.run-tests.result == 'success' }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Upgrade pip windows
if: matrix.os == 'windows-latest'
run: |
python -m pip install --upgrade pip setuptools wheel
- name: Upgrade pip
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: |
pip install --upgrade pip setuptools wheel
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
libhdf5-serial-dev \
zlib1g-dev \
libatlas-base-dev \
lcov \
swig3.0 \
libpcsclite-dev \
libssl-dev \
libgit2-dev \
ca-certificates
mkdir -p ~/bin/ && ln -s /usr/bin/swig3.0 ~/bin/swig && export PATH=~/bin/:$PATH
- name: Install Windows dependencies
if: matrix.os == 'windows-latest'
run: |
choco install swig
- name: Install macOS dependencies
if: matrix.os == 'macos-latest'
run: |
brew install swig
- name: Install dependencies
run: |
pip install .[yubikey]
pip install pyinstaller
- name: Build and test standalone executable (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
pyinstaller --onefile --name taf -y taf/tools/cli/taf.py
chmod +x dist/taf
./dist/taf --help | grep "TAF Command Line Interface" || { echo "Error: Expected text not found in the executable output"; exit 1; }
- name: Build and test standalone executable (Windows)
if: matrix.os == 'windows-latest'
run: |
pyinstaller --onefile --name taf.exe -y taf/tools/cli/taf.py
./dist/taf.exe --help | Select-String "TAF Command Line Interface" -quiet
- name: Build and test standalone executable (macOS)
if: matrix.os == 'macos-latest'
run: |
pyinstaller --onefile --name taf -y taf/tools/cli/taf.py
./dist/taf --help | grep "TAF Command Line Interface" || { echo "Error: Expected text not found in the executable output"; exit 1; }
- name: Upload standalone executable (Linux)
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: taf-executable-linux
path: dist/taf

- name: Upload standalone executable (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: taf-executable-windows
path: dist/taf.exe

- name: Upload standalone executable (macOS)
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v3
with:
name: taf-executable-macos
path: dist/taf
# on:
# push: {}
# pull_request:
# types: [closed]
# release:
# types: [published]

# jobs:

# run-tests:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
# steps:
# - uses: actions/checkout@v3

# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v3
# with:
# python-version: ${{ matrix.python-version }}

# - name: Upgrade pip, setuptools, and wheel
# run: |
# pip install --upgrade pip setuptools wheel

# - name: Install dependencies
# run: |
# sudo apt-get update
# sudo apt-get install libhdf5-serial-dev zlib1g-dev libatlas-base-dev lcov swig3.0 libpcsclite-dev
# mkdir -p ~/bin/ && ln -s /usr/bin/swig3.0 ~/bin/swig && export PATH=~/bin/:$PATH
# pip install wheel # Ensure wheel is installed
# pip install -e .[ci,test,yubikey]

# - name: Setup GitHub user
# run: |
# git config --global user.name oll-bot
# git config --global user.email developers@openlawlib.org

# - name: Run pre-commit and test with pytest
# run: |
# pre-commit run --all-files
# pytest taf/tests

# build-and-test-executables:
# needs: run-tests
# strategy:
# matrix:
# os: [ubuntu-latest, windows-latest, macos-latest]
# runs-on: ${{ matrix.os }}

# if: ${{ needs.run-tests.result == 'success' }}
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v3

# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: '3.10'

# - name: Upgrade pip windows
# if: matrix.os == 'windows-latest'
# run: |
# python -m pip install --upgrade pip setuptools wheel

# - name: Upgrade pip
# if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
# run: |
# pip install --upgrade pip setuptools wheel

# - name: Install Linux dependencies
# if: matrix.os == 'ubuntu-latest'
# run: |
# sudo apt-get update
# sudo apt-get install libhdf5-serial-dev zlib1g-dev libatlas-base-dev lcov swig3.0 libpcsclite-dev
# mkdir -p ~/bin/ && ln -s /usr/bin/swig3.0 ~/bin/swig && export PATH=~/bin/:$PATH

# - name: Install Windows dependencies
# if: matrix.os == 'windows-latest'
# run: |
# choco install swig

# - name: Install macOS dependencies
# if: matrix.os == 'macos-latest'
# run: |
# brew install swig

# - name: Install dependencies
# run: |
# pip install .[yubikey]
# pip install pyinstaller

# - name: Build and test standalone executable (Linux)
# if: matrix.os == 'ubuntu-latest'
# run: |
# pyinstaller --onefile --name taf -y taf/tools/cli/taf.py
# chmod +x dist/taf
# ./dist/taf --help | grep "TAF Command Line Interface" || { echo "Error: Expected text not found in the executable output"; exit 1; }

# - name: Build and test standalone executable (Windows)
# if: matrix.os == 'windows-latest'
# run: |
# pyinstaller --onefile --name taf.exe -y taf/tools/cli/taf.py
# ./dist/taf.exe --help | Select-String "TAF Command Line Interface" -quiet

# - name: Build and test standalone executable (macOS)
# if: matrix.os == 'macos-latest'
# run: |
# pyinstaller --onefile --name taf -y taf/tools/cli/taf.py
# ./dist/taf --help | grep "TAF Command Line Interface" || { echo "Error: Expected text not found in the executable output"; exit 1; }

# - name: Upload standalone executable (Linux)
# if: matrix.os == 'ubuntu-latest'
# uses: actions/upload-artifact@v3
# with:
# name: taf-executable-linux
# path: dist/taf

# - name: Upload standalone executable (Windows)
# if: matrix.os == 'windows-latest'
# uses: actions/upload-artifact@v3
# with:
# name: taf-executable-windows
# path: dist/taf.exe

# - name: Upload standalone executable (macOS)
# if: matrix.os == 'macos-latest'
# uses: actions/upload-artifact@v3
# with:
# name: taf-executable-macos
# path: dist/taf
115 changes: 115 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build and Deploy TAF

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
build_and_upload:
strategy:
matrix:
# os: [ubuntu-latest, windows-latest, macos-latest]
# python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
# architecture: ['x64', 'x86']
os: [windows-latest]
python-version: ['3.10']
architecture: ['x64', 'x86']
exclude:
# Exclude macOS and Linux with x86 architecture
- os: macos-latest
architecture: x86
- os: ubuntu-latest
architecture: x86

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Set up 32-bit Python on Windows
if: matrix.os == 'windows-latest' && matrix.architecture == 'x86'
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
architecture: 'x86'

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Upgrade pip windows
if: matrix.os == 'windows-latest'
run: |
python -m pip install --upgrade pip setuptools wheel
- name: Upgrade pip
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: |
pip install --upgrade pip setuptools wheel
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install libhdf5-serial-dev zlib1g-dev libatlas-base-dev lcov swig3.0 libpcsclite-dev
mkdir -p ~/bin/ && ln -s /usr/bin/swig3.0 ~/bin/swig && export PATH=~/bin/:$PATH
- name: Install Windows dependencies
if: matrix.os == 'windows-latest'
run: |
choco install swig
- name: Install macOS dependencies
if: matrix.os == 'macos-latest'
run: |
brew install swig
- name: Install dependencies
run: |
pip install .[yubikey]
pip install pyinstaller
pip install twine==3.8.0
- name: Build TAF
run: |
python setup.py sdist bdist_wheel clean --all
# - name: Convert to anylinux (if Ubuntu latest)
# if: matrix.os == 'ubuntu-latest'
# run: |
# pip install auditwheel
# auditwheel repair dist/*.whl --plat manylinux_2_24_x86_64

# - name: Delete Linux-tagged wheel files
# if: matrix.os == 'ubuntu-latest'
# run: |
# rm -f dist/*-linux_*.whl # Remove Linux-tagged .whl files in the dist directory

- name: Upload to TestPyPi
# if: startsWith(github.ref, 'refs/tags/v')
run: |
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
env:
TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
# - name: Upload wheels to PyPI
# if: startsWith(github.ref, 'refs/tags/v')
# run: |
# python -m pip install twine
# twine check dist/*
# twine upload --skip-existing dist/* -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }}
# env:
# PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
# PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# displayName: "Upload wheels"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from importlib.util import find_spec
import sys

PACKAGE_NAME = "taf"
PACKAGE_NAME = "test-taf"
VERSION = "0.30.0"
AUTHOR = "Open Law Library"
AUTHOR_EMAIL = "info@openlawlib.org"
Expand Down

0 comments on commit c1e3c72

Please sign in to comment.