Skip to content

Commit

Permalink
Add version-branch commit script (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
kminehart committed Sep 11, 2023
1 parent f679c2f commit 6476be0
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
100 changes: 100 additions & 0 deletions scripts/drone_build_v_branch_grafana.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env bash

# This script runs in Grafana's CI when a commit is made to a 'v[0-9].*' branch.

dst="${DESTINATION}/${DRONE_BUILD_EVENT}/${DRONE_BRANCH}"
local_dst="file://dist/${DRONE_BUILD_EVENT}"
set -e

# This command enables qemu emulators for building Docker images for arm64/armv6/armv7/etc on the host.
docker run --privileged --rm tonistiigi/binfmt --install all

# Build all of the grafana.tar.gz packages.
echo "Building tar.gz packages..."
dagger run --silent go run ./cmd \
package \
--yarn-cache=${YARN_CACHE_FOLDER} \
--distro=linux/amd64 \
--distro=linux/arm64 \
--distro=linux/arm/v6 \
--distro=linux/arm/v7 \
--distro=windows/amd64 \
--distro=darwin/amd64 \
--checksum \
--build-id=${DRONE_BUILD_NUMBER} \
--grafana-dir=${GRAFANA_DIR} \
--github-token=${GITHUB_TOKEN} \
--go-version=${GO_VERSION} \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} > assets.txt

echo "Done building tar.gz packages..."
cat assets.txt

# Copy only the linux/amd64 edition npm artifacts into a separate folder
dagger run --silent go run ./cmd npm \
$(cat assets.txt | grep tar.gz | grep linux | grep amd64 | grep -v sha256 | awk '{print "--package=" $0}') \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} > npm.txt

# Copy only the linux/amd64 edition storybook into a separate folder
dagger run --silent go run ./cmd storybook \
$(cat assets.txt | grep tar.gz | grep linux | grep amd64 | grep -v sha256 | awk '{print "--package=" $0}') \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} > storybook.txt

# Use the non-windows, non-darwin, non-rpi packages and create deb packages from them.
dagger run --silent go run ./cmd deb \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep -v windows | grep -v darwin | grep -v arm-6 | awk '{print "--package=" $0}') \
--checksum \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} > debs.txt

# Use the armv7 package to build the `rpi` specific version.
dagger run --silent go run ./cmd deb \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep -v windows | grep -v darwin | grep arm-6 | awk '{print "--package=" $0}') \
--name=grafana-rpi \
--checksum \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} >> debs.txt

# Make rpm installers for all the same Linux distros, and sign them because RPM packages are signed.
dagger run --silent go run ./cmd rpm \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep -v windows | grep -v darwin | grep -v arm-6 | awk '{print "--package=" $0}') \
--checksum \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} \
--sign=true \
--gpg-private-key-base64="${GPG_PRIVATE_KEY}" \
--gpg-public-key-base64="${GPG_PUBLIC_KEY}" \
--gpg-passphrase="${GPG_PASSPHRASE}" > rpms.txt

# For Windows we distribute zips and exes
dagger run --silent go run ./cmd zip \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep windows | awk '{print "--package=" $0}') \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} \
--checksum > zips.txt

dagger run --silent go run ./cmd windows-installer \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep windows | awk '{print "--package=" $0}') \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} \
--checksum > exes.txt

# Build a docker image for all Linux distros except armv6
dagger run --silent go run ./cmd docker \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep -v windows | grep -v darwin | grep -v arm-6 | awk '{print "--package=" $0}') \
--checksum \
--ubuntu-base="ubuntu:22.10" \
--alpine-base="alpine:3.18.0" \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} > docker.txt

cat debs.txt rpms.txt zips.txt exes.txt docker.txt npm.txt storybook.txt >> assets.txt

echo "Final list of artifacts:"
cat assets.txt

# Move the tar.gz packages to their expected locations
cat assets.txt | go run ./scripts/move_packages.go ./dist/prerelease
1 change: 1 addition & 0 deletions scripts/drone_publish_tag_grafana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dagger run --silent go run ./cmd \
--build-id=${DRONE_BUILD_NUMBER} \
--grafana-dir=${GRAFANA_DIR} \
--github-token=${GITHUB_TOKEN} \
--go-version=${GO_VERSION} \
--version=${DRONE_TAG} \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} > assets.txt
Expand Down

0 comments on commit 6476be0

Please sign in to comment.