-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (68 loc) · 2.03 KB
/
build-and-publish-to-pypi.yml
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
---
name: Release->Build and Publish to PyPi
# yamllint disable rule:line-length
on:
release:
types: [published]
# set the run-name
run-name: ${{ github.ref_name }} -> Release->Build and Publish Pypi (
${{ github.run_attempt }}
)
jobs:
output_debug_info:
name: Output debug info
runs-on: ubuntu-latest
steps:
- name: Get current date and time
id: datetime
run: |
datetime=$(date +'%Y-%m-%dT%H-%M-%SZ')
echo "datetime=$datetime" >> $GITHUB_OUTPUT
- name: Display Run Name
run: echo ${{ steps.datetime.outputs.datetime }}
build_and_publish:
name: Build artifacts and publish to pyPi
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up Python 3.11
uses: actions/[email protected]
with:
python-version: 3.11
- name: Update pip and install hatch
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Get version
id: get_version
run: |
export version=$(hatch version)
echo "version=$version" >> $GITHUB_OUTPUT
#validates that the version is a valid semver
- name: Validate version
id: validate_version
run: |
if [[ ! ${{ steps.get_version.outputs.version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version: ${{ steps.get_version.outputs.version }}"
exit 1
fi
- name: Hatch build
run: hatch build
- name: Display structure of build files
id: display_build_files
run: |
ls -R dist/
- name: Archive all artifacts in dist/
uses: actions/[email protected]
with:
name: dist-v${{ steps.get_version.outputs.version }}
path: dist/
if-no-files-found: error
- name: Publish to PyPi
uses: pypa/[email protected]
# with:
# repository-url: https://test.pypi.org/legacy/