From 219a4518d761a74714c47788e6a6ae4dd24ff752 Mon Sep 17 00:00:00 2001 From: Kevin Li Date: Thu, 20 Jul 2023 08:43:47 -0700 Subject: [PATCH] ci: Add upload build to S3 action for cloud build (#486) Issue #, if available: *Description of changes:* Add upload build to S3 action to allow cloud build without generating pkg - [X] I've reviewed the guidance in CONTRIBUTING.md #### License Acceptance By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. Signed-off-by: Kevin Li --- .github/workflows/upload-build-to-S3.yaml | 109 ++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .github/workflows/upload-build-to-S3.yaml diff --git a/.github/workflows/upload-build-to-S3.yaml b/.github/workflows/upload-build-to-S3.yaml new file mode 100644 index 000000000..6f61229e1 --- /dev/null +++ b/.github/workflows/upload-build-to-S3.yaml @@ -0,0 +1,109 @@ +name: Upload build to s3 + +on: + workflow_dispatch: +env: + GO111MODULE: on + +permissions: + # This is required for configure-aws-credentials to request an OIDC JWT ID token to access AWS resources later on. + # More info: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings + id-token: write + contents: read # This is required for actions/checkout + +jobs: + macos-aarch64-build: + runs-on: [self-hosted, macos, arm64, 11, release] + timeout-minutes: 60 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + persist-credentials: false + submodules: true + - uses: actions/setup-go@v4 + with: + go-version-file: go.mod + cache: true + + - name: Make macos aarch64 build + run: | + brew install go lz4 automake autoconf libtool + make clean + make download-licenses + make FINCH_OS_IMAGE_LOCATION_ROOT=/Applications/Finch + tar -zcvf finch.${GITHUB_REF_NAME}.aarch64.tar.gz _output + shell: zsh {0} + + - name: Upload macos aarch64 build + uses: actions/upload-artifact@v2 + with: + name: finch.macos-aarch64 + path: finch.*.aarch64.tar.gz + if-no-files-found: error + + macos-x86_64-build: + runs-on: [self-hosted, macos, amd64, 11, release] + timeout-minutes: 60 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + persist-credentials: false + submodules: true + - uses: actions/setup-go@v4 + with: + go-version-file: go.mod + cache: true + + - name: Make macos x86_64 build + run: | + brew install go lz4 automake autoconf libtool + make clean + make download-licenses + make FINCH_OS_IMAGE_LOCATION_ROOT=/Applications/Finch + tar -zcvf finch.${GITHUB_REF_NAME}.x86_64.tar.gz _output + shell: zsh {0} + + - name: Upload macos x86_64 build + uses: actions/upload-artifact@v2 + with: + name: finch.macos-x86_64 + path: finch.*.x86_64.tar.gz + if-no-files-found: error + + release: + runs-on: ubuntu-latest + timeout-minutes: 5 + needs: + - macos-x86_64-build + - macos-aarch64-build + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + persist-credentials: false + + - name: configure aws credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: ${{ secrets.ROLE }} + role-session-name: dependency-upload-session + aws-region: ${{ secrets.REGION }} + + - name: Download macos aarch64 build + uses: actions/download-artifact@v2 + with: + name: finch.macos-aarch64 + path: build + + - name: Download macos x86_64 build + uses: actions/download-artifact@v2 + with: + name: finch.macos-x86_64 + path: build + # TODO: Change destination bucket after creating automation for signing. + - name: "Upload to S3" + run: | + aws s3 cp ./build/ s3://${{ secrets.DEPENDENCY_BUCKET_NAME }}/aarch64/ --recursive --exclude "*" --include "finch.${GITHUB_REF_NAME}.aarch64.tar.gz" + aws s3 cp ./build/ s3://${{ secrets.DEPENDENCY_BUCKET_NAME }}/x86-64/ --recursive --exclude "*" --include "finch.${GITHUB_REF_NAME}.x86_64.tar.gz" \ No newline at end of file