Skip to content

Commit a35542f

Browse files
committed
INTPYTHON-406 Add automated release workflows for Django-MongoDB
1 parent b660425 commit a35542f

File tree

3 files changed

+202
-0
lines changed

3 files changed

+202
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "main", "*" ]
17+
pull_request:
18+
branches: [ "main", "*" ]
19+
schedule:
20+
- cron: '35 23 * * 5'
21+
workflow_call:
22+
inputs:
23+
ref:
24+
required: true
25+
type: string
26+
27+
jobs:
28+
analyze:
29+
name: Analyze
30+
runs-on: ubuntu-latest
31+
timeout-minutes: 360
32+
permissions:
33+
# required for all workflows
34+
security-events: write
35+
# required to fetch internal or private CodeQL packs
36+
packages: read
37+
actions: read
38+
contents: read
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v4
43+
with:
44+
ref: ${{ inputs.ref }}
45+
- name: Set up Python
46+
uses: actions/setup-python@v4
47+
with:
48+
python-version: 3.x
49+
50+
# Initializes the CodeQL tools for scanning.
51+
- name: Initialize CodeQL
52+
uses: github/codeql-action/init@v3
53+
with:
54+
languages: python
55+
build-mode: none
56+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
57+
queries: security-extended
58+
config: |
59+
paths-ignore:
60+
- '.github/**'
61+
- 'tests/**'
62+
63+
- shell: bash
64+
run: |
65+
pip install -e .
66+
67+
- name: Perform CodeQL Analysis
68+
uses: github/codeql-action/analyze@v3
69+
with:
70+
category: "/language:python"

.github/workflows/dist.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Python Dist
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
inputs:
7+
ref:
8+
required: true
9+
type: string
10+
push:
11+
tags:
12+
- "[0-9]+.[0-9]+.[0-9]+"
13+
- "[0-9]+.[0-9]+.[0-9]+.post[0-9]+"
14+
- "[0-9]+.[0-9]+.[0-9]+[a-b][0-9]+"
15+
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
environment: release
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
ref: ${{ inputs.ref }}
25+
- name: Set up Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: 3.x
29+
- name: Install dependencies
30+
run: pip install build
31+
- name: Create packages
32+
run: python -m build .
33+
- name: Store package artifacts
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: all-dist-${{ github.run_id }}
37+
path: "dist/*"

.github/workflows/release-python.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "The new version to set"
8+
required: true
9+
following_version:
10+
description: "The post (dev) version to set"
11+
required: true
12+
dry_run:
13+
description: "Dry Run?"
14+
default: false
15+
type: boolean
16+
17+
env:
18+
# Changes per repo
19+
PRODUCT_NAME: django-mongodb
20+
# Changes per branch
21+
SILK_ASSET_GROUP: django-mongodb-main
22+
EVERGREEN_PROJECT: django-mongodb
23+
24+
defaults:
25+
run:
26+
shell: bash -eux {0}
27+
28+
jobs:
29+
pre-publish:
30+
environment: release
31+
runs-on: ubuntu-latest
32+
permissions:
33+
id-token: write
34+
contents: write
35+
outputs:
36+
version: ${{ steps.pre-publish.outputs.version }}
37+
steps:
38+
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
39+
with:
40+
app_id: ${{ vars.APP_ID }}
41+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
42+
- uses: mongodb-labs/drivers-github-tools/setup@v2
43+
with:
44+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
45+
aws_region_name: ${{ vars.AWS_REGION_NAME }}
46+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
47+
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
48+
- uses: mongodb-labs/drivers-github-tools/python/pre-publish@v2
49+
id: pre-publish
50+
with:
51+
version: ${{ inputs.version }}
52+
dry_run: ${{ inputs.dry_run }}
53+
54+
build-dist:
55+
needs: [pre-publish]
56+
uses: ./.github/workflows/dist.yml
57+
with:
58+
ref: ${{ needs.pre-publish.outputs.version }}
59+
60+
static-scan:
61+
needs: [pre-publish]
62+
uses: ./.github/workflows/codeql.yml
63+
with:
64+
ref: ${{ needs.pre-publish.outputs.version }}
65+
66+
publish:
67+
needs: [build-dist, static-scan]
68+
runs-on: ubuntu-latest
69+
environment: release
70+
permissions:
71+
id-token: write
72+
contents: write
73+
attestations: write
74+
security-events: write
75+
steps:
76+
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
77+
with:
78+
app_id: ${{ vars.APP_ID }}
79+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
80+
- uses: mongodb-labs/drivers-github-tools/setup@v2
81+
with:
82+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
83+
aws_region_name: ${{ vars.AWS_REGION_NAME }}
84+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
85+
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
86+
- uses: blink1073/drivers-github-tools/python/publish@INTPYTHON-406
87+
with:
88+
version: ${{ inputs.version }}
89+
following_version: ${{ inputs.following_version }}
90+
product_name: ${{ env.PRODUCT_NAME }}
91+
silk_asset_group: ${{ env.SILK_ASSET_GROUP }}
92+
evergreen_project: ${{ env.EVERGREEN_PROJECT }}
93+
token: ${{ github.token }}
94+
repository_url: https://test.pypi.org/legacy/
95+
dry_run: ${{ inputs.dry_run }}

0 commit comments

Comments
 (0)