Skip to content

Commit f5c5c8d

Browse files
authored
Merge pull request #334 from ldx/vn/release
Automate releases
2 parents afe5cb1 + bb2b43b commit f5c5c8d

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

.github/workflows/build.yaml

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on:
33
push:
44
branches:
55
- main
6+
tags:
7+
- "v*"
68
pull_request:
79
jobs:
810
build-and-test:
@@ -23,10 +25,59 @@ jobs:
2325
with:
2426
python-version: ${{ matrix.python-version }}
2527
- name: Build package
26-
run: python setup.py build
27-
- name: Install package
28-
run: python setup.py install
28+
run: |
29+
python -m pip install --upgrade build twine
30+
python -m build
31+
twine check --strict dist/*
2932
- name: Install coveralls
3033
run: sudo pip install coveralls
3134
- name: Run tests
3235
run: sudo PATH=$PATH coverage run setup.py test
36+
37+
release:
38+
runs-on: ubuntu-latest
39+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
40+
needs:
41+
- build-and-test
42+
steps:
43+
- name: Check out code
44+
uses: actions/checkout@v2
45+
- name: Set up Python
46+
uses: actions/setup-python@v2
47+
with:
48+
python-version: "3.x"
49+
- name: Build package
50+
run: |
51+
python -m pip install --upgrade build twine
52+
python -m build
53+
twine check --strict dist/*
54+
- name: Publish package
55+
uses: pypa/gh-action-pypi-publish@release/v1
56+
with:
57+
user: __token__
58+
password: ${{ secrets.PYPI_API_TOKEN }}
59+
- name: Create GitHub release
60+
id: create_release
61+
uses: actions/create-release@v1
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
with:
65+
tag_name: ${{ github.ref }}
66+
release_name: ${{ github.ref }}
67+
draft: false
68+
prerelease: false
69+
- name: Set asset name
70+
run: |
71+
export PKG=$(ls dist/ | grep tar)
72+
set -- $PKG
73+
echo "name=$1" >> $GITHUB_ENV
74+
- name: Upload release asset to GitHub
75+
id: upload-release-asset
76+
uses: actions/upload-release-asset@v1
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
with:
80+
upload_url: ${{ steps.create_release.outputs.upload_url }}
81+
asset_path: dist/${{ env.name }}
82+
asset_name: ${{ env.name }}
83+
asset_content_type: application/zip

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
name=__pkgname__,
1616
version=__version__,
1717
description="Python bindings for iptables",
18+
long_description="Python bindings for classic iptables",
19+
long_description_content_type="text/x-rst",
1820
author="Vilmos Nebehaj",
1921
author_email="[email protected]",
2022
url="https://github.com/ldx/python-iptables",

0 commit comments

Comments
 (0)