Repository navigation
53 lines (43 loc) · 1.46 KB
/
Copy pathreleasing.yml
File metadata and controls
53 lines (43 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: dist
on:
push:
tags:
- "v*" # Only trigger when pushing a version tag like v1.2.3
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: write # Required to create a release
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure full Git history for setuptools-scm
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine setuptools-scm
- name: Verify version from tag
id: get_version
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v} # Extract version from 'vX.Y.Z'
echo "VERSION=$TAG_VERSION" >> $GITHUB_ENV
echo "Publishing version: $TAG_VERSION"
- name: Build package (pyproject.toml)
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ github.ref_name }} dist/* --title "Release ${{ github.ref_name }}" --notes "Automated release for version ${{ github.ref_name }}"