-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (125 loc) · 4.21 KB
/
Copy pathci.yml
File metadata and controls
153 lines (125 loc) · 4.21 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Python Package CI/CD
on:
push:
branches: [main, master]
paths:
- '**.py'
- 'setup.py'
- '.github/workflows/ci.yml'
pull_request:
branches: [main, master]
jobs:
test:
name: Test on ${{ matrix.os }} - Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies only
run: |
python -m pip install --upgrade pip
pip install requests
- name: Test from source (direct execution)
run: |
python dpow/__main__.py
- name: Install package in development mode
run: |
pip install -e .
- name: Test installed package
run: |
python -m dpow
publish:
name: Auto-version and Publish to PyPI
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine requests packaging
- name: Get latest release version and increment
id: version
run: |
# Get latest release tag
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "Latest tag: $LATEST_TAG"
# Remove 'v' prefix if present
VERSION=${LATEST_TAG#v}
echo "Current version: $VERSION"
# Split version into parts
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
# Increment patch version
PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
echo "New version: $NEW_VERSION"
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Update version in setup.py
run: |
sed -i 's/version="[^"]*"/version="${{ steps.version.outputs.version }}"/' setup.py
cat setup.py
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/* || echo "Upload failed, possibly version already exists"
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Release ${{ steps.version.outputs.tag }}
body: |
Automated release ${{ steps.version.outputs.version }}
Changes in this release:
- Auto-generated from commit ${{ github.sha }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
verify-publish:
name: Verify PyPI package on ${{ matrix.os }}
needs: publish
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10"]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Wait for PyPI to update
run: sleep 90
- name: Install from PyPI
run: |
python -m pip install --upgrade pip
pip install --upgrade dpow
- name: Test installed package from PyPI
run: |
python -m dpow
- name: Verify package can be imported
run: |
python -c "import dpow; from dpow import client, server; print('Package imported successfully')"