-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (87 loc) · 2.95 KB
/
Copy pathpublish.yml
File metadata and controls
101 lines (87 loc) · 2.95 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Build wheels/sdist, create a GitHub Release (auto-generated release notes), and publish to PyPI — **manual only**.
#
# 1. Bump `version` in `pyproject.toml` and `tmd/__version__.py`, commit, push.
# 2. Push an annotated tag for that commit, e.g.:
# git tag -a v1.0.6 -m "Release v1.0.6" && git push origin v1.0.6
# 3. In GitHub: Actions → "Release and publish" → Run workflow → enter that tag as **ref** (e.g. v1.0.6).
#
# The release step uses `generate_release_notes: true` so GitHub fills the body from merged PRs/commits.
# PyPI is not triggered by tag push; only this workflow_dispatch run publishes.
name: Release and publish
on:
workflow_dispatch:
inputs:
ref:
description: "Existing git tag to build and publish (e.g. v1.0.6). Push the tag before running."
required: true
type: string
permissions:
contents: write
id-token: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Validate release ref
run: |
ref="${{ inputs.ref }}"
case "$ref" in
v*.*.*) ;;
*)
echo "::error::ref must be a semver-style tag on the remote (e.g. v1.0.6). Got: $ref"
exit 1
;;
esac
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .
- name: Test with pytest
run: pytest --cov=tmd tests/
release-and-pypi:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build sdist and wheel
run: python -m build
- name: Verify package
run: twine check dist/*
- name: Create GitHub Release
uses: softprops/action-gh-release@v3.0.0
with:
tag_name: ${{ inputs.ref }}
files: dist/*
# Let GitHub generate the changelog from commits/PRs since the previous tag.
generate_release_notes: true
draft: false
fail_on_unmatched_files: true
make_latest: true
# Allow re-running this workflow for the same tag (e.g. after a transient PyPI failure).
allowUpdates: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true