Skip to content

Commit 141f324

Browse files
authored
Merge pull request #16 from deeleeramone/main
chore(sync): merge main into develop
2 parents 8fe64a0 + f723b0d commit 141f324

17 files changed

Lines changed: 5762 additions & 16724 deletions

.github/workflows/docs.yml

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,8 @@ on:
44
push:
55
branches:
66
- main
7-
paths:
8-
- 'pywry/docs/**'
9-
- 'pywry/**/*.py'
10-
- '.github/workflows/docs.yml'
117
pull_request:
12-
branches: [main, master, develop]
13-
paths:
14-
- 'pywry/docs/**'
15-
- 'pywry/**/*.py'
16-
- '.github/workflows/docs.yml'
8+
branches: [main, develop]
179
workflow_dispatch:
1810

1911
permissions:
@@ -24,7 +16,47 @@ concurrency:
2416
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
2517

2618
jobs:
19+
detect-doc-impact:
20+
name: Detect docs impact
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
outputs:
25+
should-build: ${{ steps.detect.outputs.should-build }}
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v5
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Decide whether docs build is required
33+
id: detect
34+
shell: bash
35+
env:
36+
IS_PR: ${{ github.event_name == 'pull_request' }}
37+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
38+
run: |
39+
set -euo pipefail
40+
41+
if [[ "$IS_PR" != "true" ]]; then
42+
echo "should-build=true" >> "$GITHUB_OUTPUT"
43+
exit 0
44+
fi
45+
46+
git fetch --depth=1 origin "$BASE_SHA"
47+
48+
CHANGED=$(git diff --name-only "$BASE_SHA" HEAD)
49+
DOC_RELATED=$(echo "$CHANGED" | grep -E '^(pywry/docs/|pywry/.*\.py$|\.github/workflows/docs\.yml$)' || true)
50+
51+
if [[ -n "$DOC_RELATED" ]]; then
52+
echo "should-build=true" >> "$GITHUB_OUTPUT"
53+
else
54+
echo "should-build=false" >> "$GITHUB_OUTPUT"
55+
fi
56+
2757
build:
58+
if: github.event_name != 'pull_request' || needs.detect-doc-impact.outputs.should-build == 'true'
59+
needs: detect-doc-impact
2860
runs-on: ubuntu-latest
2961
steps:
3062
- uses: actions/checkout@v5
@@ -70,3 +102,33 @@ jobs:
70102
- name: Deploy to GitHub Pages
71103
id: deployment
72104
uses: actions/deploy-pages@v4
105+
106+
docs-required:
107+
name: Docs Required
108+
runs-on: ubuntu-latest
109+
if: github.event_name == 'pull_request' && always()
110+
needs:
111+
- detect-doc-impact
112+
- build
113+
permissions:
114+
contents: read
115+
steps:
116+
- name: Enforce required docs outcomes
117+
shell: bash
118+
env:
119+
SHOULD_BUILD: ${{ needs.detect-doc-impact.outputs.should-build }}
120+
BUILD_RESULT: ${{ needs.build.result }}
121+
run: |
122+
set -euo pipefail
123+
124+
if [[ "$SHOULD_BUILD" == "false" ]]; then
125+
echo "No docs-impacting changes detected; docs build intentionally skipped."
126+
exit 0
127+
fi
128+
129+
if [[ "$BUILD_RESULT" != "success" ]]; then
130+
echo "Docs build did not succeed (result: $BUILD_RESULT)"
131+
exit 1
132+
fi
133+
134+
echo "Docs validation passed."

.github/workflows/publish-pywry.yml

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,21 @@ jobs:
439439
path: pywry/dist/*.whl
440440
retention-days: 30
441441

442+
generate-sbom:
443+
name: Generate release SBOM
444+
needs: [test]
445+
if: ${{ !cancelled() && (needs.test.result == 'success' || needs.test.result == 'skipped') }}
446+
permissions:
447+
contents: read
448+
uses: ./.github/workflows/sbom.yml
449+
442450
# =============================================================================
443451
# Step 3: Merge all artifacts into single dist
444452
# =============================================================================
445453
merge-artifacts:
446454
name: Merge artifacts
447-
needs: [build-linux-x86_64, build-linux-aarch64, build-macos-x86_64, build-macos-arm64, build-windows-amd64, build-windows-arm64]
448-
if: ${{ !cancelled() && needs.build-linux-x86_64.result == 'success' }}
455+
needs: [build-linux-x86_64, build-linux-aarch64, build-macos-x86_64, build-macos-arm64, build-windows-amd64, build-windows-arm64, generate-sbom]
456+
if: ${{ !cancelled() && needs.build-linux-x86_64.result == 'success' && needs.generate-sbom.result == 'success' }}
449457
runs-on: ubuntu-24.04
450458
defaults:
451459
run:
@@ -469,6 +477,15 @@ jobs:
469477
name: sdist
470478
path: artifacts/sdist/
471479

480+
- name: Download SBOM artifacts
481+
uses: actions/download-artifact@v8.0.1
482+
with:
483+
name: sbom
484+
path: artifacts/sbom/
485+
486+
- name: Ensure output directories exist
487+
run: mkdir -p dist
488+
472489
- name: Consolidate artifacts and fail on duplicate wheel names
473490
shell: bash
474491
run: |
@@ -522,6 +539,34 @@ jobs:
522539
print(f"Skipped {skipped_identical} identical duplicate wheel artifact(s)")
523540
PY
524541
542+
- name: Add distributed artifacts to merged SBOM
543+
shell: bash
544+
run: |
545+
test -f artifacts/sbom/sbom.cdx.json
546+
docker run --rm \
547+
-v "$PWD:/work" \
548+
-w /work \
549+
cyclonedx/cyclonedx-cli:latest \
550+
add files \
551+
--input-file artifacts/sbom/sbom.cdx.json \
552+
--input-format json \
553+
--output-format json \
554+
--output-file dist/sbom.cdx.json \
555+
--base-path dist \
556+
--include "**/*.whl" "**/*.tar.gz"
557+
558+
- name: Validate release SBOM
559+
shell: bash
560+
run: |
561+
docker run --rm \
562+
-v "$PWD:/work" \
563+
-w /work \
564+
cyclonedx/cyclonedx-cli:latest \
565+
validate \
566+
--input-file dist/sbom.cdx.json \
567+
--input-format json \
568+
--fail-on-errors
569+
525570
- name: Validate wheel archives for duplicate ZIP members
526571
shell: bash
527572
run: |
@@ -834,6 +879,12 @@ jobs:
834879
contents: write
835880

836881
steps:
882+
- name: Download dist artifacts
883+
uses: actions/download-artifact@v8.0.1
884+
with:
885+
name: dist
886+
path: dist/
887+
837888
- name: Create draft release
838889
uses: softprops/action-gh-release@v2
839890
with:
@@ -866,8 +917,14 @@ jobs:
866917
867918
- Python 3.10, 3.11, 3.12, 3.13, 3.14
868919
920+
### SBOM
921+
922+
- CycloneDX SBOM is included in this release as `sbom.cdx.json`.
923+
869924
---
870925
*This is a draft release. Wheels are published to PyPI separately.*
926+
files: |
927+
dist/*
871928
872929
# =============================================================================
873930
# Step 6: Publish to PyPI - Trusted Publisher (workflow_dispatch only)

0 commit comments

Comments
 (0)