Skip to content

Commit 992cff4

Browse files
authored
Merge pull request #138 from BioPandas/publish-on-release
add autopublish
2 parents c7ce8fb + b91978f commit 992cff4

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/autopublish.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# To create a release, create a tag and push it to GitHub:
2+
#git tag -a "v0.0.1-beta" -m "beta version testing"
3+
#git push --tags
4+
# https://dev.to/iamtekson/publish-package-to-pypi-and-release-new-version-using-github-actions-108k
5+
name: Publish BioPandas to PyPI / GitHub
6+
7+
on:
8+
push:
9+
tags:
10+
- "v*"
11+
jobs:
12+
build-n-publish:
13+
name: Build and publish to PyPI
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout source
18+
uses: actions/checkout@v3
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: "3.x"
24+
25+
- name: Build source and wheel distributions
26+
run: |
27+
python -m pip install --upgrade build twine
28+
python -m build
29+
twine check --strict dist/*
30+
- name: Publish distribution to PyPI
31+
uses: pypa/gh-action-pypi-publish@release/v1
32+
with:
33+
user: __token__
34+
password: ${{ secrets.PYPI_API_TOKEN }}
35+
36+
- name: Create GitHub Release
37+
id: create_release
38+
uses: actions/create-release@v1
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
41+
with:
42+
tag_name: ${{ github.ref }}
43+
release_name: ${{ github.ref }}
44+
draft: false
45+
prerelease: false
46+
47+
- name: Get Asset name
48+
run: |
49+
export PKG=$(ls dist/ | grep tar)
50+
set -- $PKG
51+
echo "name=$1" >> $GITHUB_ENV
52+
- name: Upload Release Asset (sdist) to GitHub
53+
id: upload-release-asset
54+
uses: actions/upload-release-asset@v1
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
with:
58+
upload_url: ${{ steps.create_release.outputs.upload_url }}
59+
asset_path: dist/${{ env.name }}
60+
asset_name: ${{ env.name }}
61+
asset_content_type: application/zip

0 commit comments

Comments
 (0)