Skip to content

Commit 369454a

Browse files
committed
feat: enhance release workflow with comprehensive artifact management
- Enable semantic-release to handle Python package building with Poetry - Add Docker image tar generation and upload to GitHub releases - Include SBOM (Software Bill of Materials) generation and release attachment - Implement distributed job architecture for better fault isolation: - semantic-release: handles versioning and Python package release - sbom-generation: creates security manifests in parallel - publish: builds Docker artifacts and publishes to TestPyPI - Pin anchore/sbom-action to v0.17.6 for security - Configure proper version coordination across all jobs - Ensure all artifacts are attached to the same GitHub release This creates a complete release pipeline that produces: - Python wheel and source distribution (via semantic-release) - Docker image tar for local loading - SBOM for supply chain security compliance - TestPyPI publication for external distribution
1 parent 8808001 commit 369454a

File tree

2 files changed

+43
-12
lines changed

2 files changed

+43
-12
lines changed

.github/workflows/release.yaml

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ jobs:
4949
tag: true # Tag the release
5050
push: true # Push changes back to the repository
5151
commit: true # Commit changes
52-
build: false # Skip build in semantic-release since we'll do it separately
5352

5453

5554
sbom-generation:
@@ -62,13 +61,30 @@ jobs:
6261
security-events: write
6362
steps:
6463
- uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0
66+
ref: ${{ github.head_ref || github.ref_name }}
67+
- name: Get version
68+
id: version
69+
run: |
70+
# Get version from pyproject.toml after semantic-release updated it
71+
VERSION=$(grep '^version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
72+
echo "version=$VERSION" >> $GITHUB_OUTPUT
73+
echo "Version: $VERSION"
6574
- name: Generate SBOM
66-
uses: anchore/sbom-action@v0
75+
uses: anchore/sbom-action@v0.17.6
6776
with:
6877
path: . # Generate SBOM for the entire repository
6978
artifact-name: sbom.spdx.json # Name of the generated SBOM file
7079
format: spdx-json # Use SPDX format for SBOM
7180
dependency-snapshot: true # Include dependency snapshot
81+
- name: Upload SBOM to GitHub release
82+
uses: softprops/action-gh-release@v2
83+
with:
84+
tag_name: v${{ steps.version.outputs.version }}
85+
files: sbom.spdx.json
86+
draft: false
87+
prerelease: false
7288

7389
publish:
7490
needs: semantic-release
@@ -79,20 +95,35 @@ jobs:
7995
with:
8096
fetch-depth: 0
8197
ref: ${{ github.head_ref || github.ref_name }}
82-
- name: Set up Python
98+
- name: Get version
99+
id: version
100+
run: |
101+
# Get version from pyproject.toml after semantic-release updated it
102+
VERSION=$(grep '^version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
103+
echo "version=$VERSION" >> $GITHUB_OUTPUT
104+
echo "Version: $VERSION"
105+
- name: Set up Docker Buildx
106+
uses: docker/setup-buildx-action@v3
107+
- name: Build Docker image as tar
108+
run: |
109+
docker build -t network-reputation-check:v${{ steps.version.outputs.version }} .
110+
docker save network-reputation-check:v${{ steps.version.outputs.version }} -o network-reputation-check-v${{ steps.version.outputs.version }}.tar
111+
- name: Upload Docker tar to GitHub release
112+
uses: softprops/action-gh-release@v2
113+
with:
114+
tag_name: v${{ steps.version.outputs.version }}
115+
files: network-reputation-check-v${{ steps.version.outputs.version }}.tar
116+
draft: false
117+
prerelease: false
118+
- name: Set up Python for TestPyPI publishing
83119
uses: actions/setup-python@v5
84120
with:
85121
python-version: 3.11
86-
- name: Install dependencies
87-
run: |
88-
pip install poetry
89-
poetry install --with dev
90-
- name: Build package
91-
run: |
92-
poetry build
93-
- name: Publish to TestPyPI
122+
- name: Install Poetry and publish to TestPyPI
94123
env:
95124
POETRY_PYPI_TOKEN_TESTPYPI: ${{ secrets.TEST_PYPI_API_TOKEN }}
96125
run: |
126+
pip install poetry
127+
poetry install --with dev
97128
poetry config repositories.testpypi https://test.pypi.org/legacy/
98129
poetry publish --repository testpypi

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ version_toml = ["pyproject.toml:project.version"]
6262
allow_zero_version = true
6363
commit_message = "chore(release): {version} [skip ci]"
6464
commit_author = "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
65-
build_command = "poetry build"
65+
build_command = "pip install poetry && poetry build"
6666
upload_to_vcs_release = true
6767

6868
[build-system]

0 commit comments

Comments
 (0)