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

Release workflow #38

Merged
merged 3 commits into from
Sep 19, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 53 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- "**"
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
workflow_dispatch:

Expand All @@ -25,17 +27,25 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: install build dependencies
run: pip install -U setuptools wheel
- name: Build discrete-optimization wheel
run: python setup.py bdist_wheel
- name: Upload as build artifacts
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist/*.whl
- name: Checkout source code
uses: actions/checkout@v2
- name: Install build dependencies
run: pip install -U setuptools wheel
- name: Update version number according to pushed tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
VERSION=${GITHUB_REF/refs\/tags\/v/} # stripping "refs/tags/v"
echo $VERSION
# Replace in-place version number in package __init__.py, also used by setup.py
sed -i -e "s/^__version__\s*=.*$/__version__ = \"${VERSION}\"/g" discrete_optimization/__init__.py
cat discrete_optimization/__init__.py
- name: Build discrete-optimization wheel
run: python setup.py bdist_wheel
- name: Upload as build artifacts
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist/*.whl

test:
needs: build
Expand Down Expand Up @@ -187,3 +197,35 @@ jobs:
path: |
tmp/coverage.xml
tmp/coverage_html

deploy:
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download wheels artifact
uses: actions/download-artifact@v1.0.0
with:
name: wheels
- name: Create the github release
uses: softprops/action-gh-release@v1
with:
files: wheels/*.whl
generate_release_notes: true
- name: Publish package to TestPyPI (only for forks)
env:
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
if: github.repository != 'airbus/discrete-optimization' && env.TEST_PYPI_API_TOKEN != ''
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
packages_dir: wheels/
- name: Publish package to PyPI (main repo)
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
if: github.repository == 'airbus/discrete-optimization' && env.PYPI_API_TOKEN != ''
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheels/
1 change: 1 addition & 0 deletions discrete_optimization/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.0"
60 changes: 57 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,46 @@
import os
from pathlib import Path

from setuptools import find_packages, setup


# Extract version number from package/__init__.py, taken from pip setup.py
def read(rel_path: str) -> str:
here = os.path.abspath(os.path.dirname(__file__))
# intentionally *not* adding an encoding option to open, See:
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
with open(os.path.join(here, rel_path)) as fp:
return fp.read()


def get_version(rel_path: str) -> str:
for line in read(rel_path).splitlines():
if line.startswith("__version__"):
# __version__ = "0.9"
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
raise RuntimeError("Unable to find version string.")


version = get_version("discrete_optimization/__init__.py")

#  get long description from readme
long_description = read("README.md")

# minizinc files to embed
data_packages = [
str(p).format(p).replace("/", ".")
for p in Path("discrete_optimization").glob("**/minizinc")
]

# requirements for testing
tests_require = ["pytest", "pytest-cov", "scikit-learn>=1.0"]


# setup arguments
setup(
name="discrete_optimization",
version="0.1",
name="discrete-optimization",
version=version,
packages=find_packages() + data_packages,
include_package_data=True,
package_data={"": ["*"]},
Expand All @@ -34,6 +63,31 @@
tests_require=tests_require,
extras_require={"test": tests_require},
license="MIT",
author="Airbus AI Research <scikit-decide@airbus.com>",
author="Airbus AI Research",
author_email="scikit-decide@airbus.com",
description="Discrete optimization library",
long_description=long_description,
long_description_content_type="text/markdown",
classifiers=[
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Development Status :: 4 - Beta",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
],
url="https://github.com/airbus/discrete-optimization",
download_url="https://github.com/airbus/discrete-optimization",
)