-
Notifications
You must be signed in to change notification settings - Fork 1
126 lines (113 loc) · 4.07 KB
/
python-release-uv.yml
File metadata and controls
126 lines (113 loc) · 4.07 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Python Release (uv)
# Creates a GitHub release and publishes the package to PyPI using uv. Would commonly be one of two jobs along
# with Python Deploy Docs in a repo workflow triggered by e.g. tagging a version.
#
# Requires the secret `PYPI_API_TOKEN`.
on:
workflow_call:
inputs:
python-version:
description: The python version to use
required: true
type: string
default: "3.10"
uv-version:
description: The uv version to use
required: false
type: string
default: "latest"
working-directory:
description: The working directory
required: false
type: string
default: .
timeout-minutes:
description: Maximum runtime in minutes
required: false
type: number
default: 10
pypi-publish:
description: Publish to PyPI or not
required: false
type: boolean
default: true
tag-prefix:
description: Prefix stripped from the pushed tag to derive the version
required: false
type: string
default: "v"
changelog-path:
description: Path to the changelog file relative to working-directory
required: false
type: string
default: "CHANGELOG.md"
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout-minutes }}
defaults:
run:
shell: bash
working-directory: ${{ inputs.working-directory }}
steps:
- uses: actions/checkout@v5
#----------------------------------------------
# get version and verify changelog entry
#----------------------------------------------
- name: Get version from tag
id: tag_name
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "current_version=${GITHUB_REF_NAME#${{ inputs.tag-prefix }}}" >> "$GITHUB_OUTPUT"
shell: bash
- name: Get Changelog Entry
id: changelog_reader
if: startsWith(github.ref, 'refs/tags/')
uses: GNS-Science/changelog-reader-action@master
with:
validation_depth: 10
version: ${{ steps.tag_name.outputs.current_version }}
path: ${{ inputs.working-directory }}/${{ inputs.changelog-path }}
- name: install_package
uses: GNS-Science/nshm-github-actions/.github/actions/python-install-uv@main
with:
python-version: ${{ inputs.python-version }}
uv-version: ${{ inputs.uv-version }}
working-directory: ${{ inputs.working-directory }}
#----------------------------------------------
# build wheels and tarball
#----------------------------------------------
- name: Build wheels and source tarball
run: >-
uv build
- name: show temporary files
run: >-
ls -l
#----------------------------------------------
# create GitHub release
#----------------------------------------------
- name: create github release
id: create_release
uses: GNS-Science/action-gh-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: ${{ steps.changelog_reader.outputs.changes }}
files: ${{ inputs.working-directory }}/dist/*.whl
draft: false
prerelease: false
#----------------------------------------------
# publish to PyPI
#----------------------------------------------
- name: publish to PyPI
if: ${{ inputs.pypi-publish }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true