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 dagger run to go run ./cmd commands #108

Merged
merged 1 commit into from
Aug 1, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GitHub actions and Go packages for building Grafana using [Dagger](https://dagge
To get started, executed the following command in your terminal:

```shell
go run ./cmd --help
dagger run go run ./cmd --help
```

You can find further information in the [docs 📖](https://github.com/grafana/grafana-build/tree/main/docs)!
2 changes: 1 addition & 1 deletion actions/backend/build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ runs:
using: composite
steps:
- shell: bash
run: go run ./cmd backend build
run: dagger run go run ./cmd backend build
2 changes: 1 addition & 1 deletion actions/backend/test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ runs:
using: composite
steps:
- shell: bash
run: go run ./cmd backend test
run: dagger run go run ./cmd backend test
2 changes: 1 addition & 1 deletion actions/package/publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ runs:
steps:
- shell: bash
run: |
go run ./cmd \
dagger run go run ./cmd \
--enterprise=${{ inputs.enterprise }} \
--enterprise-ref="${{ inputs.enterprise_ref }}" \
--grafana-ref="${{ inputs.grafana_ref }}" \
Expand Down
2 changes: 1 addition & 1 deletion docs/artifact-types/deb.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Debian artifact (.deb)

```
$ go run ./cmd deb --package file://$PWD/dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.tar.gz
$ dagger run go run ./cmd deb --package file://$PWD/dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.tar.gz
# Produces dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.deb
```
2 changes: 1 addition & 1 deletion docs/artifact-types/docker-image.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Docker image artifact

```
$ go run ./cmd docker --package file://$PWD/dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.tar.gz
$ dagger run go run ./cmd docker --package file://$PWD/dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.tar.gz
# Produces dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.ubuntu.docker.tar.gz (Ubuntu)
# Produces dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.docker.tar.gz (Alpine)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/artifact-types/rpm.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RPM artifact (.rpm)

```
$ go run ./cmd rpm --package file://$PWD/dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.tar.gz
$ dagger run go run ./cmd rpm --package file://$PWD/dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.tar.gz
# Produces dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.rpm
```
2 changes: 1 addition & 1 deletion docs/artifact-types/tarball.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
This is mostly an intermitted artifact that can then be used as source to generate Debian, RPM, or other artifacts.

```
$ go run ./cmd package
$ dagger run go run ./cmd package
```
2 changes: 1 addition & 1 deletion docs/artifact-types/windows-installer.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
grafana-build can create a Windows installer out of a [Grafana tarball][pkg] using [NSIS][].

```
$ go run ./cmd windows-installer --package file://$PWD/dist/grafana.tar.gz
$ dagger run go run ./cmd windows-installer --package file://$PWD/dist/grafana.tar.gz
```

[nsis]: https://nsis.sourceforge.io/Main_Page
Expand Down
2 changes: 1 addition & 1 deletion docs/artifact-types/zip.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
This is basically just a simple repackaging of the tarball.

```
$ go run ./cmd zip --package file://$PWD/dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.tar.gz
$ dagger run go run ./cmd zip --package file://$PWD/dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.tar.gz
# Produces dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.zip
```
6 changes: 3 additions & 3 deletions docs/guides/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This actually consists of various parts as you need to have a binary of Grafana
All of that is encompassed by the `package` command:

```
$ go run ./cmd package --distro linux/amd64 --enterprise
$ dagger run go run ./cmd package --distro linux/amd64 --enterprise
```

The command above will build the backend binary for Linux on an AMD64-compatible CPU and package that up into a [single archive][tarball] with the frontend artifacts: `grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.tar.gz`
Expand All @@ -20,7 +20,7 @@ If you want to use a local checkout of Grafana (for instance if you want to buil
The following command will create a binary package for `darwin/arm64` of Grafana based on a checkout inside the `$HOME/src/github.com/grafana/grafana` folder:

```
$ go run ./cmd package --distro darwin/arm64 --grafana-dir $HOME/src/github.com/grafana/grafana
$ dagger run go run ./cmd package --distro darwin/arm64 --grafana-dir $HOME/src/github.com/grafana/grafana
```

## Platform packages
Expand All @@ -29,7 +29,7 @@ Now that you have a Grafana tarball with the main binaries and the frontend asse
grafana-build supports a handful of these specific [artifact types](../artifact-types/index.md) but for this tutorial let's build a [Debian package][deb]:

```
$ go run ./cmd deb --package file://$PWD/dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.tar.gz
$ dagger run go run ./cmd deb --package file://$PWD/dist/grafana-enterprise-10.1.0-pre_lUJuyyVXnECr_linux_amd64.tar.gz
```

This will produce `grafana_10.1.0-pre_lUJuyyVXnECr_linux_amd64.deb` within the `dist` folder.
Expand Down
2 changes: 1 addition & 1 deletion scripts/drone_publish_main.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

go run ./cmd \
dagger run go run ./cmd \
package \
--distro=linux/amd64 \
--distro=linux/arm64 \
Expand Down
2 changes: 1 addition & 1 deletion scripts/drone_publish_main_enterprise.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

go run ./cmd \
dagger run go run ./cmd \
package \
--distro=linux/amd64 \
--distro=linux/arm64 \
Expand Down
18 changes: 9 additions & 9 deletions scripts/drone_publish_tag_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e
docker run --privileged --rm tonistiigi/binfmt --install all

# Build all of the grafana.tar.gz packages.
go run ./cmd \
dagger run go run ./cmd \
package \
--yarn-cache=${YARN_CACHE_FOLDER} \
--distro=linux/amd64 \
Expand All @@ -27,7 +27,7 @@ go run ./cmd \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} > grafana.txt &

# Build the grafana-pro tar.gz package.
go run ./cmd \
dagger run go run ./cmd \
package \
--yarn-cache=${YARN_CACHE_FOLDER} \
--distro=linux/amd64 \
Expand Down Expand Up @@ -55,20 +55,20 @@ cat pro.txt grafana.txt > assets.txt
go run ./scripts/copy_npm $(cat assets.txt | grep tar.gz | grep linux | grep amd64 | grep -v enterprise | grep -v pro | grep -v sha256 -m 1) > npm.txt

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

# Use the non-pro, non-windows, non-darwin packages and create deb packages from them.
go run ./cmd deb \
dagger run go run ./cmd deb \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep -v windows | grep -v darwin | awk '{print "--package=" $0}') \
--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.
go run ./cmd rpm \
dagger run go run ./cmd rpm \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep -v windows | grep -v darwin | awk '{print "--package=" $0}') \
--checksum \
--destination=${local_dst} \
Expand All @@ -79,20 +79,20 @@ go run ./cmd rpm \
--gpg-passphrase-base64=$(echo $GPG_PASSPHRASE | base64 -w 0) > rpms.txt &

# For Windows we distribute zips and exes
go run ./cmd zip \
dagger run 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 &

go run ./cmd windows-installer \
dagger run 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
go run ./cmd docker \
dagger run 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" \
Expand All @@ -101,7 +101,7 @@ go run ./cmd docker \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} > docker.txt &

# Copy only the linux/amd64 edition frontends into a separate folder
go run ./cmd cdn \
dagger run go run ./cmd cdn \
$(cat assets.txt | grep tar.gz | grep pro | grep linux | grep amd64 | grep -v docker | grep -v sha256 | awk '{print "--package=" $0}') \
--destination=${local_dst} \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} > cdn.txt &
Expand Down
12 changes: 6 additions & 6 deletions scripts/drone_publish_tag_enterprise.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e
docker run --privileged --rm tonistiigi/binfmt --install all

# Build all of the grafana.tar.gz packages.
go run ./cmd \
dagger run go run ./cmd \
package \
--yarn-cache=${YARN_CACHE_FOLDER} \
--distro=linux/amd64 \
Expand All @@ -31,14 +31,14 @@ go run ./cmd \
echo "Done building tar.gz packages..."

# Use the non-windows, non-darwin packages and create deb packages from them.
go run ./cmd deb \
dagger run go run ./cmd deb \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep -v windows | grep -v darwin | awk '{print "--package=" $0}') \
--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.
go run ./cmd rpm \
dagger run go run ./cmd rpm \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep -v windows | grep -v darwin | awk '{print "--package=" $0}') \
--checksum \
--destination=${local_dst} \
Expand All @@ -49,20 +49,20 @@ go run ./cmd rpm \
--gpg-passphrase-base64=$(echo $GPG_PASSPHRASE | base64 -w 0) > rpms.txt &

# For Windows we distribute zips and exes
go run ./cmd zip \
dagger run 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 &

go run ./cmd windows-installer \
dagger run 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
go run ./cmd docker \
dagger run 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" \
Expand Down
14 changes: 7 additions & 7 deletions scripts/drone_publish_tag_grafana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e
docker run --privileged --rm tonistiigi/binfmt --install all

# Build all of the grafana.tar.gz packages.
go run ./cmd \
dagger run go run ./cmd \
package \
--yarn-cache=${YARN_CACHE_FOLDER} \
--distro=linux/amd64 \
Expand All @@ -30,20 +30,20 @@ echo "Done building tar.gz packages..."
go run ./scripts/copy_npm $(cat assets.txt | grep tar.gz | grep linux | grep amd64 | grep -v sha256 -m 1) > npm.txt &

# Copy only the linux/amd64 edition storybook into a separate folder
go run ./cmd storybook \
dagger run 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 packages and create deb packages from them.
go run ./cmd deb \
dagger run go run ./cmd deb \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep -v windows | grep -v darwin | awk '{print "--package=" $0}') \
--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.
go run ./cmd rpm \
dagger run go run ./cmd rpm \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | grep -v windows | grep -v darwin | awk '{print "--package=" $0}') \
--checksum \
--destination=${local_dst} \
Expand All @@ -54,20 +54,20 @@ go run ./cmd rpm \
--gpg-passphrase-base64=$(echo $GPG_PASSPHRASE | base64 -w 0) > rpms.txt &

# For Windows we distribute zips and exes
go run ./cmd zip \
dagger run 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 &

go run ./cmd windows-installer \
dagger run 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
go run ./cmd docker \
dagger run 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" \
Expand Down
8 changes: 4 additions & 4 deletions scripts/drone_publish_tag_pro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -e
docker run --privileged --rm tonistiigi/binfmt --install all

# Build all of the grafana.tar.gz packages.
go run ./cmd \
dagger run go run ./cmd \
package \
--yarn-cache=${YARN_CACHE_FOLDER} \
--distro=linux/amd64 \
Expand All @@ -30,14 +30,14 @@ go run ./cmd \
echo "Done building tar.gz packages..."

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

# Build a docker image for all .tar.gz packages
go run ./cmd docker \
dagger run go run ./cmd docker \
$(cat assets.txt | grep tar.gz | grep -v docker | grep -v sha256 | awk '{print "--package=" $0}') \
--checksum \
--ubuntu-base="ubuntu:22.10" \
Expand All @@ -46,7 +46,7 @@ go run ./cmd docker \
--gcp-service-account-key-base64=${GCP_KEY_BASE64} > docker.txt &

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