Updating the release process, and validating credentials are active (#386)

* pypi release improvements, and credential checks

* deps updates along the way
This commit is contained in:
Chayim 2022-10-06 18:09:43 +03:00 committed by GitHub
parent 660db8f8f5
commit 4833a3198e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 181 additions and 581 deletions

27
.github/workflows/check-pypi.yml vendored Normal file
View file

@ -0,0 +1,27 @@
name: Check if required secrets are set to publish to Pypi
on:
schedule:
cron: '5 5 * * *'
jobs:
checksecret:
name: check if PYPI_TOKEN and TESTPYPI_TOKEN are set in github secrets
runs-on: ubuntu-latest
steps:
- name: Check PYPI_TOKEN
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
if ${{ env.PYPI_TOKEN == '' }} ; then
echo "PYPI_TOKEN secret is not set"
exit 1
fi
- name: Check TESTPYPI_TOKEN
env:
TESTPYPI_TOKEN: ${{ secrets.TESTPYPI_TOKEN }}
run: |
if ${{ env.TESTPYPI_TOKEN == '' }} ; then
echo "TESTPYPI_TOKEN secret is not set"
exit 1
fi

View file

@ -147,54 +147,3 @@ jobs:
flags: unit
env_vars: OS
fail_ci_if_error: false
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: test-unix
# Run only on pushing a tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python 3.9
uses: actions/setup-python@v4.2.0
with:
python-version: 3.9
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# Make sync version of library (redis_om)
#----------------------------------------------
- name: Make sync version of library (redis_om)
run: make sync
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction
- name: PyPI upload
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
make upload

59
.github/workflows/pypi-publish.yaml vendored Normal file
View file

@ -0,0 +1,59 @@
name: Publish Pypi
on:
release:
types: [ published ]
jobs:
pytest:
name: Publish to PyPi
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps:
- uses: actions/checkout@master
- name: get version from tag
id: get_version
run: |
realversion="${GITHUB_REF/refs\/tags\//}"
realversion="${realversion//v/}"
echo "::set-output name=VERSION::$realversion"
- name: Set the version for publishing
uses: ciiiii/toml-editor@1.0.0
with:
file: "pyproject.toml"
key: "tool.poetry.version"
value: "${{ steps.get_version.outputs.VERSION }}"
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Cache Poetry virtualenv
uses: actions/cache@v1
id: cache
with:
path: ~/.virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ hashFiles('**/poetry.lock') }}
- name: Set Poetry config
run: |
pip install --upgrade pip python poetry
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
poetry export --dev --without-hashes -o requirements.txt
pip install -r requirements.txt
- name: Make sync version of library (redis_om)
run: make sync
- name: Install
run: poetry install --no-interaction
- name: Publish to PyPI
run: |
poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }} --build