[COST-4953] Specify operating system for testing purposes. (#507) #192
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-n-publish: | |
name: Build and publish koku-nise to PyPI | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3.2.0 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v4.4.0 | |
with: | |
python-version: 3.8 | |
- name: Install dependencies | |
run: | | |
python3 -m pip install --upgrade pip | |
python3 -m pip install pipenv-setup setuptools wheel twine chardet vistir==0.6.1 -c requirements/build-constraints.txt | |
- name: Build and publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.pypi_password }} | |
run: | | |
set -e | |
VERSION=$(python setup.py --version) | |
if [ ! -z $(git tag -l "${VERSION}") ]; then | |
echo "Tag already exists, doing nothing"; | |
exit_code=1 | |
elif [ -z "$(pipenv-setup check)" ]; then | |
echo "setup.py out of sync with Pipfile" | |
exit_code=1 | |
else | |
echo "Creating tag ${VERSION}"; | |
git config --local user.email "cost-mgmt@redhat.com" | |
git config --local user.name "Koku-Nise Release Action" | |
git tag ${VERSION}; | |
git push origin --tags; | |
python3 setup.py sdist bdist_wheel | |
python3 -m twine upload dist/* | |
exit_code=0 | |
fi | |
exit $exit_code |