Skip to content

Commit 0ec9b50

Browse files
committed
wip: actions to publish to pypi
1 parent 70e387b commit 0ec9b50

File tree

4 files changed

+102
-2
lines changed

4 files changed

+102
-2
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish Casp CLI to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish-pypi:
9+
name: Build and Publish CLI
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Check for changes in cli/casp
19+
id: check_changes
20+
run: |
21+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || true)
22+
23+
if [ -z "$PREV_TAG" ]; then
24+
echo "No previous tag found (likely first release). Publishing..."
25+
echo "changed=true" >> "$GITHUB_OUTPUT"
26+
else
27+
echo "Previous release tag found: $PREV_TAG"
28+
29+
if git diff --quiet "$PREV_TAG" HEAD -- cli/casp; then
30+
echo "No changes detected in cli/casp."
31+
echo "changed=false" >> "$GITHUB_OUTPUT"
32+
else
33+
echo "Changes detected in cli/casp."
34+
echo "changed=true" >> "$GITHUB_OUTPUT"
35+
fi
36+
fi
37+
38+
- name: Set up Python
39+
if: steps.check_changes.outputs.changed == 'true'
40+
uses: actions/setup-python@v4
41+
with:
42+
python-version: '3.11'
43+
44+
- name: Install build dependencies
45+
if: steps.check_changes.outputs.changed == 'true'
46+
run: python -m pip install build --user
47+
48+
- name: Build package
49+
if: steps.check_changes.outputs.changed == 'true'
50+
working-directory: cli/casp
51+
run: python -m build
52+
53+
- name: Publish to PyPI
54+
if: steps.check_changes.outputs.changed == 'true'
55+
uses: pypa/gh-action-pypi-publish@release/v1
56+
with:
57+
password: ${{ secrets.PYPI_API_TOKEN }}
58+
packages_dir: cli/casp/dist/
59+
skip_existing: true
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish Casp CLI to TestPyPI
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
paths:
7+
- 'cli/casp/**'
8+
9+
jobs:
10+
publish-testpypi:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.11'
21+
22+
- name: Install build dependencies
23+
run: python -m pip install build --user
24+
25+
- name: Build package
26+
working-directory: cli/casp
27+
run: python -m build
28+
29+
- name: Publish to TestPyPI
30+
uses: pypa/gh-action-pypi-publish@release/v1
31+
with:
32+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
33+
repository-url: https://test.pypi.org/legacy/
34+
packages_dir: cli/casp/dist/
35+
skip_existing: true

cli/casp/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "casp"
7-
version = "0.0.8"
7+
version = "2.17.0.1764252874"
88
authors = [
99
{ name="PauloVLB", email="paulovlb@google.com" },
1010
]
1111
description = "A new, modern Command-Line Interface (CLI) for ClusterFuzz."
1212
readme = "README.md"
1313
license = "Apache-2.0"
14-
requires-python = ">=3.6"
14+
requires-python = ">=3.11"
1515
classifiers = [
1616
"Programming Language :: Python :: 3",
1717
"Operating System :: OS Independent",

cli/casp/test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
LAST_TAG=$(git describe --tags --abbrev=0)
2+
VERSION=${LAST_TAG#v}
3+
TIMESTAMP=$(date +%s)
4+
5+
# Set version to <last_tag>.<timestamp> (e.g., 1.0.0.1701234567)
6+
sed -i "s/^version = \".*\"/version = \"$VERSION.$TIMESTAMP\"/" pyproject.toml

0 commit comments

Comments
 (0)