Skip to content

Commit 9b24aff

Browse files
committed
chore(release): automate through github actions
1 parent 2e03d99 commit 9b24aff

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

.github/workflows/pypi-release.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: PyPI release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
RELEASE_TAG: ${{ github.event.release.tag_name }}
9+
PYTHON_VERSION: 3.11
10+
# CACHE: "poetry"
11+
12+
jobs:
13+
repository-check:
14+
name: Repository check
15+
runs-on: ubuntu-latest
16+
17+
release-prowler-job:
18+
runs-on: ubuntu-latest
19+
needs: repository-check
20+
env:
21+
POETRY_VIRTUALENVS_CREATE: "false"
22+
name: Release py-ocsf-models to PyPI
23+
steps:
24+
25+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
27+
- name: Install dependencies
28+
run: |
29+
pipx install poetry==2.1.1
30+
31+
- name: Setup Python
32+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
33+
with:
34+
python-version: ${{ env.PYTHON_VERSION }}
35+
# cache: ${{ env.CACHE }}
36+
37+
- name: Build py-ocsf-models package
38+
run: |
39+
poetry build
40+
41+
- name: Publish py-ocsf-models package to PyPI
42+
run: |
43+
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}
44+
poetry publish

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ repos:
8585
# For running trufflehog in docker, use the following entry instead:
8686
# entry: bash -c 'docker run -v "$(pwd):/workdir" -i --rm trufflesecurity/trufflehog:latest git file:///workdir --only-verified --fail'
8787
language: system
88-
stages: ["commit", "push"]
88+
stages: ["pre-commit", "pre-push"]
8989

9090
- id: bandit
9191
name: bandit

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ import py_ocsf_models
3535

3636
You can find ready-to-run examples demonstrating how to generate events using the OCSF schema in the [examples](./examples/) folder.
3737

38+
## How to Release
39+
40+
To release a new version of `py-ocsf-models`:
41+
42+
1. **Create a PR with version update**: Update the version number in `pyproject.toml` and create a pull request with the changes.
43+
44+
2. **Create a GitHub release**: Once the PR is merged into the master branch, create a new release in GitHub from the master branch. This will automatically trigger the `pypi-release.yml` workflow to publish the package to PyPI.
3845

3946
## Contributing
4047
Contributions are welcome! Whether you're fixing a bug, adding new features, or improving the documentation, please feel free to make a pull request or open an issue.

0 commit comments

Comments
 (0)