Skip to content

Commit 4833a31

Browse files
authored
Updating the release process, and validating credentials are active (#386)
* pypi release improvements, and credential checks * deps updates along the way
1 parent 660db8f commit 4833a31

File tree

6 files changed

+181
-581
lines changed

6 files changed

+181
-581
lines changed

.github/workflows/check-pypi.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Check if required secrets are set to publish to Pypi
2+
3+
on:
4+
schedule:
5+
cron: '5 5 * * *'
6+
7+
jobs:
8+
checksecret:
9+
name: check if PYPI_TOKEN and TESTPYPI_TOKEN are set in github secrets
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check PYPI_TOKEN
13+
env:
14+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
15+
run: |
16+
if ${{ env.PYPI_TOKEN == '' }} ; then
17+
echo "PYPI_TOKEN secret is not set"
18+
exit 1
19+
fi
20+
- name: Check TESTPYPI_TOKEN
21+
env:
22+
TESTPYPI_TOKEN: ${{ secrets.TESTPYPI_TOKEN }}
23+
run: |
24+
if ${{ env.TESTPYPI_TOKEN == '' }} ; then
25+
echo "TESTPYPI_TOKEN secret is not set"
26+
exit 1
27+
fi

.github/workflows/ci.yml

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -147,54 +147,3 @@ jobs:
147147
flags: unit
148148
env_vars: OS
149149
fail_ci_if_error: false
150-
151-
deploy:
152-
name: Deploy
153-
runs-on: ubuntu-latest
154-
needs: test-unix
155-
# Run only on pushing a tag
156-
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
157-
steps:
158-
- name: Checkout
159-
uses: actions/checkout@v3
160-
- name: Setup Python 3.9
161-
uses: actions/[email protected]
162-
with:
163-
python-version: 3.9
164-
- name: Install Poetry
165-
uses: snok/install-poetry@v1
166-
with:
167-
virtualenvs-create: true
168-
virtualenvs-in-project: true
169-
installer-parallel: true
170-
#----------------------------------------------
171-
# load cached venv if cache exists
172-
#----------------------------------------------
173-
- name: Load cached venv
174-
id: cached-poetry-dependencies
175-
uses: actions/cache@v3
176-
with:
177-
path: .venv
178-
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
179-
#----------------------------------------------
180-
# Make sync version of library (redis_om)
181-
#----------------------------------------------
182-
- name: Make sync version of library (redis_om)
183-
run: make sync
184-
#----------------------------------------------
185-
# install dependencies if cache does not exist
186-
#----------------------------------------------
187-
- name: Install dependencies
188-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
189-
run: poetry install --no-interaction --no-root
190-
#----------------------------------------------
191-
# install your root project, if required
192-
#----------------------------------------------
193-
- name: Install library
194-
run: poetry install --no-interaction
195-
- name: PyPI upload
196-
env:
197-
TWINE_USERNAME: __token__
198-
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
199-
run: |
200-
make upload

.github/workflows/pypi-publish.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish Pypi
2+
on:
3+
release:
4+
types: [ published ]
5+
6+
jobs:
7+
pytest:
8+
name: Publish to PyPi
9+
runs-on: ubuntu-latest
10+
env:
11+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
12+
steps:
13+
- uses: actions/checkout@master
14+
15+
- name: get version from tag
16+
id: get_version
17+
run: |
18+
realversion="${GITHUB_REF/refs\/tags\//}"
19+
realversion="${realversion//v/}"
20+
echo "::set-output name=VERSION::$realversion"
21+
22+
- name: Set the version for publishing
23+
uses: ciiiii/[email protected]
24+
with:
25+
file: "pyproject.toml"
26+
key: "tool.poetry.version"
27+
value: "${{ steps.get_version.outputs.VERSION }}"
28+
29+
- name: Set up Python 3.9
30+
uses: actions/setup-python@v1
31+
with:
32+
python-version: 3.9
33+
34+
- name: Cache Poetry virtualenv
35+
uses: actions/cache@v1
36+
id: cache
37+
with:
38+
path: ~/.virtualenvs
39+
key: poetry-${{ hashFiles('**/poetry.lock') }}
40+
restore-keys: |
41+
poetry-${{ hashFiles('**/poetry.lock') }}
42+
43+
- name: Set Poetry config
44+
run: |
45+
pip install --upgrade pip python poetry
46+
poetry config virtualenvs.in-project false
47+
poetry config virtualenvs.path ~/.virtualenvs
48+
poetry export --dev --without-hashes -o requirements.txt
49+
pip install -r requirements.txt
50+
51+
- name: Make sync version of library (redis_om)
52+
run: make sync
53+
54+
- name: Install
55+
run: poetry install --no-interaction
56+
57+
- name: Publish to PyPI
58+
run: |
59+
poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }} --build

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ help:
2020
@echo " redis start a Redis instance with Docker"
2121
@echo " sync generate modules redis_om, tests_sync from aredis_om, tests respectively"
2222
@echo " dist build a redis-om package"
23-
@echo " upload upload a redis-om package to PyPI"
2423
@echo " all equivalent to \"make lint format test\""
2524
@echo ""
2625
@echo "Check the Makefile to know exactly what each target is doing."
@@ -50,18 +49,13 @@ dist: $(INSTALL_STAMP) clean sync
5049
sync: $(INSTALL_STAMP)
5150
$(POETRY) run python make_sync.py
5251

53-
.PHONY: upload
54-
upload: dist
55-
$(POETRY) run twine upload dist/*
56-
5752
.PHONY: lint
5853
lint: $(INSTALL_STAMP) dist
5954
$(POETRY) run isort --profile=black --lines-after-imports=2 ./tests/ $(NAME) $(SYNC_NAME)
6055
$(POETRY) run black ./tests/ $(NAME)
6156
$(POETRY) run flake8 --ignore=W503,E501,F401,E731 ./tests/ $(NAME) $(SYNC_NAME)
6257
$(POETRY) run mypy ./tests/ $(NAME) $(SYNC_NAME) --ignore-missing-imports
6358
$(POETRY) run bandit -r $(NAME) $(SYNC_NAME) -s B608
64-
$(POETRY) run twine check dist/*
6559

6660
.PHONY: format
6761
format: $(INSTALL_STAMP) sync

0 commit comments

Comments
 (0)