Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions which publish to PyPI #48

Merged
merged 20 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/manylinux-install-cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -x
set -e

# Remove the ancient version of cmake
yum remove cmake -y

# Add in curl
yum install wget -y

yum install java-1.8.0-openjdk uuid uuid-devel libuuid libuuid-devel -y

# Download new cmake
wget https://github.com/Kitware/CMake/releases/download/v3.19.4/cmake-3.19.4-Linux-x86_64.sh -O /tmp/cmake.sh
chmod a+x /tmp/cmake.sh

# Install cmake into /usr
/tmp/cmake.sh --prefix=/usr --skip-license
200 changes: 200 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: PyPI

on:
push:
branches:
- master
- github-actions

jobs:

Source:
runs-on: ubuntu-20.04
name: Source

steps:
- name: 🧰 Checkout
uses: actions/checkout@v2
with:
# Always clone the full depth so git-describe works.
fetch-depth: 0
submodules: true

- name: Install dependencies (Ubuntu)
run: |
sudo apt-get update
sudo apt-get install -y cmake default-jre-headless uuid-dev libantlr4-runtime-dev

- name: 🐍 Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install build dependencies
run: |
pip install -U pip
pip install -r requirements.txt

- name: Install package dependencies
run: |
python setup.py install

- name: 🚧 Build distribution 📦
run: |
python setup.py sdist

- name: Check distribution 📦
run: |
twine check dist/*

- name: 📤 Publish source to Test PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }}
run: |
twine upload --skip-existing --verbose --repository testpypi dist/*.tar.gz

# - name: 📤 Publish source to PyPI
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# run: |
# twine upload dist/*.tar.gz

Linux:
strategy:
matrix:
python-version: [ 'cp36-cp36m', 'cp37-cp37m', 'cp38-cp38', 'cp39-cp39' ]
fail-fast: false

name: ${{ matrix.python-version }} • manylinux
runs-on: ubuntu-latest

steps:
- name: 🧰 Checkout
uses: actions/checkout@v2
with:
# Always clone the full depth so git-describe works.
fetch-depth: 0
submodules: true

- name: 🐍 Set up Python
uses: actions/setup-python@v2

- name: Install build dependencies
run: |
pip install -U pip
pip install twine auditwheel

- name: 🚧 Build distribution 📦
uses: RalfG/python-wheels-manylinux-build@v0.3.3-manylinux2010_x86_64
with:
build-requirements: 'cython'
pre-build-command: 'bash .github/workflows/manylinux-install-cmake.sh'
python-versions: ${{ matrix.python-version }}
#pip-wheel-args: '-w ./dist --no-deps --verbose'

- name: List distribution 📦
run: |
set -x
ls -l dist/*
echo $USER
whoami
sudo chown -R $USER dist
ls -l dist/*
rm -v dist/*linux_x86_64*.whl
ls -l dist/*

- name: Check distribution 📦
run: |
for WHEEL in dist/*.whl; do
echo
echo "::group::Checking $WHEEL"
echo
python -m zipfile --list $WHEEL
echo
auditwheel show $WHEEL
echo
twine check $WHEEL
echo
echo "::endgroup::"
done

- name: 📤 Publish wheels to Test PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }}
run: |
twine upload --skip-existing --verbose --repository testpypi dist/*.whl

# - name: 📤 Publish wheels to PyPI
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# run: |
# twine upload dist/*.whl

MacAndWindows:
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9', 'pypy-3.6', 'pypy-3.7' ]
os: [windows-latest, macos-latest]
fail-fast: false

name: ${{ matrix.python-version }} • ${{ matrix.os }}
runs-on: ${{ matrix.os }}

steps:
- name: 🧰 Checkout
uses: actions/checkout@v2
with:
# Always clone the full depth so git-describe works.
fetch-depth: 0
submodules: true

- name: Install dependencies (Mac OS X)
if: startsWith(matrix.os, 'macos')
run: |
true

- name: Install dependencies (Windows)
if: startsWith(matrix.os, 'windows')
run: |
true

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

- name: Install build dependencies
run: |
pip install -U pip
pip install -r requirements.txt

- name: Install package dependencies
run: |
python setup.py install

- name: 🚧 Build distribution 📦
run: |
python setup.py bdist_wheel

- name: Check distribution 📦
run: |
python -m zipfile -l dist/*
twine check dist/*

- name: 📤 Publish wheels to Test PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_PASSWORD }}
run: |
twine upload --skip-existing --verbose --repository testpypi dist/*.whl

# - name: 📤 Publish wheels to PyPI
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# run: |
# twine upload dist/*.whl
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "third_party/antlr4"]
path = third_party/antlr4
url = https://github.com/antlr/antlr4.git
[submodule "third_party/make-env"]
path = third_party/make-env
url = https://github.com/SymbiFlow/make-env.git
30 changes: 20 additions & 10 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ include *.md
include LICENSE
include AUTHORS

# Development support files
include Makefile
include requirements.txt

include environment.yml
include *.yapf
include *.yml
include pyproject.toml
include .clang-format

recursive-include examples *.fasm
# Examples
graft examples

# Tests
graft tests

# Docs
recursive-include docs *.py
Expand All @@ -21,18 +28,21 @@ recursive-include docs *.yml
recursive-include docs *.png
recursive-include docs Makefile
recursive-include tests *
prune tests/__pycache__
prune docs/_*
prune docs/env

# textx based parser
recursive-include fasm/parser *.tx
recursive-include fasm/parser *.pyx
exclude fasm/parser/*.c

# antlr based parser
include src/*
include src/antlr/*
graft third_party

# Excludes
global-exclude .git
exclude .gitmodules
exclude .clang-format

recursive-include fasm/parser *.tx
recursive-include fasm/parser *.pyx
exclude fasm/parser/*.c
include pyproject.toml
prune third_party
prune .github
prune __pycache__