Skip to content

Automation of github release and tag, and publish to pypi #1

Automation of github release and tag, and publish to pypi

Automation of github release and tag, and publish to pypi #1

Workflow file for this run

name: Publish to PyPI
on:
pull_request:
branches: [test]
jobs:
pypi_release:
runs-on: ubuntu-latest
env:
POETRY_VERSION: 1.3.0
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# install & configure poetry
#----------------------------------------------
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org \
| python3 - --version ${{ env.POETRY_VERSION }};
poetry config virtualenvs.create true;
poetry config virtualenvs.in-project true;
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies and root project
#----------------------------------------------
- name: Install dependencies and root project
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --all-extras
#----------------------------------------------
# get current pushed tag
#----------------------------------------------
- name: Show GitHub ref
run: echo "$GITHUB_REF"
- name: Get current pushed tag
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
echo ${{ env.RELEASE_VERSION }}
#----------------------------------------------
# override version tag
#----------------------------------------------
- name: Override version tag
run: poetry run python3 override_version.py
shell: sh
#----------------------------------------------
# publish to testpypi
#----------------------------------------------
# - run: poetry config repositories.testpypi https://test.pypi.org/legacy/
# - run: poetry config pypi-token.testpypi ${{ secrets.TWINE_TEST_TOKEN }}
# - name: Publish package to test Pypi
# run: poetry publish -vvvv --build -r testpypi
#----------------------------------------------
# check tag
#----------------------------------------------
- name: Check Tag
id: check-tag
run: |
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo ::set-output name=match::true
fi