Skip to content

Commit a226e7f

Browse files
Merge pull request #230 from blacklanternsecurity/dev
Better publishing
2 parents 501d238 + 09de1ae commit a226e7f

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

.github/workflows/python-tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ jobs:
6060
- name: Build PyPi package
6161
run: uv run maturin build --release --out dist
6262
- name: Publish PyPi package
63-
# TODO: Remove || true
64-
run: uv run maturin publish --username __token__ --password ${{ secrets.PYPI_TOKEN }} || true
63+
run: uv run maturin publish --skip-existing --username __token__ --password ${{ secrets.PYPI_TOKEN }}
6564
linux:
6665
runs-on: ${{ matrix.platform.runner }}
6766
needs: publish

.github/workflows/rust-tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,10 @@ jobs:
5151
uses: actions-rust-lang/setup-rust-toolchain@v1
5252

5353
- name: Publish to crates.io
54-
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
54+
run: |
55+
VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
56+
if cargo search cloudcheck --limit 1 | head -1 | grep -q "$VERSION"; then
57+
echo "Version $VERSION already exists on crates.io, skipping publish"
58+
else
59+
cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
60+
fi

cloudcheck_update/cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
import os
12
import sys
23
from cloudcheck_update import update
34

45

56
def main():
7+
threshold = int(os.environ.get("ERROR_THRESHOLD", 10))
68
errors = update()
79
for error in errors:
810
print(error)
9-
return 1 if errors else 0
11+
error_count = len(errors)
12+
if error_count > threshold:
13+
print(f"Error count ({error_count}) exceeds threshold ({threshold})")
14+
return 1
15+
elif error_count > 0:
16+
print(f"Error count ({error_count}) within threshold ({threshold})")
17+
return 0
1018

1119

1220
if __name__ == "__main__":

0 commit comments

Comments
 (0)