-
Notifications
You must be signed in to change notification settings - Fork 71
59 lines (48 loc) · 1.42 KB
/
build.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
name: build
on:
release:
types: [released]
workflow_dispatch:
defaults:
run:
shell: bash -l {0}
env:
IS_PRERELEASE: ${{ github.event_name == 'workflow_dispatch' }}
jobs:
build-n-publish:
name: Build and publish to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get prerelease version tags
if: env.IS_PRERELEASE == 'true'
run: |
py_dirty_tag=$(awk '/__version__ = "[[:digit:]+]\.[[:digit:]+]\.[[:digit:]+]\-.+"/ {print $3}' ./prolif/_version.py)
py_is_pre=$(test -z "$py_dirty_tag" && echo "false" || echo "true")
echo "py_is_pre=$py_is_pre" >> $GITHUB_ENV
- name: Fail if prerelease is not correctly versioned
if: ( env.IS_PRERELEASE == 'true' ) && !( env.py_is_pre )
uses: actions/github-script@v3
with:
script: |
core.setFailed("Versions are not tagged as a prerelease")
- name: Install python with pip
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies for packaging
run: |
pip install build
- name: Check python installation
run: |
which python
python --version
pip --version
pip list
- name: Build package
run: |
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}