Skip to content

Commit f39673f

Browse files
shihTianlu Shi
andauthored
Change release procedure to use OIDC (#9)
Co-authored-by: Tianlu Shi <[email protected]>
1 parent ee35ccc commit f39673f

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ on:
55
branches:
66
- main
77

8+
env:
9+
AWS_REGION: us-east-1
10+
811
jobs:
912
release:
1013
runs-on: ubuntu-latest
1114
permissions:
12-
contents: write
15+
contents: read
16+
id-token: write
1317
steps:
1418
- name: Check out the repository
1519
uses: actions/checkout@v3
@@ -49,16 +53,32 @@ jobs:
4953
- name: Run pytest
5054
run: |
5155
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
5558
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
5872
- name: Publish package on TestPyPI
5973
if: "! steps.check-version.outputs.tag"
6074
uses: pypa/gh-action-pypi-publish@release/v1
6175
with:
6276
user: __token__
63-
password: ${{ secrets.TEST_PYPI_TOKEN }}
77+
password: ${{ steps.get-test-pypi-token.outputs.token }}
6478
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

Comments
 (0)