-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(cloudflare): add cloudflare-api package and fix broken imports #10
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
ec92633
655ed94
48b1cef
3170f14
2d84e06
910cf3c
f08f800
f80e6d2
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 | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,104 @@ | ||||||||||||||||||||||||||||||||||||||
| # .github/workflows/publish.yml | ||||||||||||||||||||||||||||||||||||||
| # Publishes packages to GCP Artifact Registry when tags are pushed | ||||||||||||||||||||||||||||||||||||||
| # Secrets are fetched from Infisical | ||||||||||||||||||||||||||||||||||||||
| # Uses Assured OSS dependencies for supply chain security | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| name: Publish Package | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||||||||
| tags: | ||||||||||||||||||||||||||||||||||||||
| - 'cloudflare-auth-v*' | ||||||||||||||||||||||||||||||||||||||
| - 'gcs-utilities-v*' | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||
| INFISICAL_DOMAIN: https://secrets.byronwilliamscpa.com | ||||||||||||||||||||||||||||||||||||||
| INFISICAL_PROJECT: python-libs | ||||||||||||||||||||||||||||||||||||||
| INFISICAL_ENV: prod | ||||||||||||||||||||||||||||||||||||||
| ARTIFACT_REGISTRY_URL: https://us-central1-python.pkg.dev/assured-oss-457903/python-libs/ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||
| determine-package: | ||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||
| outputs: | ||||||||||||||||||||||||||||||||||||||
| package_dir: ${{ steps.parse.outputs.package_dir }} | ||||||||||||||||||||||||||||||||||||||
| package_name: ${{ steps.parse.outputs.package_name }} | ||||||||||||||||||||||||||||||||||||||
| version: ${{ steps.parse.outputs.version }} | ||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||
| - name: Parse tag | ||||||||||||||||||||||||||||||||||||||
| id: parse | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| TAG="${{ github.ref_name }}" | ||||||||||||||||||||||||||||||||||||||
| echo "Processing tag: $TAG" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if [[ "$TAG" == cloudflare-auth-v* ]]; then | ||||||||||||||||||||||||||||||||||||||
| echo "package_dir=packages/cloudflare-auth" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||
| echo "package_name=byronwilliamscpa-cloudflare-auth" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||
| echo "version=${TAG#cloudflare-auth-v}" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||
| elif [[ "$TAG" == gcs-utilities-v* ]]; then | ||||||||||||||||||||||||||||||||||||||
| echo "package_dir=packages/gcs-utilities" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||
| echo "package_name=byronwilliamscpa-gcs-utilities" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||
| echo "version=${TAG#gcs-utilities-v}" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||
| echo "::error::Unknown tag format: $TAG" | ||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| build-and-publish: | ||||||||||||||||||||||||||||||||||||||
| needs: determine-package | ||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||
| - name: Checkout repository | ||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Fetch secrets from Infisical | ||||||||||||||||||||||||||||||||||||||
| uses: Infisical/secrets-action@03d3fa38607956c493f53c6633f94006a13c47ae # v1.0.7 | ||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||
| client-id: ${{ secrets.INFISICAL_CLIENT_ID }} | ||||||||||||||||||||||||||||||||||||||
| client-secret: ${{ secrets.INFISICAL_CLIENT_SECRET }} | ||||||||||||||||||||||||||||||||||||||
| env-slug: ${{ env.INFISICAL_ENV }} | ||||||||||||||||||||||||||||||||||||||
| project-slug: ${{ env.INFISICAL_PROJECT }} | ||||||||||||||||||||||||||||||||||||||
| domain: ${{ env.INFISICAL_DOMAIN }} | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||
| - name: Install uv | ||||||||||||||||||||||||||||||||||||||
| uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1 | ||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||
| enable-cache: true | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Set up Python | ||||||||||||||||||||||||||||||||||||||
| run: uv python install 3.12 | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+50
to
+72
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. 🛠️ Refactor suggestion | 🟠 Major Add timeout to prevent indefinite publishing jobs. The Apply this diff: build-and-publish:
needs: determine-package
runs-on: ubuntu-latest
+ timeout-minutes: 15
steps:🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Verify version matches tag | ||||||||||||||||||||||||||||||||||||||
| working-directory: ${{ needs.determine-package.outputs.package_dir }} | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| TOML_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | ||||||||||||||||||||||||||||||||||||||
| TAG_VERSION="${{ needs.determine-package.outputs.version }}" | ||||||||||||||||||||||||||||||||||||||
| if [[ "$TOML_VERSION" != "$TAG_VERSION" ]]; then | ||||||||||||||||||||||||||||||||||||||
| echo "::error::Version mismatch! pyproject.toml=$TOML_VERSION, tag=$TAG_VERSION" | ||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+74
to
+82
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. 🧹 Nitpick | 🔵 Trivial Consider using a TOML parser for more robust version extraction. The Consider this alternative using Python's built-in TOML support: - name: Verify version matches tag
working-directory: ${{ needs.determine-package.outputs.package_dir }}
run: |
- TOML_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
+ TOML_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
TAG_VERSION="${{ needs.determine-package.outputs.version }}"Note: 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Authenticate to Google Cloud | ||||||||||||||||||||||||||||||||||||||
| uses: google-github-actions/auth@71f986410dfbc7added4569d411d040a91dc6935 # v2.1.8 | ||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||
| credentials_json: ${{ env.GCP_SA_KEY_BASE64 }} | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Install keyring for Artifact Registry | ||||||||||||||||||||||||||||||||||||||
| run: pip install keyrings.google-artifactregistry-auth | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+89
to
+90
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: git ls-files .github/workflows/publish.ymlRepository: ByronWilliamsCPA/python-libs Length of output: 101 🏁 Script executed: cat -n .github/workflows/publish.yml | sed -n '80,105p'Repository: ByronWilliamsCPA/python-libs Length of output: 1370 🌐 Web query:
💡 Result: Latest PyPI version: 1.1.2 — uploaded Mar 1, 2023. [1] Source: PyPI project page for keyrings.google-artifactregistry-auth. [1] Pin the keyring package version for supply chain security. Installing Apply this diff to pin to the latest stable version: - name: Install keyring for Artifact Registry
- run: pip install keyrings.google-artifactregistry-auth
+ run: pip install keyrings.google-artifactregistry-auth==1.1.2📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Build package | ||||||||||||||||||||||||||||||||||||||
| working-directory: ${{ needs.determine-package.outputs.package_dir }} | ||||||||||||||||||||||||||||||||||||||
| run: uv build | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Publish to Artifact Registry | ||||||||||||||||||||||||||||||||||||||
| working-directory: ${{ needs.determine-package.outputs.package_dir }} | ||||||||||||||||||||||||||||||||||||||
| run: uv publish --publish-url ${{ env.ARTIFACT_REGISTRY_URL }} | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+92
to
+98
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. 🧹 Nitpick | 🔵 Trivial Consider adding package verification before publishing. Publishing immediately after building without verification is risky. Consider adding a validation step to check package metadata and catch issues before they reach the registry. Add a verification step between build and publish: - name: Build package
working-directory: ${{ needs.determine-package.outputs.package_dir }}
run: uv build
+ - name: Verify package
+ working-directory: ${{ needs.determine-package.outputs.package_dir }}
+ run: |
+ # Check that dist files were created
+ ls -lh dist/
+ # Verify package metadata (requires twine)
+ uv run pip install twine
+ uv run twine check dist/*
- name: Publish to Artifact Registry🤖 Prompt for AI Agents🧹 Nitpick | 🔵 Trivial Consider uploading build artifacts for audit trail. Uploading the built distributions as workflow artifacts provides an audit trail and allows manual inspection if issues arise. This is particularly valuable for published packages. Add after the build step: - name: Build package
working-directory: ${{ needs.determine-package.outputs.package_dir }}
run: uv build
+ - name: Upload build artifacts
+ uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
+ with:
+ name: dist-${{ needs.determine-package.outputs.package_name }}-${{ needs.determine-package.outputs.version }}
+ path: ${{ needs.determine-package.outputs.package_dir }}/dist/
+ retention-days: 90
- name: Publish to Artifact Registry🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| - name: Job summary | ||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||
| echo "## 📦 Published: ${{ needs.determine-package.outputs.package_name }} v${{ needs.determine-package.outputs.version }}" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||
| echo "" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||
| echo "Registry: \`us-central1-python.pkg.dev/assured-oss-457903/python-libs\`" >> $GITHUB_STEP_SUMMARY | ||||||||||||||||||||||||||||||||||||||
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.
🛠️ Refactor suggestion | 🟠 Major
Add timeout to prevent indefinite hangs.
The
determine-packagejob lacks atimeout-minutessetting. While this job is quick, adding a timeout prevents resource waste if the job hangs unexpectedly.Apply this diff:
jobs: determine-package: runs-on: ubuntu-latest + timeout-minutes: 5 outputs:🤖 Prompt for AI Agents