Skip to content

Commit

Permalink
ci: Add upload build to S3 action for cloud build (#486)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
KevinLiAWS authored Jul 20, 2023
1 parent 53dad06 commit 219a451
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/upload-build-to-S3.yaml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 219a451

Please sign in to comment.