-
Notifications
You must be signed in to change notification settings - Fork 24
chore: resolve merge with master — keep OIDC PyPI workflows #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7e5d71d
cb70699
d96e930
209cabd
c5bd521
7251e8d
98100f7
974eba1
f28c2dc
0f1ce0e
b4fc266
963e31c
55a0fdd
1bf4e67
891557a
0258bf6
bf133da
216251c
2b378c4
71da4a9
ddf3d61
803559d
ae98629
c0df15a
2831e17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ on: | |
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| build-and-publish: | ||
|
|
@@ -19,7 +20,7 @@ jobs: | |
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
| python-version: "3.14" | ||
|
|
||
| - name: Build package | ||
| working-directory: packages/openfdd-engine | ||
|
|
@@ -31,10 +32,6 @@ jobs: | |
|
|
||
| - name: Publish to PyPI | ||
| if: startsWith(github.ref, 'refs/tags/openfdd-engine-v') | ||
| working-directory: packages/openfdd-engine | ||
| env: | ||
| TWINE_USERNAME: __token__ | ||
| TWINE_PASSWORD: ${{ secrets.PYPI_OPENFDD_ENGINE_TOKEN }} | ||
| run: | | ||
| twine upload dist/* | ||
|
|
||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| packages-dir: packages/openfdd-engine/dist/ | ||
|
Comment on lines
+35
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check if the file exists and read its contents
cat -n .github/workflows/publish-openfdd-engine.ymlRepository: bbartling/open-fdd Length of output: 1177 🌐 Web query:
💡 Result: GitHub Actions best practices recommend pinning actions to full commit SHAs for maximum security against supply chain attacks, as tags like Citations:
🏁 Script executed: # Check for other workflow files
find .github/workflows -name "*.yml" -o -name "*.yaml" | head -20Repository: bbartling/open-fdd Length of output: 170 🏁 Script executed: # Check the other workflow files for action pinning patterns
echo "=== ci.yml ===" && head -40 .github/workflows/ci.yml && echo -e "\n=== publish-open-fdd.yml ===" && head -40 .github/workflows/publish-open-fdd.ymlRepository: bbartling/open-fdd Length of output: 1992 Pin the publish action to a full commit SHA. On line 35, 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,10 +23,45 @@ Two distributions are relevant for **contractors / pandas + YAML** workflows: | |
| - Root **`pyproject.toml`** → `[project] version` for **`open-fdd`** (e.g. `2.0.8`). | ||
| - **`packages/openfdd-engine/pyproject.toml`** → `version` and `dependencies` → `open-fdd>=X.Y.Z` aligned with what you just published (or still satisfied by `>=`). | ||
| 2. **Changelog / tag message** — note engine-only docs, IoT `RuleRunner` usage, etc., if applicable. | ||
| 3. **PyPI tokens** (GitHub → repo → **Settings → Secrets**): | ||
| - **`PYPI_OPENFDD_TOKEN`** — API token for the **`open-fdd`** project on PyPI. | ||
| - **`PYPI_OPENFDD_ENGINE_TOKEN`** — API token for the **`openfdd-engine`** project on PyPI. | ||
| (Use [trusted publishing](https://docs.pypi.org/trusted-publishers/) later if you prefer OIDC over long-lived tokens.) | ||
|
|
||
| ### PyPI upload auth (required once per project) | ||
|
|
||
| CI uses **[PyPI Trusted Publishing](https://docs.pypi.org/trusted-publishers/)** (OpenID Connect from GitHub). **No `TWINE_PASSWORD` / repo secrets** are required if this is configured. | ||
|
|
||
| For **each** PyPI project (`open-fdd` and `openfdd-engine`): | ||
|
|
||
| 1. Log in to [pypi.org](https://pypi.org), open the project → **Manage project** → **Publishing**. | ||
| 2. Under **Manage publishers**, add a **GitHub** publisher: | ||
| - **Owner:** `bbartling` (your GitHub org or user) | ||
| - **Repository name:** `open-fdd` | ||
| - **Workflow name:** must match the file name exactly: | ||
| - for **`open-fdd`** uploads → **`publish-open-fdd.yml`** | ||
| - for **`openfdd-engine`** uploads → **`publish-openfdd-engine.yml`** | ||
| 3. Save. PyPI may show a **pending** publisher until the first successful run. | ||
|
|
||
| Workflows use **`pypa/gh-action-pypi-publish@release/v1`** with **`permissions: id-token: write`**. Official guide: [Publishing package distribution releases using GitHub Actions CI/CD workflows](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/). | ||
|
|
||
| **After changing workflows:** Git tag builds use the workflow YAML from the **tagged commit**. Merge the updated workflows to **`master`**, then either **delete and recreate** the release tags on the new commit or cut a **patch version** (e.g. `2.0.9`) and new tags so Actions picks up OIDC. | ||
|
|
||
| ### Fallback: API token instead of OIDC | ||
|
|
||
| If you cannot use trusted publishing, edit the **Publish to PyPI** step in the workflow to pass a secret, for example: | ||
|
|
||
| ```yaml | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| packages-dir: dist/ | ||
| password: ${{ secrets.PYPI_OPENFDD_TOKEN }} | ||
| ``` | ||
|
Comment on lines
+50
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify fallback snippet for The example on Lines 50-55 uses 📝 Suggested doc tweak uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
password: ${{ secrets.PYPI_OPENFDD_TOKEN }}
+
+# For openfdd-engine workflow, use:
+# packages-dir: packages/openfdd-engine/dist/
+# password: ${{ secrets.PYPI_OPENFDD_ENGINE_TOKEN }}🤖 Prompt for AI Agents |
||
|
|
||
| Use a **project-scoped** PyPI token for the matching project. Empty or wrong secret still yields **403**. | ||
|
|
||
| ### If CI shows `HTTPError: 403 Forbidden` | ||
|
|
||
| - **OIDC not configured** on the PyPI project for that **exact** workflow filename, or publisher still **pending**. | ||
| - **Wrong workflow name** in PyPI (typo vs `publish-open-fdd.yml` / `publish-openfdd-engine.yml`). | ||
| - **Tag points to an old commit** that used `twine` + missing secrets — merge OIDC workflows and re-tag. | ||
| - **Version already exists** on PyPI — bump version and use a new tag. | ||
|
|
||
| --- | ||
|
|
||
|
|
@@ -64,7 +99,7 @@ git push origin open-fdd-v2.0.8 | |
| - Package path: **`packages/openfdd-engine`** | ||
| - Workflow: **`.github/workflows/publish-openfdd-engine.yml`** | ||
| - Tag pattern: **`openfdd-engine-v*`** (e.g. `openfdd-engine-v0.1.1`) | ||
| - Secret: **`PYPI_OPENFDD_ENGINE_TOKEN`** | ||
| - **CI upload:** same **Trusted Publishing** setup as above (workflow **`publish-openfdd-engine.yml`** on this repo). Optional **token fallback** is documented in §1. | ||
|
|
||
| Local build: | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: bbartling/open-fdd
Length of output: 490
🏁 Script executed:
Repository: bbartling/open-fdd
Length of output: 519
🌐 Web query:
GitHub Actions pinning to commit SHA security best practices💡 Result:
Pinning GitHub Actions to a full-length commit SHA is the recommended security best practice to ensure immutability and prevent supply chain attacks where malicious code could be injected via tag overwrites. Key best practices: - Always pin to full-length commit SHAs (40 characters), not short SHAs or tags like 'v1'. Example: - uses: actions/checkout@692973e # v4.1.7 Verify the SHA is from the official repository, not a fork. - Prioritize high-risk third-party actions (those handling secrets or sensitive operations). - Use GitHub policies to enforce SHA pinning at repository/organization level. - Periodically update pins using Dependabot or Renovate (they recognize version comments like # v4.1.7). - Audit action source code and prefer verified creators from GitHub Marketplace. - Tools like Hyland/github-actions-ensure-sha-pinned-actions can automate conversion of tags to SHAs. - Combine with other hardening: minimize GITHUB_TOKEN permissions, use OIDC, restrict permissions. This mitigates risks like tag force-pushing malicious code, as SHAs are immutable (requiring SHA-1 collision attacks, which are infeasible). Note: SHA-pinned actions won't get Dependabot vulnerability alerts (only for semver tags), so monitor manually or via other tools.
Citations:
🏁 Script executed:
Repository: bbartling/open-fdd
Length of output: 1270
🏁 Script executed:
Repository: bbartling/open-fdd
Length of output: 528
Pin
gh-action-pypi-publishto an immutable commit SHA.Line 36 uses
@release/v1, a mutable ref that can be exploited for supply chain attacks if the tag is force-pushed. Pinning to a full-length commit SHA hardens the release pipeline against upstream tag overwrites.🔒 Suggested change
🤖 Prompt for AI Agents