Skip to content

Commit 5961cad

Browse files
authored
Merge pull request #11 from UMThorntonGroup/publish-from-github-2
make gh release and publish to PyPI when version tag is created
2 parents 7c39777 + 52f392e commit 5961cad

2 files changed

Lines changed: 71 additions & 2 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Publish Python Package
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]*.[0-9]*.[0-9]*'
7+
- 'v[0-9]*.[0-9]*.[0-9]*'
8+
9+
permissions:
10+
contents: write # Required for creating a GitHub release
11+
id-token: write # Required for trusted publishing to PyPI
12+
13+
jobs:
14+
create-release:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Create GitHub Release
22+
id: create_release
23+
uses: actions/create-release@v1
24+
with:
25+
tag_name: ${{ github.ref_name }}
26+
release_name: Release ${{ github.ref_name }}
27+
body: |
28+
This is an automated release for version ${{ github.ref_name }}.
29+
draft: false
30+
prerelease: false
31+
32+
release-build:
33+
runs-on: ubuntu-latest
34+
needs: create-release
35+
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.x"
42+
43+
- name: Build release distributions
44+
run: |
45+
python -m pip install build
46+
python -m build
47+
48+
- name: Upload distributions
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: release-dists
52+
path: dist/
53+
54+
pypi-publish:
55+
runs-on: ubuntu-latest
56+
needs: release-build
57+
environment:
58+
name: release
59+
url: https://pypi.org/project/ammber
60+
61+
steps:
62+
- name: Retrieve release distributions
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: release-dists
66+
path: dist/
67+
68+
- name: Publish release distributions to PyPI
69+
uses: pypa/gh-action-pypi-publish@release/v1
70+
with:
71+
packages-dir: dist/

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ dependencies = [
5151
classifiers=[
5252
'Development Status :: 1 - Planning',
5353
'Intended Audience :: Science/Research',
54-
'Programming Language :: Python :: 2',
55-
'Programming Language :: Python :: 2.7',
5654
'Programming Language :: Python :: 3',
5755
'Programming Language :: Python :: 3.4',
5856
'Programming Language :: Python :: 3.5',

0 commit comments

Comments
 (0)