Skip to content

Commit d5729b3

Browse files
committed
Automatically build and release from tags
1 parent f34e632 commit d5729b3

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

.github/utils/check_version.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
import sys
3+
4+
from setuptools.config import StaticModule
5+
6+
7+
sys.path.insert(0, os.getcwd())
8+
version = StaticModule('flask_pluginengine').__version__
9+
tag_version = sys.argv[1]
10+
11+
if tag_version != version:
12+
print(
13+
f'::error::Tag version {tag_version} does not match package version {version}'
14+
)
15+
sys.exit(1)

.github/workflows/pypi.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: PyPI release 🐍 📦
2+
3+
on:
4+
push:
5+
tags: [v*]
6+
7+
jobs:
8+
build-publish:
9+
name: PyPI release 🐍 📦
10+
runs-on: ubuntu-20.04
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-python@v2
15+
name: Set up Python 🐍
16+
with:
17+
python-version: '3.10'
18+
- name: Check version 🔍
19+
run: python .github/utils/check_version.py "${GITHUB_REF#refs/tags/v}"
20+
- name: Install pypa/build 🔧
21+
run: pip install --user build
22+
- name: Build wheel and sdist 📦
23+
run: >-
24+
python -m
25+
build
26+
--sdist
27+
--wheel
28+
--outdir dist/
29+
.
30+
- name: Publish to Test PyPI 🧪
31+
uses: pypa/gh-action-pypi-publish@bea5cda687c2b79989126d589ef4411bedce0195
32+
with:
33+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
34+
repository_url: https://test.pypi.org/legacy/
35+
- name: Publish to PyPI 🚀
36+
uses: pypa/gh-action-pypi-publish@bea5cda687c2b79989126d589ef4411bedce0195
37+
with:
38+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)