2020-01-20 03:42:45 -05:00
|
|
|
name: Build and publish Python package
|
2020-01-19 00:50:21 -05:00
|
|
|
|
|
|
|
on:
|
|
|
|
create:
|
|
|
|
tags:
|
|
|
|
- 'v*'
|
2020-06-18 21:06:22 -04:00
|
|
|
repository_dispatch:
|
|
|
|
types: [wf-python]
|
2020-01-19 00:50:21 -05:00
|
|
|
|
|
|
|
jobs:
|
2020-01-20 03:42:45 -05:00
|
|
|
build:
|
2020-01-19 00:50:21 -05:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
2020-01-20 05:55:17 -05:00
|
|
|
python: [3.5, 3.6, 3.7, 3.8]
|
2020-01-19 00:50:21 -05:00
|
|
|
include:
|
|
|
|
- os: ubuntu-latest
|
|
|
|
ARCH: linux-x86_64
|
|
|
|
LIBFILE: 'libhyperbuild_python_lib.so'
|
|
|
|
PYEXT: 'so'
|
|
|
|
- os: windows-latest
|
|
|
|
ARCH: windows-x86_64
|
|
|
|
LIBFILE: 'hyperbuild_python_lib.dll'
|
|
|
|
PYEXT: 'pyd'
|
|
|
|
- os: macos-latest
|
|
|
|
ARCH: macos-x86_64
|
|
|
|
LIBFILE: 'libhyperbuild_python_lib.dylib'
|
|
|
|
PYEXT: 'so'
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- name: Get version
|
|
|
|
id: version
|
|
|
|
shell: bash
|
2020-06-18 23:00:25 -04:00
|
|
|
run: echo ::set-output name=VERSION::"$([[ "$GITHUB_REF" == refs/tags/v* ]] && echo ${GITHUB_REF#refs/tags/v} || echo '0.0.0')"
|
2020-01-20 08:15:26 -05:00
|
|
|
- name: Get native module file name
|
|
|
|
id: native_file
|
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
PYTHON_VERSION: ${{ matrix.python }}
|
|
|
|
# PowerShell doesn't support `${...}` syntax.
|
|
|
|
run: echo ::set-output name=NAME::${{ matrix.ARCH }}-${PYTHON_VERSION//./_}/hyperbuild.${{ matrix.PYEXT }}
|
2020-01-19 00:50:21 -05:00
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v1
|
|
|
|
with:
|
2020-01-20 05:55:17 -05:00
|
|
|
python-version: ${{ matrix.python }}
|
2020-01-19 00:50:21 -05:00
|
|
|
architecture: 'x64'
|
|
|
|
- name: Set up Rust
|
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2020-07-03 03:34:57 -04:00
|
|
|
toolchain: stable
|
2020-01-19 00:50:21 -05:00
|
|
|
profile: minimal
|
|
|
|
default: true
|
|
|
|
- name: Build native module
|
|
|
|
working-directory: ./python
|
2020-01-20 03:42:45 -05:00
|
|
|
run: cargo build --release
|
2020-06-18 19:49:48 -04:00
|
|
|
- name: Install B2 CLI (macOS, Linux)
|
|
|
|
if: runner.os != 'Windows'
|
|
|
|
run: |
|
|
|
|
sudo pip install setuptools
|
|
|
|
sudo pip install --upgrade b2
|
|
|
|
- name: Install B2 CLI (Windows)
|
|
|
|
if: runner.os == 'Windows'
|
|
|
|
run: |
|
|
|
|
pip install --upgrade b2
|
|
|
|
- name: Upload to B2
|
2020-01-20 05:55:17 -05:00
|
|
|
# Convert dots to underscores in Python version as Python uses dots to represent import hierarchy.
|
2020-06-18 19:49:48 -04:00
|
|
|
run: |
|
|
|
|
b2 authorize-account ${{ secrets.CICD_CLI_B2_KEY_ID }} ${{ secrets.CICD_CLI_B2_APPLICATION_KEY }}
|
2020-07-03 06:47:22 -04:00
|
|
|
b2 upload-file ${{ secrets.CICD_CLI_B2_BUCKET_NAME }} ./python/target/release/${{ matrix.LIBFILE }} hyperbuild/bin/python/${{ steps.version.outputs.VERSION }}/${{ steps.native_file.outputs.NAME }}
|
2020-01-20 03:42:45 -05:00
|
|
|
package:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: build
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- name: Get version
|
|
|
|
id: version
|
|
|
|
shell: bash
|
2020-06-18 23:00:25 -04:00
|
|
|
run: echo ::set-output name=VERSION::"$([[ "$GITHUB_REF" == refs/tags/v* ]] && echo ${GITHUB_REF#refs/tags/v} || echo '0.0.0')"
|
2020-01-20 03:42:45 -05:00
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v1
|
|
|
|
with:
|
|
|
|
python-version: '3.5'
|
|
|
|
architecture: 'x64'
|
2020-01-20 05:01:57 -05:00
|
|
|
- name: Install Python dependencies
|
|
|
|
run: |
|
|
|
|
pip install --upgrade wheel
|
|
|
|
pip install --upgrade setuptools
|
|
|
|
pip install --upgrade twine
|
2020-06-18 19:49:48 -04:00
|
|
|
- name: Install B2 CLI
|
2020-06-18 20:57:56 -04:00
|
|
|
run: sudo pip install --upgrade b2
|
2020-01-20 03:42:45 -05:00
|
|
|
- name: Pack and publish package
|
|
|
|
working-directory: ./python
|
|
|
|
run: |
|
|
|
|
cat << 'EOF' > "$HOME/.pypirc"
|
|
|
|
[pypi]
|
|
|
|
username = __token__
|
|
|
|
password = ${{ secrets.PYPI_API_TOKEN }}
|
|
|
|
EOF
|
|
|
|
cp ../README.md .
|
2020-06-18 19:49:48 -04:00
|
|
|
b2 authorize-account ${{ secrets.CICD_CLI_B2_KEY_ID }} ${{ secrets.CICD_CLI_B2_APPLICATION_KEY }}
|
|
|
|
b2 sync b2://${{ secrets.CICD_CLI_B2_BUCKET_NAME }}/hyperbuild/bin/python/${{ steps.version.outputs.VERSION }}/ ./hyperbuild/.
|
2020-01-20 04:44:47 -05:00
|
|
|
python setup.py sdist bdist_wheel
|
2020-06-18 21:44:54 -04:00
|
|
|
if [[ "${{ steps.version.outputs.VERSION }}" != "0.0.0" ]]; then
|
|
|
|
python -m twine upload dist/*
|
|
|
|
fi
|