-
Notifications
You must be signed in to change notification settings - Fork 2
INTPYTHON-582 Add release workflows #9
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ac8f1cb
INTPYTHON-585 Add release workflows
blink1073 94288b3
add dependabot
blink1073 64246af
address zizmor
blink1073 a0ae1cc
address zizmor
blink1073 dd5c084
address zizmor
blink1073 eeebced
wip
blink1073 f287d9b
wip
blink1073 6141478
wip
blink1073 7ff93e3
wip
blink1073 189a85d
wip
blink1073 54568a5
lint
blink1073 f0c024f
reduce matrix
blink1073 912619d
reduce matrix
blink1073 d2619ed
address review
blink1073 9442e28
lint
blink1073 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| version: 2 | ||
| updates: | ||
| # GitHub Actions | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| cooldown: | ||
| default-days: 7 | ||
| groups: | ||
| actions: | ||
| patterns: | ||
| - "*" | ||
| # Python | ||
| - package-ecosystem: "pip" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| cooldown: | ||
| default-days: 7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: Python Dist | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "[0-9]+.[0-9]+.[0-9]+" | ||
| - "[0-9]+.[0-9]+.[0-9]+.post[0-9]+" | ||
| - "[0-9]+.[0-9]+.[0-9]+[a-b][0-9]+" | ||
| - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+" | ||
| workflow_dispatch: | ||
| pull_request: | ||
| workflow_call: | ||
| inputs: | ||
| ref: | ||
| required: true | ||
| type: string | ||
|
|
||
| concurrency: | ||
| group: dist-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash -eux {0} | ||
|
|
||
| jobs: | ||
| make_dist: | ||
| name: Make Dist | ||
| runs-on: macos-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| # Build sdist on lowest supported Python | ||
| python-version: '3.10' | ||
|
|
||
| - name: Install python requirements | ||
| run: | | ||
| python -m pip install uv rust-just build twine | ||
|
|
||
| - name: Build Dist | ||
| run: | | ||
| python -m build . | ||
|
|
||
| - name: Test SDist | ||
| run: | | ||
| python -m twine check --strict dist/*.* | ||
| python -m pip install dist/*.gz | ||
| cd .. | ||
| python -c "import django_mongodb_extensions" | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: "dist" | ||
| path: ./dist/*.* | ||
|
|
||
| collect_dist: | ||
| runs-on: ubuntu-latest | ||
| needs: [make_dist] | ||
| name: Download Dist | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Download all workflow run artifacts | ||
| uses: actions/download-artifact@v5 | ||
| - name: Flatten directory | ||
| working-directory: . | ||
| run: | | ||
| find . -mindepth 2 -type f -exec mv {} . \; | ||
| find . -type d -empty -delete | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: all-dist-${{ github.run_id }} | ||
| path: "./*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| following_version: | ||
| description: "The post (dev) version to set" | ||
| dry_run: | ||
| description: "Dry Run?" | ||
| default: false | ||
| type: boolean | ||
| schedule: | ||
| - cron: '30 5 * * *' | ||
|
|
||
| env: | ||
| # Changes per repo | ||
| PRODUCT_NAME: django-mongodb-extensions | ||
| # Constant | ||
| # inputs will be empty on a scheduled run. so, we only set dry_run | ||
| # to 'false' when the input is set to 'false'. | ||
| DRY_RUN: ${{ ! contains(inputs.dry_run, 'false') }} | ||
| FOLLOWING_VERSION: ${{ inputs.following_version || '' }} | ||
|
|
||
| concurrency: | ||
| group: release-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash -eux {0} | ||
|
|
||
| jobs: | ||
| pre-publish: | ||
| environment: release | ||
| runs-on: ubuntu-latest | ||
| if: github.repository_owner == 'mongodb-labs' || github.event_name == 'workflow_dispatch' | ||
| permissions: | ||
| id-token: write | ||
| contents: write | ||
| outputs: | ||
| version: ${{ steps.pre-publish.outputs.version }} | ||
| steps: | ||
| - uses: mongodb-labs/drivers-github-tools/secure-checkout@v3 | ||
| with: | ||
| app_id: ${{ vars.APP_ID }} | ||
| private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
| - uses: mongodb-labs/drivers-github-tools/setup@v3 | ||
|
||
| with: | ||
| aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} | ||
| aws_region_name: ${{ vars.AWS_REGION_NAME }} | ||
| aws_secret_id: ${{ secrets.AWS_SECRET_ID }} | ||
| - uses: mongodb-labs/drivers-github-tools/python-labs/pre-publish@v3 | ||
|
||
| id: pre-publish | ||
| with: | ||
| dry_run: ${{ env.DRY_RUN }} | ||
|
|
||
| build-dist: | ||
| needs: [pre-publish] | ||
| uses: ./.github/workflows/dist-python.yml | ||
| permissions: | ||
| contents: write | ||
| with: | ||
| ref: ${{ needs.pre-publish.outputs.version }} | ||
|
|
||
| publish: | ||
| # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#publishing-the-distribution-to-pypi | ||
| needs: [build-dist] | ||
| if: (github.repository_owner == 'mongodb-labs' && github.event_name != 'pull_request') || github.event_name == 'workflow_dispatch' | ||
| runs-on: ubuntu-latest | ||
| environment: release | ||
| permissions: | ||
| id-token: write | ||
| steps: | ||
| - name: Download all the dists | ||
| uses: actions/download-artifact@v5 | ||
| with: | ||
| name: all-dist-${{ github.run_id }} | ||
| path: dist/ | ||
| - name: Publish distribution 📦 to PyPI | ||
| if: startsWith(env.DRY_RUN, 'false') | ||
| uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1 | ||
|
|
||
| post-publish: | ||
| needs: [publish] | ||
| runs-on: ubuntu-latest | ||
| environment: release | ||
| permissions: | ||
| id-token: write | ||
| contents: write | ||
| attestations: write | ||
| security-events: write | ||
| steps: | ||
| - uses: mongodb-labs/drivers-github-tools/secure-checkout@v3 | ||
|
||
| with: | ||
| app_id: ${{ vars.APP_ID }} | ||
| private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
| - uses: mongodb-labs/drivers-github-tools/setup@v3 | ||
|
||
| with: | ||
| aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} | ||
| aws_region_name: ${{ vars.AWS_REGION_NAME }} | ||
| aws_secret_id: ${{ secrets.AWS_SECRET_ID }} | ||
| - uses: mongodb-labs/drivers-github-tools/python-labs/post-publish@v3 | ||
|
||
| with: | ||
| following_version: ${{ env.FOLLOWING_VERSION }} | ||
| product_name: ${{ env.PRODUCT_NAME }} | ||
| token: ${{ github.token }} | ||
| dry_run: ${{ env.DRY_RUN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| name: Python Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: tests-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash -eux {0} | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| MIN_PYTHON: "3.10" | ||
| MIN_MONGODB: "6.0" | ||
| MAX_MONGODB: "8.0" | ||
|
|
||
| jobs: | ||
| static: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7 | ||
|
||
| with: | ||
| enable-cache: true | ||
| python-version: ${{ matrix.python-version }} | ||
| - uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3 | ||
| - run: just lint | ||
| build: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: ["ubuntu-latest"] | ||
| python-version: ["3.10", "3.11", "3.12", "3.13"] | ||
| fail-fast: false | ||
| name: CPython ${{ matrix.python-version }}-${{ matrix.os }} | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7 | ||
|
||
| with: | ||
| enable-cache: true | ||
| python-version: ${{ matrix.python-version }} | ||
| - uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3 | ||
| - name: Start MongoDB on Linux | ||
| if: ${{ startsWith(runner.os, 'Linux') }} | ||
| uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0 | ||
| with: | ||
| mongodb-version: ${{ env.MAX_MONGODB }} | ||
| mongodb-replica-set: test-rs | ||
| - run: just test | ||
|
|
||
| build-min: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7 | ||
|
||
| with: | ||
| enable-cache: true | ||
| python-version: ${{ env.MIN_PYTHON }} | ||
| - uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7 | ||
|
||
| with: | ||
| enable-cache: true | ||
| python-version: ${{ env.MIN_PYTHON }} | ||
| - uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3 | ||
| - uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0 | ||
| with: | ||
| mongodb-version: ${{ env.MIN_MONGODB }} | ||
| mongodb-replica-set: test-rs | ||
| - name: Run unit tests with minimum dependency versions | ||
| run: | | ||
| uv sync --python=${MIN_PYTHON} --resolution=lowest-direct | ||
| just test | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| name: GitHub Actions Security Analysis with zizmor 🌈 | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["master"] | ||
| pull_request: | ||
| branches: ["**"] | ||
|
|
||
| jobs: | ||
| zizmor: | ||
| name: zizmor latest via Cargo | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| security-events: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Run zizmor 🌈 | ||
| uses: zizmorcore/zizmor-action@da5ac40c5419dcf7f21630fb2f95e725ae8fb9d5 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.