-
Notifications
You must be signed in to change notification settings - Fork 534
132 lines (118 loc) · 4.08 KB
/
build_wheels.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
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
name: Build loadgen wheels and release them into PYPI
on:
release:
types: [published]
push:
branches:
- master
- loadgen-release
- dev
paths:
- loadgen/**
jobs:
update_version:
name: Update version only on ubuntu but used by windows and macos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Check if VERSION.txt file has changed in this push
- name: Check if VERSION.txt file has changed
id: version_changed
run: |
echo "version_changed=false" >> $GITHUB_ENV
echo "new_version=" >> $GITHUB_ENV # Initialize with empty value
<<<<<<< HEAD
if git diff --name-only HEAD~1 | grep -q "VERSION.txt"; then
=======
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q "VERSION.txt"; then
>>>>>>> origin/dev
echo "VERSION.txt file has been modified"
echo "version_changed=true" >> $GITHUB_ENV
new_version=$(cat VERSION.txt)
echo "new_version=$new_version" >> $GITHUB_ENV
else
echo "VERSION.txt file has NOT been modified"
fi
# Step 4: Increment version if VERSION.txt was not changed
- name: Increment version if necessary
id: do_version_increment
if: env.version_changed == 'false'
run: |
cd loadgen
# Check if VERSION file exists, else initialize it
if [ ! -f VERSION.txt ]; then
echo "0.0.0" > VERSION.txt
fi
version=$(cat VERSION.txt)
IFS='.' read -r major minor patch <<< "$version"
patch=$((patch + 1))
new_version="$major.$minor.$patch"
echo $new_version > VERSION.txt
echo "New version: $new_version"
echo "new_version=$new_version" >> $GITHUB_ENV
# Step 5: Commit the updated version to the repository
- name: Commit updated version
if: env.version_changed == 'false'
run: |
cd loadgen
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git add VERSION.txt
git commit -m "Increment version to $new_version"
git push
build_wheels:
name: Build wheels on ${{ matrix.os }}
needs: update_version
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Install requirements
run: python -m pip install cibuildwheel twine
- name: Build wheels
run: git pull && python -m cibuildwheel loadgen/ --output-dir wheels
# Save wheels as artifacts
- name: Upload built wheels
uses: actions/upload-artifact@v3
with:
name: wheels-${{ matrix.os }}
path: wheels
publish_wheels:
needs: build_wheels # Wait for the build_wheels job to complete
runs-on: ubuntu-latest # Only run this job on Linux
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v3
# Download the built wheels from ubuntu
- name: Download Ubuntu wheels
uses: actions/download-artifact@v3
with:
name: wheels-ubuntu-latest
path: wheels
# Download the built wheels from macOS
- name: Download macOS wheels
uses: actions/download-artifact@v3
with:
name: wheels-macos-latest
path: wheels
# Download the built wheels from Windows
- name: Download Windows wheels
uses: actions/download-artifact@v3
with:
name: wheels-windows-latest
path: wheels
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
verify-metadata: true
skip-existing: true
packages-dir: wheels
repository-url: https://upload.pypi.org/legacy/
verbose: true