-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (54 loc) · 1.81 KB
/
test-publish.yaml
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
name: Publish Package (PyPI)
on:
pull_request:
branches:
- main
jobs:
build_and_publish:
name: "Build and Publish PyPI package - TEST"
runs-on: ubuntu-latest
environment:
name: pypi
url: https://test.pypi.org/p/oakutils
permissions:
id-token: write
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build toml
- name: Update version in pyproject.toml
run: |
python3 << END
import toml
import os
from datetime import datetime
# Read the current pyproject.toml
with open('pyproject.toml', 'r') as f:
config = toml.load(f)
# Get the current version
current_version = config['project']['version']
# Create a unique version using GitHub run number and current date
run_number = os.environ['GITHUB_RUN_NUMBER']
current_date = datetime.now().strftime("%Y%m%d")
new_version = f"{current_version}.dev{current_date}{run_number}"
# Update the version in the config
config['project']['version'] = new_version
# Write the updated config back to pyproject.toml
with open('pyproject.toml', 'w') as f:
toml.dump(config, f)
print(f"Updated version to {new_version}")
END
- name: Build oakutils
run: |
python -m build --sdist --wheel --outdir dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_API_TOKEN }}