Skip to content

Commit

Permalink
Merge pull request #13 from digorgonzola/upload_to_s3
Browse files Browse the repository at this point in the history
Upload to s3
  • Loading branch information
digorgonzola authored Aug 25, 2022
2 parents 8a46481 + cd40f09 commit 85077ea
Showing 1 changed file with 105 additions and 9 deletions.
114 changes: 105 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,127 @@ on:
release:
types:
- created
#### Use for testing locally with nektos/act. Currently doesn't work on action "release"
# [push]

jobs:
build-and-publish:
build_and_publish:
name: create release with artifacts
runs-on: ubuntu-latest
outputs:
wheel_file: ${{ steps.wheel_file.outputs.WHEEL }}

steps:
- uses: actions/checkout@v3
- name: Checkout repo
uses: actions/checkout@v3

- uses: unfor19/install-aws-cli-action@master
if: ${{ env.ACT }}

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ap-southeast-2
role-session-name: aws_session
role-skip-session-tagging: true
role-duration-seconds: 900

- name: Setup python
uses: actions/setup-python@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v3
python-version: '3.8.13'
# cache: 'pip'

- name: Install build tools
run: python -m pip install build --user

- name: Build wheels
run: python -m build --outdir wheels

- uses: actions/upload-artifact@v3
if: ${{ !env.ACT }}
with:
name: release_artifact
path: wheels/*.whl

- name: Attach wheel to release
if: ${{ !env.ACT }}
uses: softprops/action-gh-release@v1
with:
files: wheels/*.whl
- name: Upload to S3 bucket
uses: hkusu/s3-upload-action@v2

- name: Get wheel filename
id: wheel_file
run: |
echo "::set-output name=WHEEL::$(find wheels -type f -iname '*.whl' -printf '%f\n')"
- name: Upload wheel(s) to S3
run: |
aws s3 cp wheels/${{ steps.wheel_file.outputs.WHEEL }} s3://${{ secrets.AWS_ARTIFACT_BUCKET }}/releases/python-aodncore/
copy_artifact_rc:
name: copy wheel to rc folder
runs-on: ubuntu-latest
needs: build_and_publish
steps:
- name: wait for approval
uses: trstringer/manual-approval@v1
if: ${{ !env.ACT }}
with:
secret: ${{ github.TOKEN }}
approvers: digorgonzola

- uses: unfor19/install-aws-cli-action@master
if: ${{ env.ACT }}

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ap-southeast-2
role-skip-session-tagging: true
role-duration-seconds: 900

- name: promote release artifact to rc
run: |
aws s3 cp \
s3://${{ secrets.AWS_ARTIFACT_BUCKET }}/releases/python-aodncore/${{ needs.build_and_publish.outputs.wheel_file }} \
s3://${{ secrets.AWS_ARTIFACT_BUCKET }}/promoted/python-aodncore/rc/
copy_artifact_prod:
name: copy wheel to prod folder
runs-on: ubuntu-latest
needs:
- build_and_publish
- copy_artifact_rc
steps:
- name: wait for approval
uses: trstringer/manual-approval@v1
if: ${{ !env.ACT }}
with:
secret: ${{ github.TOKEN }}
approvers: digorgonzola

- uses: unfor19/install-aws-cli-action@master
if: ${{ env.ACT }}

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ap-southeast-2
aws-bucket: ${{ secrets.AWS_ARTIFACT_BUCKET }}
file-path: wheels/*.whl
destination-dir: /releases/python-aodncore
role-skip-session-tagging: true
role-duration-seconds: 900

- name: promote release artifact to rc
run: |
aws s3 cp \
s3://${{ secrets.AWS_ARTIFACT_BUCKET }}/releases/python-aodncore/${{ needs.build_and_publish.outputs.wheel_file }} \
s3://${{ secrets.AWS_ARTIFACT_BUCKET }}/promoted/python-aodncore/prod/

0 comments on commit 85077ea

Please sign in to comment.