Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 use matrix for provider build #1806

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 12 additions & 31 deletions .github/workflows/providers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,19 @@ name: 'Build & Release Providers'

on:
workflow_dispatch:
# inputs:
# providers:
# description: "Providers to build (Space separated, leave empty for all providers)"
# default: ""
# required: false

env:
BUCKET: releases-us.mondoo.io
PROVIDERS: 'arista aws azure equinix gcp github gitlab google-workspace ipmi k8s ms365 network oci okta opcua os slack terraform vcd vsphere'

jobs:
build:
provider-build:
runs-on: self-hosted
timeout-minutes: 120
strategy:
max-parallel: 2
matrix:
provider: [arista, aws, azure, equinix, gcp, github, gitlab, google-workspace, ipmi, k8s, ms365, network, oci, okta, opcua, os, slack, terraform, vcd, vsphere ]
steps:
- name: Converge provider list inputs
run: |
if [ -z "${{ github.event.inputs.providers }}" ]; then
echo "No providers specified, building all"
echo "PROVIDERS=${PROVIDERS}" >> $GITHUB_ENV
else
echo "Building ${{ github.event.inputs.providers }}"
echo "PROVIDERS=${{ github.event.inputs.providers }}" >> $GITHUB_ENV
fi

- name: Checkout
uses: actions/checkout@v4
with:
Expand All @@ -51,14 +39,12 @@ jobs:
make providers/proto
go build -o lr ./providers-sdk/v1/lr/cli/main.go

- name: 'Build Providers'
- name: 'Build Provider'
run: |
rm -rf ./dist
for p in ${PROVIDERS}; do
scripts/provider_bundler.sh $p
done
scripts/provider_bundler.sh ${{ matrix.provider }}

- name: 'Publish Providers'
- name: 'Publish Provider'
run: |
for pkg in $(ls dist | cut -f1,2 -d_ | uniq); do
echo "Publishing $pkg"
Expand All @@ -68,17 +54,12 @@ jobs:
echo "Publishing $pkg to gs://${BUCKET}/providers/${PROVIDER}/${VERSION}/"
gsutil -m cp -c dist/${pkg}*.xz gs://${BUCKET}/providers/${PROVIDER}/${VERSION}/
gsutil -m cp -c dist/${pkg}_SHA256SUMS gs://${BUCKET}/providers/${PROVIDER}/${VERSION}/
echo "{ \"name\": \"${PROVIDER}\", \"version\": \"${VERSION}\" }" >> "dist/${pkg}.json"
done

- name: 'Generate and Publish latest.json'
run: |
echo "{ \"providers\": [$(ls dist/*.json | xargs cat | paste -sd, -)] }" > dist/latest.json
echo "Latest.json contents:"
cat dist/latest.json
echo "---"
gsutil -m cp -c dist/latest.json gs://${BUCKET}/providers/

provider-index:
needs: provider-build
runs-on: self-hosted
steps:
- name: Trigger Reindex of releases.mondoo.com
uses: peter-evans/repository-dispatch@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion scripts/provider_bundler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ build_bundle(){

echo "Building ${PROVIDER_DIST}/${PROVIDER_NAME} for ${GOOS}/${GOARCH}/${GOARM} ..."
# we switch into the path to use the local go.mods
cd ${PROVIDER_PATH} && GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -o ${PROVIDER_DIST}/${PROVIDER_NAME} main.go
cd ${PROVIDER_PATH} && CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -tags production -ldflags "-s -w" -o ${PROVIDER_DIST}/${PROVIDER_NAME} main.go

# set linux flags that do not work on macos
TAR_FLAGS=""
Expand Down