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

Add version-branch commit script #156

Merged
merged 2 commits into from
Sep 11, 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
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
Loading