Skip to content

Commit e99d62a

Browse files
authored
Merge pull request #5 from danlsn/4-build-and-publish-dander-to-pypi
4 build and publish dander to pypi
2 parents dd1826b + 58116f4 commit e99d62a

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
publish:
12+
name: Build and publish
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.11'
25+
26+
- name: Ensure PYPI token is available
27+
env:
28+
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
29+
run: |
30+
if [ -z "$PYPI_API_TOKEN" ]; then
31+
echo "Missing secret: PYPI_API_TOKEN" >&2
32+
exit 1
33+
fi
34+
35+
- name: Install build tools
36+
run: python -m pip install --upgrade pip hatch twine
37+
38+
- name: Build distributions
39+
run: hatch build
40+
41+
- name: Create and push tag
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: |
45+
version=$(python -c "import re,io;print(re.search(r'__version__\s*=\s*[\'\"]([^\'\"]+)[\'\"]', open('src/dander/__about__.py').read()).group(1))")
46+
echo "Version: $version"
47+
git config user.name "github-actions[bot]"
48+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
49+
git tag -a "v$version" -m "Release $version" || echo "tag exists"
50+
git push origin "refs/tags/v$version" || echo "push tag failed"
51+
52+
- name: List built artifacts
53+
run: ls -la dist || true
54+
55+
- name: Publish to PyPI with hatch
56+
env:
57+
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
58+
run: |
59+
export HATCH_INDEX_AUTH="__token__:$PYPI_API_TOKEN"
60+
echo "Publishing with hatch..."
61+
hatch publish dist/* --yes

src/dander/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-FileCopyrightText: 2024-present Daniel Lawson <daniel.lawson@rmit.edu.au>
22
#
33
# SPDX-License-Identifier: MIT
4-
__version__ = "0.3.0"
4+
__version__ = "0.3.1"

0 commit comments

Comments
 (0)