From e46f9779b5a6f60c781fe268da468484c361f509 Mon Sep 17 00:00:00 2001 From: Ben Rockwood Date: Mon, 18 Sep 2023 23:04:56 -0700 Subject: [PATCH] Improvements to provider building (#1779) This change fixes several oddities in the provider build action, namely using the version variable for the providers list. It also removes manual invocation inputs because it currently builds the latest.json file based on what its built in dist/ --------- Signed-off-by: Ben Rockwood --- .github/workflows/providers.yaml | 29 +++++++++++++++++++---------- scripts/provider_bundler.sh | 10 ++++++---- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/.github/workflows/providers.yaml b/.github/workflows/providers.yaml index 3ce282e134..09264233af 100644 --- a/.github/workflows/providers.yaml +++ b/.github/workflows/providers.yaml @@ -2,24 +2,30 @@ name: 'Build & Release Providers' on: workflow_dispatch: - inputs: - version: - description: "Providers that should be released" - default: "arista aws azure equinix gcp github gitlab google-workspace ipmi k8s ms365 network oci okta opcua os slack terraform vcd vsphere" + # inputs: + # providers: + # description: "Providers to build (Space separated, leave empty for all providers)" + # default: "" + # required: false env: BUCKET: releases-us.mondoo.io - PROVIDERS: "os network" + PROVIDERS: 'arista aws azure equinix gcp github gitlab google-workspace ipmi k8s ms365 network oci okta opcua os slack terraform vcd vsphere' jobs: build: runs-on: self-hosted - timeout-minutes: 60 + timeout-minutes: 120 steps: - - name: Version from Workflow Dispatch - if: github.event_name == 'workflow_dispatch' + - name: Converge provider list inputs run: | - echo "PROVIDERS=${{ github.event.inputs.version }}" >> $GITHUB_ENV + 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 @@ -65,9 +71,12 @@ jobs: echo "{ \"name\": \"${PROVIDER}\", \"version\": \"${VERSION}\" }" >> "dist/${pkg}.json" done - - name: 'Publish latest.json' + - 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/ - name: Trigger Reindex of releases.mondoo.com diff --git a/scripts/provider_bundler.sh b/scripts/provider_bundler.sh index 67ce64e289..6de356467f 100755 --- a/scripts/provider_bundler.sh +++ b/scripts/provider_bundler.sh @@ -97,11 +97,13 @@ build_bundle windows amd64 build_bundle windows arm64 # Generate SHA256 checksums -echo "Generating SHA256 checksums..." +echo " - Generating SHA256 checksums..." cd $BUNDLE_DIST shasum -a 256 ${PROVIDER_NAME}_${PROVIDER_VERSION}_*.xz > ${PROVIDER_NAME}_${PROVIDER_VERSION}_SHA256SUMS printf "\n\n" -echo "The ${PROVIDER_NAME} provider has been built and bundled successfully." -echo "The bundles can be found in ${BUNDLE_DIST}." -echo "Time Elapsed: $((($(date +%s)-$START_TIME)/60)) minutes" \ No newline at end of file +echo " The ${PROVIDER_NAME} provider has been built and bundled successfully." +echo " The bundles can be found in ${BUNDLE_DIST}." +echo " Time Elapsed: $((($(date +%s)-$START_TIME)/60)) minutes" +echo "-------------------------------------------------------" +echo "" \ No newline at end of file