88 - " rc"
99 - " hotfix-rc"
1010 workflow_dispatch :
11+ inputs :
12+ dev_version :
13+ description : " Create a dev build (e.g., .dev1 suffix)"
14+ default : false
15+ type : boolean
16+ workflow_call :
17+ inputs :
18+ dev_version :
19+ description : " Create a dev build (e.g., .dev1 suffix)"
20+ required : true
21+ type : boolean
22+ outputs :
23+ package_version :
24+ description : " The package version (with optional .devX suffix)"
25+ value : ${{ jobs.setup.outputs.package_version }}
1126
1227defaults :
1328 run :
1429 shell : bash
1530 working-directory : languages/python
1631
32+ env :
33+ _VERSION_FILE : ../../crates/bitwarden-py/Cargo.toml
34+ _TEST_PYPI_REPOSITORY_URL : https://test.pypi.org/pypi/bitwarden-sdk/json
35+
1736permissions :
1837 contents : read
1938
@@ -24,17 +43,57 @@ jobs:
2443
2544 setup :
2645 name : Setup
27- runs-on : ubuntu-22 .04
46+ runs-on : ubuntu-24 .04
2847 outputs :
2948 package_version : ${{ steps.retrieve-version.outputs.package_version }}
49+ package_version_cargo : ${{ steps.retrieve-version.outputs.package_version_cargo }}
3050 steps :
3151 - name : Checkout repo
3252 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3353
3454 - name : Get Package Version
3555 id : retrieve-version
56+ env :
57+ USE_DEV_VERSION : ${{ inputs.dev_version }}
3658 run : |
37- VERSION="$(grep -o '^version = ".*"' ../../crates/bitwarden-py/Cargo.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"
59+ VERSION="$(grep -o '^version = ".*"' "$_VERSION_FILE" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")"
60+
61+ if [ -z "$VERSION" ]; then
62+ echo "==================================="
63+ echo "[!] Could not determine package version from $_VERSION_FILE"
64+ echo "==================================="
65+ exit 1
66+ fi
67+
68+ if [ "$USE_DEV_VERSION" = "true" ]; then
69+ latest_dev_num=0
70+
71+ # Get all versions from PyPI that match the current package version with dev suffix
72+ dev_versions=$(curl -s "$_TEST_PYPI_REPOSITORY_URL" | \
73+ jq -r --arg version "$VERSION" \
74+ '.releases | keys[] | select(test("^" + $version + "\\.dev[0-9]+$"))' || true)
75+
76+ if [ -n "$dev_versions" ]; then
77+ # Extract dev numbers and find the latest
78+ latest_dev_num=$(echo "$dev_versions" | \
79+ sed -n "s/^${VERSION}\.dev\([0-9]\+\)$/\1/p" | \
80+ sort -n | \
81+ tail -1)
82+ else
83+ echo "Failed to retrieve current dev_versions from PyPi."
84+ exit 1
85+ fi
86+
87+ # Increment dev number
88+ new_dev_num=$((latest_dev_num + 1))
89+ dev_version_suffix=".dev${new_dev_num}"
90+
91+ echo "package_version_cargo=${VERSION}-dev${new_dev_num}" >> $GITHUB_OUTPUT
92+
93+ VERSION="${VERSION}${dev_version_suffix}"
94+ fi
95+
96+ echo "Package version: $VERSION"
3897 echo "package_version=$VERSION" >> $GITHUB_OUTPUT
3998
4099 build :
@@ -64,12 +123,12 @@ jobs:
64123 python-version : " 3.9"
65124 maturin-build-args : " "
66125
67- - os : ubuntu-22 .04
126+ - os : ubuntu-24 .04
68127 target : x86_64-unknown-linux-gnu
69128 python-version : " 3.9"
70129 maturin-build-args : " --zig"
71130
72- - os : ubuntu-22 .04
131+ - os : ubuntu-24 .04
73132 target : aarch64-unknown-linux-gnu
74133 python-version : " 3.9"
75134 maturin-build-args : " --zig"
@@ -78,6 +137,23 @@ jobs:
78137 - name : Checkout repo
79138 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
80139
140+ - name : Add dev version suffix
141+ if : ${{ inputs.dev_version }}
142+ env :
143+ PACKAGE_VERSION_CARGO : ${{ needs.setup.outputs.package_version_cargo }}
144+ run : |
145+ echo "Updating version files with: $_PACKAGE_VERSION"
146+
147+ inplace_arg="-i"
148+ # Use sed with cross-platform compatibility (macOS and Linux)
149+ if [[ "$OSTYPE" == "darwin"* ]]; then
150+ inplace_arg="-i ''"
151+ fi
152+
153+ sed $inplace_arg "s/^version = \"[0-9]\.[0-9]\.[0-9]\"/version = \"$PACKAGE_VERSION_CARGO\"/" "$_VERSION_FILE"
154+ sed $inplace_arg "s/__version__ = \"[0-9]\.[0-9]\.[0-9]\"/__version__ = \"$_PACKAGE_VERSION\"/" bitwarden_sdk/__init__.py
155+ git diff
156+
81157 - name : Setup Python
82158 uses : actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
83159 with :
@@ -117,15 +193,15 @@ jobs:
117193 target : ${{ matrix.settings.target }}
118194 args : --release --interpreter python${{ matrix.settings.python-version }} ${{ matrix.settings.maturin-build-args }}
119195 sccache : true
120- working-directory : ${{ github.workspace }}/ languages/python
196+ working-directory : languages/python
121197
122198 - name : Build wheels (Linux - x86_64)
123199 if : ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
124200 uses : PyO3/maturin-action@ea5bac0f1ccd0ab11c805e2b804bfcb65dac2eab # v1.45.0
125201 with :
126202 target : ${{ matrix.settings.target }}
127203 args : --release --sdist --interpreter python${{ matrix.settings.python-version }} ${{ matrix.settings.maturin-build-args }}
128- working-directory : ${{ github.workspace }}/ languages/python
204+ working-directory : languages/python
129205
130206 - name : Upload wheels
131207 uses : actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
0 commit comments