Skip to content

Commit 2540f2e

Browse files
committed
docs: Split README.md per action
1 parent 8554e7e commit 2540f2e

File tree

5 files changed

+270
-291
lines changed

5 files changed

+270
-291
lines changed

README.md

Lines changed: 12 additions & 291 deletions
Original file line numberDiff line numberDiff line change
@@ -2,294 +2,15 @@
22

33
`ni/python-actions` is a Git repository containing reusable GitHub Actions for NI Python projects.
44

5-
## Table of Contents
6-
7-
- [`ni/python-actions`](#nipython-actions)
8-
- [Table of Contents](#table-of-contents)
9-
- [`ni/python-actions/setup-python`](#nipython-actionssetup-python)
10-
- [Usage](#usage)
11-
- [Inputs](#inputs)
12-
- [`python-version`](#python-version)
13-
- [Outputs](#outputs)
14-
- [`python-version`](#python-version-1)
15-
- [`python-path`](#python-path)
16-
- [Environment Variables](#environment-variables)
17-
- [`pythonVersion`](#pythonversion)
18-
- [`ni/python-actions/setup-poetry`](#nipython-actionssetup-poetry)
19-
- [Usage](#usage-1)
20-
- [Inputs](#inputs-1)
21-
- [`poetry-version`](#poetry-version)
22-
- [`use-cache`](#use-cache)
23-
- [Outputs](#outputs-1)
24-
- [`cache-hit`](#cache-hit)
25-
- [`ni/python-actions/check-project-version`](#nipython-actionscheck-project-version)
26-
- [Usage](#usage-2)
27-
- [Inputs](#inputs-2)
28-
- [`project-directory`](#project-directory)
29-
- [`expected-version`](#expected-version)
30-
- [`ni/python-actions/update-project-version`](#nipython-actionsupdate-project-version)
31-
- [Usage](#usage-3)
32-
- [Inputs](#inputs-3)
33-
- [`project-directory`](#project-directory-1)
34-
- [`branch-prefix`](#branch-prefix)
35-
- [`create-pull-request`](#create-pull-request)
36-
- [`version-rule` and `use-dev-suffix`](#version-rule-and-use-dev-suffix)
37-
- [`token`](#token)
38-
39-
## `ni/python-actions/setup-python`
40-
41-
The `setup-python` action installs Python and adds it to the PATH.
42-
43-
It is a thin wrapper for https://github.com/actions/setup-python which is intended to
44-
single-source the default Python version for multiple NI Python projects.
45-
46-
By default, this action installs Python 3.11.9.
47-
48-
### Usage
49-
50-
```yaml
51-
steps:
52-
- uses: ni/python-actions/[email protected]
53-
```
54-
55-
### Inputs
56-
57-
#### `python-version`
58-
59-
You can specify the `python-version` input for testing with multiple versions of Python:
60-
61-
```yaml
62-
strategy:
63-
matrix:
64-
python-version: [3.9, '3.10', 3.11, 3.12, 3.13]
65-
steps:
66-
- uses: ni/python-actions/[email protected]
67-
with:
68-
python-version: ${{ matrix.python-version }}
69-
```
70-
71-
### Outputs
72-
73-
#### `python-version`
74-
75-
You can use the `python-version` output to get the actual version of Python, which is useful for caching:
76-
77-
```yaml
78-
steps:
79-
- uses: ni/python-actions/[email protected]
80-
id: setup-python
81-
- uses: actions/cache@v4
82-
with:
83-
path: .venv
84-
key: venv-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
85-
```
86-
87-
`python-version` is unique across implementations (CPython vs. PyPy) and free-threaded builds:
88-
89-
- CPython: "3.13.4".
90-
- CPython with free-threading: "3.13.4t"
91-
- PyPy: "pypy3.11.11-v7.3.19"
92-
93-
#### `python-path`
94-
95-
`actions/setup-python` sets the `pythonLocation` environment variable to the **directory**
96-
containing the Python installation.
97-
98-
You can also use the `python-path` output to get the path to the Python interpreter:
99-
100-
```yaml
101-
steps:
102-
- uses: ni/python-actions/[email protected]
103-
id: setup-python
104-
- run: pipx install <package> --python ${{ steps.setup-python.outputs.python-version }}
105-
```
106-
107-
### Environment Variables
108-
109-
#### `pythonVersion`
110-
111-
This is the same as `outputs.python-version` and is mainly intended for use in
112-
`ni/python-actions/setup-poetry`.
113-
114-
## `ni/python-actions/setup-poetry`
115-
116-
The `setup-poetry` action installs Poetry, adds it to the PATH, and caches it to speed up
117-
workflows.
118-
119-
This action installs Poetry using the Python version that was selected by the `setup-python`
120-
action, so you must call `setup-python` first.
121-
122-
By default, this action installs Poetry 2.1.4.
123-
124-
### Usage
125-
126-
```yaml
127-
steps:
128-
- uses: ni/python-actions/[email protected]
129-
- uses: ni/python-actions/[email protected]
130-
- run: poetry install -v
131-
```
132-
133-
### Inputs
134-
135-
#### `poetry-version`
136-
137-
```yaml
138-
steps:
139-
- uses: ni/python-actions/[email protected]
140-
- uses: ni/python-actions/[email protected]
141-
with:
142-
poetry-version: 2.1.4
143-
- run: poetry install -v
144-
```
145-
146-
#### `use-cache`
147-
148-
If you run into caching problems, you can disable caching by specifying `use-cache: false`.
149-
150-
### Outputs
151-
152-
#### `cache-hit`
153-
154-
You can use `cache-hit` to check whether Poetry was loaded from cache. This is mainly intended for
155-
testing the action.
156-
157-
## `ni/python-actions/check-project-version`
158-
159-
The `check-project-version` action uses Poetry to get the version of a Python project and checks
160-
that it matches an expected version. By default, this action checks against `github.ref_name`, which
161-
is the GitHub release tag for GitHub release events.
162-
163-
This action requires Poetry, so you must call `setup-python` and `setup-poetry` first.
164-
165-
### Usage
166-
167-
```yaml
168-
steps:
169-
- uses: ni/python-actions/[email protected]
170-
- uses: ni/python-actions/[email protected]
171-
- uses: ni/python-actions/[email protected]
172-
if: github.event_name == 'release'
173-
```
174-
175-
### Inputs
176-
177-
#### `project-directory`
178-
179-
You can specify `project-directory` to check a project located in a subdirectory.
180-
181-
```yaml
182-
- uses: ni/python-actions/[email protected]
183-
with:
184-
project-directory: packages/foo
185-
```
186-
187-
#### `expected-version`
188-
189-
You can specify `expected-version` to check against something other than `github.ref_name`.
190-
191-
```yaml
192-
- uses: ni/python-actions/[email protected]
193-
with:
194-
expected-version: ${{ steps.get-expected-version.outputs.version }}
195-
```
196-
197-
## `ni/python-actions/update-project-version`
198-
199-
The `update-project-version` action uses Poetry to update the version of a Python project and
200-
creates a pull request to modify its `pyproject.toml` file.
201-
202-
This action requires Poetry, so you must call `setup-python` and `setup-poetry` first.
203-
204-
Creating a pull request requires the workflow or job to have the following `GITHUB_TOKEN`
205-
permissions:
206-
207-
```yaml
208-
permissions:
209-
contents: write
210-
pull-requests: write
211-
````
212-
213-
### Usage
214-
215-
```yaml
216-
steps:
217-
- uses: ni/python-actions/[email protected]
218-
- uses: ni/python-actions/[email protected]
219-
- uses: ni/python-actions/[email protected]
220-
```
221-
222-
### Inputs
223-
224-
#### `project-directory`
225-
226-
You can specify `project-directory` to update a project located in a subdirectory.
227-
228-
```yaml
229-
- uses: ni/python-actions/[email protected]
230-
with:
231-
project-directory: packages/foo
232-
```
233-
234-
#### `branch-prefix`
235-
236-
You can specify `branch-prefix` to customize the pull request branch names. The default value of
237-
`users/build/` generates pull requests with names like `users/build/update-project-version-main` and
238-
`users/build/update-project-version-releases-1.1`.
239-
240-
```yaml
241-
- uses: ni/python-actions/[email protected]
242-
with:
243-
branch-prefix: users/python-build/
244-
```
245-
246-
#### `create-pull-request`
247-
248-
You can use `create-pull-request` and `project-directory` to update multiple projects with a single
249-
pull request.
250-
251-
```yaml
252-
- uses: ni/python-actions/[email protected]
253-
with:
254-
project-directory: packages/foo
255-
create-pull-request: false
256-
- uses: ni/python-actions/[email protected]
257-
with:
258-
project-directory: packages/bar
259-
create-pull-request: false
260-
- uses: ni/python-actions/[email protected]
261-
with:
262-
project-directory: packages/baz
263-
create-pull-request: true
264-
```
265-
266-
#### `version-rule` and `use-dev-suffix`
267-
268-
You can specify `version-rule` and `use-dev-suffix` to customize the versioning scheme.
269-
270-
- `version-rule` specifies the rule for updating the version number. For example, `major` will
271-
update 1.0.0 -> 2.0.0, while `patch` will update 1.0.0 -> 1.0.1. See [the docs for `poetry
272-
version`](https://python-poetry.org/docs/cli/#version) for the list of rules and their behavior.
273-
- `use-dev-suffix` specifies whether to use development versions like `1.0.0.dev0`.
274-
275-
The defaults are `version-rule=patch` and `use-dev-suffix=true`, which have the following behavior:
276-
277-
| Old Version | New Version |
278-
| ----------- | ----------- |
279-
| 1.0.0 | 1.0.1.dev0 |
280-
| 1.0.1.dev0 | 1.0.1.dev1 |
281-
| 1.0.1.dev1 | 1.0.1.dev2 |
282-
283-
When you are ready to exit the "dev" phase, you should manually update the version number to the
284-
desired release version before creating a release in GitHub.
285-
286-
#### `token`
287-
288-
The default GITHUB_TOKEN cannot trigger PR workflows, so the generated pull request will not run any
289-
status checks. You can work around this by using `token` to specify a token that is saved in a
290-
repo/org secret.
291-
292-
See [Triggering further workflow
293-
runs](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs)
294-
in the `create-pull-request` action documentation for more info about this problem and other
295-
solutions to it.
5+
## Actions
6+
7+
- [`ni/python-actions/setup-python`](setup-python): installs Python and adds it to the PATH,
8+
single-sourcing the default Python version for multiple NI Python projects.
9+
- [`ni/python-actions/setup-poetry`](setup-poetry): installs Poetry, adds it to the PATH, and caches
10+
it to speed up workflows.
11+
- [`ni/python-actions/check-project-version`](check-project-version): uses Poetry to get the version
12+
of a Python project and checks that it matches an expected version. Publish workflows can use this
13+
to verify that the release tag matches the version number in `pyproject.toml`.
14+
- [`ni/python-actions/update-project-version`](update-project-version): uses Poetry to update the
15+
version of a Python project and creates a pull request to modify its `pyproject.toml` file.
16+
Publish workflows can use this to update the version in `pyproject.toml` for the next build.

check-project-version/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# `ni/python-actions/check-project-version`
2+
3+
The `check-project-version` action uses Poetry to get the version of a Python project and checks
4+
that it matches an expected version. Publish workflows can use this to verify that the release tag
5+
matches the version number in `pyproject.toml`.
6+
7+
By default, this action checks against `github.ref_name`, which is the GitHub release tag for GitHub
8+
release events.
9+
10+
This action requires Poetry, so you must call `setup-python` and `setup-poetry` first.
11+
12+
## Usage
13+
14+
```yaml
15+
steps:
16+
- uses: ni/python-actions/[email protected]
17+
- uses: ni/python-actions/[email protected]
18+
- uses: ni/python-actions/[email protected]
19+
if: github.event_name == 'release'
20+
```
21+
22+
## Inputs
23+
24+
### `project-directory`
25+
26+
You can specify `project-directory` to check a project located in a subdirectory.
27+
28+
```yaml
29+
- uses: ni/python-actions/[email protected]
30+
with:
31+
project-directory: packages/foo
32+
```
33+
34+
### `expected-version`
35+
36+
You can specify `expected-version` to check against something other than `github.ref_name`.
37+
38+
```yaml
39+
- uses: ni/python-actions/[email protected]
40+
with:
41+
expected-version: ${{ steps.get-expected-version.outputs.version }}
42+
```

setup-poetry/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# `ni/python-actions/setup-poetry`
2+
3+
The `setup-poetry` action installs Poetry, adds it to the PATH, and caches it to speed up
4+
workflows.
5+
6+
This action installs Poetry using the Python version that was selected by the `setup-python`
7+
action, so you must call `setup-python` first.
8+
9+
By default, this action installs Poetry 2.1.4.
10+
11+
## Usage
12+
13+
```yaml
14+
steps:
15+
- uses: ni/python-actions/[email protected]
16+
- uses: ni/python-actions/[email protected]
17+
- run: poetry install -v
18+
```
19+
20+
## Inputs
21+
22+
### `poetry-version`
23+
24+
```yaml
25+
steps:
26+
- uses: ni/python-actions/[email protected]
27+
- uses: ni/python-actions/[email protected]
28+
with:
29+
poetry-version: 2.1.4
30+
- run: poetry install -v
31+
```
32+
33+
### `use-cache`
34+
35+
If you run into caching problems, you can disable caching by specifying `use-cache: false`.
36+
37+
## Outputs
38+
39+
### `cache-hit`
40+
41+
You can use `cache-hit` to check whether Poetry was loaded from cache. This is mainly intended for
42+
testing the action.

0 commit comments

Comments
 (0)