|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + following_version: |
| 7 | + description: "The post (dev) version to set" |
| 8 | + dry_run: |
| 9 | + description: "Dry Run?" |
| 10 | + default: false |
| 11 | + type: boolean |
| 12 | + schedule: |
| 13 | + - cron: '30 5 * * *' |
| 14 | + |
| 15 | +env: |
| 16 | + # Changes per repo |
| 17 | + PRODUCT_NAME: PyMongoExplain |
| 18 | + # Constant |
| 19 | + # inputs will be empty on a scheduled run. so, we only set dry_run |
| 20 | + # to 'false' when the input is set to 'false'. |
| 21 | + DRY_RUN: ${{ ! contains(inputs.dry_run, 'false') }} |
| 22 | + FOLLOWING_VERSION: ${{ inputs.following_version || '' }} |
| 23 | + |
| 24 | +concurrency: |
| 25 | + group: release-${{ github.ref }} |
| 26 | + cancel-in-progress: true |
| 27 | + |
| 28 | +defaults: |
| 29 | + run: |
| 30 | + shell: bash -eux {0} |
| 31 | + |
| 32 | +jobs: |
| 33 | + pre-publish: |
| 34 | + environment: release |
| 35 | + runs-on: ubuntu-latest |
| 36 | + if: github.repository_owner == 'mongodb-labs' || github.event_name == 'workflow_dispatch' |
| 37 | + permissions: |
| 38 | + id-token: write |
| 39 | + contents: write |
| 40 | + outputs: |
| 41 | + version: ${{ steps.pre-publish.outputs.version }} |
| 42 | + steps: |
| 43 | + - uses: mongodb-labs/drivers-github-tools/secure-checkout@v2 |
| 44 | + with: |
| 45 | + app_id: ${{ vars.APP_ID }} |
| 46 | + private_key: ${{ secrets.APP_PRIVATE_KEY }} |
| 47 | + - uses: mongodb-labs/drivers-github-tools/setup@v2 |
| 48 | + with: |
| 49 | + aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} |
| 50 | + aws_region_name: ${{ vars.AWS_REGION_NAME }} |
| 51 | + aws_secret_id: ${{ secrets.AWS_SECRET_ID }} |
| 52 | + artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }} |
| 53 | + - uses: mongodb-labs/drivers-github-tools/python-labs/pre-publish@v2 |
| 54 | + id: pre-publish |
| 55 | + with: |
| 56 | + dry_run: ${{ env.DRY_RUN }} |
| 57 | + |
| 58 | + build-dist: |
| 59 | + needs: [pre-publish] |
| 60 | + uses: ./.github/workflows/dist-python.yml |
| 61 | + with: |
| 62 | + ref: ${{ needs.pre-publish.outputs.version }} |
| 63 | + |
| 64 | + publish: |
| 65 | + # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#publishing-the-distribution-to-pypi |
| 66 | + needs: [build-dist] |
| 67 | + if: (github.repository_owner == 'mongodb-labs' && github.event_name != 'pull_request') || github.event_name == 'workflow_dispatch' |
| 68 | + runs-on: ubuntu-latest |
| 69 | + environment: release |
| 70 | + permissions: |
| 71 | + id-token: write |
| 72 | + steps: |
| 73 | + - name: Download all the dists |
| 74 | + uses: actions/download-artifact@v4 |
| 75 | + with: |
| 76 | + name: all-dist-${{ github.run_id }} |
| 77 | + path: dist/ |
| 78 | + - name: Publish package distributions to TestPyPI |
| 79 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 80 | + with: |
| 81 | + repository-url: https://test.pypi.org/legacy/ |
| 82 | + skip-existing: true |
| 83 | + attestations: ${{ env.DRY_RUN }} |
| 84 | + - name: Publish distribution 📦 to PyPI |
| 85 | + if: startsWith(github.ref, 'refs/tags/') |
| 86 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 87 | + |
| 88 | + post-publish: |
| 89 | + needs: [publish] |
| 90 | + runs-on: ubuntu-latest |
| 91 | + environment: release |
| 92 | + permissions: |
| 93 | + id-token: write |
| 94 | + contents: write |
| 95 | + attestations: write |
| 96 | + security-events: write |
| 97 | + steps: |
| 98 | + - uses: mongodb-labs/drivers-github-tools/secure-checkout@v2 |
| 99 | + with: |
| 100 | + app_id: ${{ vars.APP_ID }} |
| 101 | + private_key: ${{ secrets.APP_PRIVATE_KEY }} |
| 102 | + - uses: mongodb-labs/drivers-github-tools/setup@v2 |
| 103 | + with: |
| 104 | + aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} |
| 105 | + aws_region_name: ${{ vars.AWS_REGION_NAME }} |
| 106 | + aws_secret_id: ${{ secrets.AWS_SECRET_ID }} |
| 107 | + artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }} |
| 108 | + - uses: mongodb-labs/drivers-github-tools/python-labs/post-publish@v2 |
| 109 | + with: |
| 110 | + following_version: ${{ env.FOLLOWING_VERSION }} |
| 111 | + product_name: ${{ env.PRODUCT_NAME }} |
| 112 | + token: ${{ github.token }} |
| 113 | + dry_run: ${{ env.DRY_RUN }} |
0 commit comments