From a889d93916957c811155606dc4b4028f617a9426 Mon Sep 17 00:00:00 2001 From: Brandon Butler Date: Wed, 9 Aug 2023 11:22:28 -0700 Subject: [PATCH] Use ephemeral credentials from AWS OIDC provider --- .github/workflows/build-arm64-wheels.yml | 16 +++++++++++----- .github/workflows/build-m1-wheel.yml | 16 +++++++++++----- .github/workflows/build-test.yml | 17 +++++++++++------ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-arm64-wheels.yml b/.github/workflows/build-arm64-wheels.yml index ba40fe845..0618633af 100644 --- a/.github/workflows/build-arm64-wheels.yml +++ b/.github/workflows/build-arm64-wheels.yml @@ -11,6 +11,10 @@ on: branches: - '**' +permissions: + id-token: write + contents: read + jobs: build_wheels: name: Build ARM64 Python Wheels @@ -84,7 +88,7 @@ jobs: echo HAS_AWS_SECRET=${HAS_AWS_SECRET} >>$GITHUB_OUTPUT env: SECRET: "${{ secrets.test_pypi_password }}" - AWS_SECRET: "${{ secrets.INSTALLER_UPLOAD_KEY }}" + AWS_SECRET: "${{ secrets.CHIA_AWS_ACCOUNT_ID }}" - name: publish (PyPi) if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET @@ -106,12 +110,14 @@ jobs: . ./activate twine upload --non-interactive --skip-existing --verbose 'target/wheels/*' + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: arn:aws:iam::${{ secrets.CHIA_AWS_ACCOUNT_ID }}:role/installer-upload + aws-region: us-west-2 + - name: Publish Dev if: steps.check_secrets.outputs.HAS_AWS_SECRET && github.ref == 'refs/heads/dev' - env: - AWS_ACCESS_KEY_ID: "${{ secrets.INSTALLER_UPLOAD_KEY }}" - AWS_SECRET_ACCESS_KEY: "${{ secrets.INSTALLER_UPLOAD_SECRET }}" - AWS_REGION: us-west-2 run: | FILES=$(find ${{ github.workspace }}/target/wheels -type f -name '*.whl') while IFS= read -r file; do diff --git a/.github/workflows/build-m1-wheel.yml b/.github/workflows/build-m1-wheel.yml index 917451d4f..1fda47663 100644 --- a/.github/workflows/build-m1-wheel.yml +++ b/.github/workflows/build-m1-wheel.yml @@ -15,6 +15,10 @@ concurrency: group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}--${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }} cancel-in-progress: true +permissions: + id-token: write + contents: read + jobs: build_wheels: name: Build wheel on Mac M1 @@ -121,7 +125,7 @@ jobs: echo HAS_AWS_SECRET=${HAS_AWS_SECRET} >>$GITHUB_OUTPUT env: SECRET: "${{ secrets.test_pypi_password }}" - AWS_SECRET: "${{ secrets.INSTALLER_UPLOAD_KEY }}" + AWS_SECRET: "${{ secrets.CHIA_AWS_ACCOUNT_ID }}" - name: Install twine run: arch -arm64 pip install twine @@ -143,12 +147,14 @@ jobs: TWINE_PASSWORD: ${{ secrets.test_pypi_password }} run: arch -arm64 twine upload --non-interactive --skip-existing --verbose 'target/wheels/*' + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: arn:aws:iam::${{ secrets.CHIA_AWS_ACCOUNT_ID }}:role/installer-upload + aws-region: us-west-2 + - name: Publish Dev if: steps.check_secrets.outputs.HAS_AWS_SECRET && github.ref == 'refs/heads/dev' - env: - AWS_ACCESS_KEY_ID: "${{ secrets.INSTALLER_UPLOAD_KEY }}" - AWS_SECRET_ACCESS_KEY: "${{ secrets.INSTALLER_UPLOAD_SECRET }}" - AWS_REGION: us-west-2 run: | FILES=$(find ${{ github.workspace }}/target/wheels -type f -name '*.whl') while IFS= read -r file; do diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f56023f04..4633cde84 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -12,6 +12,10 @@ on: branches: - '**' +permissions: + id-token: write + contents: read + jobs: build_wheels: name: Wheel on ${{ matrix.os }} py-${{ matrix.python }} @@ -232,10 +236,9 @@ jobs: if [ -n "$AWS_SECRET" ]; then HAS_AWS_SECRET='true' ; fi echo HAS_AWS_SECRET=${HAS_AWS_SECRET} >>$GITHUB_OUTPUT - env: SECRET: "${{ secrets.test_pypi_password }}" - AWS_SECRET: "${{ secrets.INSTALLER_UPLOAD_KEY }}" + AWS_SECRET: "${{ secrets.CHIA_AWS_ACCOUNT_ID }}" - name: publish (PyPi) if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET @@ -254,14 +257,16 @@ jobs: TWINE_PASSWORD: ${{ secrets.test_pypi_password }} run: twine upload --non-interactive --skip-existing --verbose 'target/wheels/*' + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: arn:aws:iam::${{ secrets.CHIA_AWS_ACCOUNT_ID }}:role/installer-upload + aws-region: us-west-2 + - name: Publish Dev if: steps.check_secrets.outputs.HAS_AWS_SECRET && github.ref == 'refs/heads/dev' shell: bash working-directory: ./target/wheels - env: - AWS_ACCESS_KEY_ID: "${{ secrets.INSTALLER_UPLOAD_KEY }}" - AWS_SECRET_ACCESS_KEY: "${{ secrets.INSTALLER_UPLOAD_SECRET }}" - AWS_REGION: us-west-2 run: | FILES=$(find . -type f -name '*.whl') while IFS= read -r file; do