Skip to content

Commit 304f0fa

Browse files
[#310] Publish bsk_rl wheels to PyPi
1 parent 8d03f72 commit 304f0fa

File tree

3 files changed

+119
-3
lines changed

3 files changed

+119
-3
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Publish Wheels
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]*"
7+
- "test*"
8+
9+
jobs:
10+
build-wheels:
11+
name: Build BSK-RL Wheels
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os:
17+
- macos-13 # x86_64
18+
- macos-latest # ARM64
19+
- ubuntu-latest # x86_64
20+
- ubuntu-22.04-arm # ARM64
21+
- windows-latest # x86_64
22+
23+
steps:
24+
- name: Checkout Code
25+
uses: actions/checkout@v5
26+
with:
27+
ref: ${{ github.ref }}
28+
29+
- name: Build wheels
30+
uses: pypa/cibuildwheel@v3.1.4
31+
32+
- name: Upload wheels
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
36+
path: ./wheelhouse/*.whl
37+
38+
make_sdist:
39+
name: Make SDist
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v5
43+
with:
44+
ref: ${{ github.ref }}
45+
46+
- uses: actions/setup-python@v5
47+
with:
48+
python-version: 3.13
49+
50+
- name: Build SDist
51+
run: pipx run build --sdist
52+
53+
- uses: actions/upload-artifact@v4
54+
with:
55+
name: cibw-sdist
56+
path: dist/*.tar.gz
57+
58+
publish:
59+
name: Publish to PyPI
60+
needs: [build-wheels, make_sdist]
61+
runs-on: ubuntu-latest
62+
permissions:
63+
id-token: write
64+
contents: read
65+
steps:
66+
- name: Checkout tagged source
67+
uses: actions/checkout@v5
68+
with:
69+
ref: ${{ github.ref }}
70+
fetch-depth: 0
71+
72+
- name: Download wheels
73+
uses: actions/download-artifact@v4
74+
with:
75+
pattern: cibw-wheels-*
76+
merge-multiple: true
77+
path: dist
78+
79+
- name: Download sdist
80+
uses: actions/download-artifact@v4
81+
with:
82+
name: cibw-sdist
83+
path: dist
84+
85+
- name: Publish to TestPyPI (test tags)
86+
if: startsWith(github.ref, 'refs/tags/test')
87+
uses: pypa/gh-action-pypi-publish@release/v1
88+
with:
89+
repository-url: https://test.pypi.org/legacy/
90+
packages-dir: dist
91+
skip-existing: true
92+
verbose: true
93+
94+
- name: Publish to PyPI (real releases)
95+
if: startsWith(github.ref, 'refs/tags/v')
96+
uses: pypa/gh-action-pypi-publish@release/v1
97+
with:
98+
packages-dir: dist

.github/workflows/pull_request_closed.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@ jobs:
1919
ref: develop
2020
fetch-depth: 0
2121
token: ${{ secrets.BOT_ACCESS_TOKEN }}
22+
2223
- name: Bump version
2324
run: ./.github/workflows/version_bumper.sh ./pyproject.toml
25+
id: bump
26+
2427
- name: Commit and push
2528
run: |
2629
git config user.name "AVSlabBot"
2730
git config user.email "cuavslab@gmail.com"
2831
git commit -a -m "[AUTO] Bump minor version number"
2932
git push
33+
34+
- name: Create tag
35+
if: ${{ steps.bump.outputs.updated_version != '' }}
36+
run: |
37+
git tag -a "v${{ steps.bump.outputs.updated_version }}" \
38+
-m "Release v${{ steps.bump.outputs.updated_version }}"
39+
git push --tags

.github/workflows/version_bumper.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@ if [[ $version_line =~ $regex ]]; then
2323
last_number=${BASH_REMATCH[2]}
2424
incremented_number=$((last_number + 1))
2525
updated_version=${BASH_REMATCH[1]}$incremented_number
26-
26+
2727
# Update the version in the pyproject.toml file
2828
sed -i "s/version = \"${BASH_REMATCH[1]}${last_number}\"/version = \"$updated_version\"/" "$file"
29-
29+
3030
echo "Version updated to $updated_version in $file"
3131
else
3232
echo "Error: Version not found in $file or not in X.Y.Z format"
3333
exit 1
34-
fi
34+
fi
35+
36+
37+
# Expose the update versions to GitHub Actions
38+
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
39+
{
40+
echo "updated_version=$updated_version"
41+
} >> "$GITHUB_OUTPUT"
42+
fi

0 commit comments

Comments
 (0)