diff --git a/.github/workflows/build-and-deploy-plugins.yml b/.github/workflows/build-and-deploy-plugins.yml index 5d0a8b3..12cd6e4 100644 --- a/.github/workflows/build-and-deploy-plugins.yml +++ b/.github/workflows/build-and-deploy-plugins.yml @@ -44,3 +44,46 @@ jobs: echo "📂 Deep list of Gerrit repo:" find gerrit-repo + + - name: Build Go plugins in Docker + run: | + set -e + mkdir -p $PLUGIN_OUTPUT_DIR + BUILD_CMDS="" + + # GitHub plugins + for dir in github-repo/pkg/plugin/implementation/*; do + plugin=$(basename "$dir") + BUILD_CMDS+="go build -buildmode=plugin -buildvcs=false -o ${PLUGIN_OUTPUT_DIR}/${plugin}.so ./${dir}/cmd && " + done + + # Gerrit plugins + for dir in gerrit-repo/plugins/*; do + plugin=$(basename "$dir") + BUILD_CMDS+="go build -buildmode=plugin -buildvcs=false -o ${PLUGIN_OUTPUT_DIR}/${plugin}.so ./${dir}/cmd && " + done + + BUILD_CMDS=${BUILD_CMDS%" && "} + docker run --rm -v "$(pwd)":/app -w /app golang:1.24-bullseye sh -c "$BUILD_CMDS" + + - name: Zip the plugin binaries + run: | + cd $PLUGIN_OUTPUT_DIR + zip -r ../$ZIP_FILE *.so + cd .. + + - name: Authenticate to GCP + run: | + echo "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }}" > gcloud-key.json + gcloud auth activate-service-account --key-file=gcloud-key.json + gcloud config set project trusty-relic-370809 + env: + GOOGLE_APPLICATION_CREDENTIALS: gcloud-key.json + + - name: Upload to GCS + run: | + gsutil -m cp -r *.zip gs://${GCS_BUCKET}/ + + - name: Cleanup + run: | + rm -rf $PLUGIN_OUTPUT_DIR $ZIP_FILE gcloud-key.json