|
5 | 5 | branches: |
6 | 6 | - main |
7 | 7 |
|
| 8 | +env: |
| 9 | + AWS_REGION: us-east-1 |
| 10 | + |
8 | 11 | jobs: |
9 | 12 | release: |
10 | 13 | runs-on: ubuntu-latest |
11 | 14 | permissions: |
12 | | - contents: write |
| 15 | + contents: read |
| 16 | + id-token: write |
13 | 17 | steps: |
14 | 18 | - name: Check out the repository |
15 | 19 | uses: actions/checkout@v3 |
@@ -49,16 +53,32 @@ jobs: |
49 | 53 | - name: Run pytest |
50 | 54 | run: | |
51 | 55 | poetry run pytest --cov=sns_extended_client test --cov-report term-missing |
52 | | - - name: Publish package on PyPI |
53 | | - if: steps.check-version.outputs.tag |
54 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
| 56 | + - name: configure aws credentials |
| 57 | + uses: aws-actions/configure-aws-credentials@v2 |
55 | 58 | with: |
56 | | - user: __token__ |
57 | | - password: ${{ secrets.PYPI_TOKEN }} |
| 59 | + role-to-assume: ${{ vars.OIDC_ROLE_NAME }} |
| 60 | + role-session-name: publishrolesession |
| 61 | + aws-region: ${{ env.AWS_REGION }} |
| 62 | + - name: Retrieve TEST PYPI TOKEN from secretsmanager |
| 63 | + id: get-test-pypi-token |
| 64 | + if: "! steps.check-version.outputs.tag" |
| 65 | + run: | |
| 66 | + echo "token=$(aws secretsmanager get-secret-value --secret-id ${{ vars.TEST_PYPI_TOKEN_NAME }} | jq -r '.SecretString')" >> $GITHUB_OUTPUT |
| 67 | + - name: Retrieve PYPI TOKEN from secretsmanager |
| 68 | + id: get-pypi-token |
| 69 | + if: steps.check-version.outputs.tag |
| 70 | + run: | |
| 71 | + echo "token=$(aws secretsmanager get-secret-value --secret-id ${{ vars.PYPI_TOKEN_NAME }} | jq -r '.SecretString')" >> $GITHUB_OUTPUT |
58 | 72 | - name: Publish package on TestPyPI |
59 | 73 | if: "! steps.check-version.outputs.tag" |
60 | 74 | uses: pypa/gh-action-pypi-publish@release/v1 |
61 | 75 | with: |
62 | 76 | user: __token__ |
63 | | - password: ${{ secrets.TEST_PYPI_TOKEN }} |
| 77 | + password: ${{ steps.get-test-pypi-token.outputs.token }} |
64 | 78 | repository_url: https://test.pypi.org/legacy/ |
| 79 | + - name: Publish package on PyPI |
| 80 | + if: steps.check-version.outputs.tag |
| 81 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 82 | + with: |
| 83 | + user: __token__ |
| 84 | + password: ${{ steps.get-pypi-token.outputs.token }} |
0 commit comments