|
1 | 1 | # This workflow will build the project, run integration tests, and release. |
2 | | -# Because secrets are not available on external forks, this job is expected to fail |
3 | | -# on external pull requests. |
4 | | - |
5 | | -# publishing instructions from |
6 | | -# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ |
| 2 | +# Secret-backed jobs fetch credentials from AWS Secrets Manager using GitHub OIDC. |
| 3 | +# PyPI uploads use trusted publishing (GitHub OIDC), not API tokens. |
7 | 4 |
|
8 | 5 | name: Build, Check, Publish |
9 | 6 |
|
|
16 | 13 | jobs: |
17 | 14 | build: |
18 | 15 | runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + id-token: write |
| 18 | + contents: read |
19 | 19 | steps: |
20 | 20 | - name: Checkout Repo |
21 | 21 | uses: actions/checkout@v3 |
22 | 22 |
|
| 23 | + - name: Configure AWS credentials for Docker Hub secrets (OIDC) |
| 24 | + if: github.event_name != 'pull_request' |
| 25 | + uses: aws-actions/configure-aws-credentials@v6 |
| 26 | + with: |
| 27 | + role-to-assume: arn:aws:iam::301904545275:role/oidc-github-hellosign-dropbox-sign-python-branch-main |
| 28 | + aws-region: us-west-2 |
| 29 | + |
| 30 | + - name: Get Docker Hub secrets from AWS Secrets Manager |
| 31 | + if: github.event_name != 'pull_request' |
| 32 | + uses: aws-actions/aws-secretsmanager-get-secrets@v3 |
| 33 | + with: |
| 34 | + secret-ids: | |
| 35 | + DOCKER_USERNAME,github-actions/hellosign/shared/docker-username |
| 36 | + DOCKER_TOKEN,github-actions/hellosign/shared/docker-token |
| 37 | + parse-json-secrets: false |
| 38 | + |
23 | 39 | - name: Build SDK |
24 | 40 | run: ./run-build |
25 | | - env: |
26 | | - DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} |
27 | | - DOCKER_TOKEN: ${{secrets.DOCKER_TOKEN}} |
28 | 41 |
|
29 | 42 | - name: Ensure no changes in Generated Code |
30 | 43 | run: ./bin/check-clean-git-status |
31 | 44 |
|
32 | | - # This job runs on pull requests |
33 | | - # Publishes to test.pypi.org, useful as a dry run |
34 | | - # Step still passes even if package version was already uploaded |
35 | | - publish-test: |
36 | | - runs-on: ubuntu-latest |
37 | | - if: >- |
38 | | - github.repository == 'hellosign/dropbox-sign-python' |
39 | | - && github.ref != 'refs/heads/main' |
40 | | - && github.event_name == 'pull_request' |
41 | | - needs: [ build ] |
42 | | - steps: |
43 | | - - name: Checkout |
44 | | - uses: actions/checkout@v3 |
45 | | - |
46 | | - - name: Set up Python 3.10 |
47 | | - uses: actions/setup-python@v3 |
48 | | - with: |
49 | | - python-version: "3.10" |
50 | | - |
51 | | - - name: Install pypa/build |
52 | | - run: python -m pip install build --user |
53 | | - |
54 | | - - name: Build a binary wheel and a source tarball |
55 | | - run: python -m build --sdist --wheel --outdir dist/ . |
56 | | - |
57 | | - - name: Publish distribution to Test PyPI |
58 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
59 | | - with: |
60 | | - password: ${{ secrets.PYPI_TEST_API_KEY }} |
61 | | - repository_url: https://test.pypi.org/legacy/ |
62 | | - skip_existing: true |
63 | | - verbose: true |
64 | | - |
65 | 45 | # This job runs on merging to "main" branch |
66 | | - # Builds and publishes package to pypi.org |
| 46 | + # Builds and publishes package to pypi.org with trusted publishing |
67 | 47 | publish-prod: |
68 | 48 | runs-on: ubuntu-latest |
| 49 | + permissions: |
| 50 | + contents: read |
| 51 | + id-token: write |
69 | 52 | if: >- |
70 | 53 | github.repository == 'hellosign/dropbox-sign-python' |
71 | 54 | && github.ref == 'refs/heads/main' |
|
86 | 69 | - name: Build a binary wheel and a source tarball |
87 | 70 | run: python -m build --sdist --wheel --outdir dist/ . |
88 | 71 |
|
89 | | - - name: Publish distribution to PyPI |
| 72 | + - name: Publish package with trusted publishing |
90 | 73 | uses: pypa/gh-action-pypi-publish@release/v1 |
91 | | - with: |
92 | | - password: ${{ secrets.PYPI_API_KEY }} |
93 | 74 |
|
94 | 75 | # This job runs on merging to "main" branch |
95 | 76 | # Creates a new tag using the value in the VERSION file |
|
0 commit comments