-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: build pipeline using jsonnet for re-use
- Loading branch information
1 parent
2a73b15
commit b6cc287
Showing
6 changed files
with
202 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
"jobs": | ||
"loki-image": | ||
"runs-on": "ubuntu-latest" | ||
"steps": | ||
- "name": "pull loki code" | ||
"uses": "actions/checkout@v3" | ||
"with": | ||
"ref": "prepare-release-please" | ||
"repository": "grafana/loki" | ||
- "name": "Set up QEMU" | ||
"uses": "docker/setup-qemu-action@v3" | ||
"with": | ||
"go-version-file": "go.mod" | ||
- "name": "set up docker buildx" | ||
"uses": "docker/setup-buildx-action@v3" | ||
- "id": "parse-metadata" | ||
"name": "parse image metadata" | ||
"run": | | ||
mkdir -p dist | ||
platform="$(echo "${{ matrix.platform}}" | sed "s/\(.*\)\/\(.*\)/\1-\2/")" | ||
echo "platform=${platform}" >> $GITHUB_OUTPUT | ||
version=$(jq -r '."cmd/loki"' .release-please-manifest.json) | ||
echo "version=${version}" >> $GITHUB_OUTPUT | ||
"shell": "bash" | ||
- "name": "Build and export" | ||
"uses": "docker/build-push-action@v5" | ||
"with": | ||
"context": "." | ||
"file": "cmd/loki/Dockerfile" | ||
"outputs": "type=docker,dest=dist/loki-${{ steps.parse-metadata.outputs.version}}-${{ steps.parse-metadata.outputs.platform }}.tar" | ||
"platforms": "${{ matrix.platform }}" | ||
"tags": "grafana/loki:${{ steps.parse-metadata.outputs.version }}" | ||
- "name": "upload artifacts" | ||
"uses": "actions/upload-artifact@v3" | ||
"with": | ||
"name": "loki-image-${{ matrix.platform }}" | ||
"path": "dist/loki-${{ steps.parse-metadata.outputs.version}}-${{ steps.parse-metadata.outputs.platform }}.tar" | ||
"strategy": | ||
"fail-fast": true | ||
"matrix": | ||
"platform": | ||
- "linux/amd64" | ||
- "linux/arm64" | ||
- "linux/arm" | ||
"promtail-image": | ||
"runs-on": "ubuntu-latest" | ||
"steps": | ||
- "name": "pull loki code" | ||
"uses": "actions/checkout@v3" | ||
"with": | ||
"ref": "prepare-release-please" | ||
"repository": "grafana/loki" | ||
- "name": "Set up QEMU" | ||
"uses": "docker/setup-qemu-action@v3" | ||
"with": | ||
"go-version-file": "go.mod" | ||
- "name": "set up docker buildx" | ||
"uses": "docker/setup-buildx-action@v3" | ||
- "id": "parse-metadata" | ||
"name": "parse image metadata" | ||
"run": | | ||
mkdir -p dist | ||
platform="$(echo "${{ matrix.platform}}" | sed "s/\(.*\)\/\(.*\)/\1-\2/")" | ||
echo "platform=${platform}" >> $GITHUB_OUTPUT | ||
version=$(jq -r '."cmd/promtail"' .release-please-manifest.json) | ||
echo "version=${version}" >> $GITHUB_OUTPUT | ||
"shell": "bash" | ||
- "name": "Build and export" | ||
"uses": "docker/build-push-action@v5" | ||
"with": | ||
"context": "." | ||
"file": "cmd/promtail/Dockerfile" | ||
"outputs": "type=docker,dest=dist/promtail-${{ steps.parse-metadata.outputs.version}}-${{ steps.parse-metadata.outputs.platform }}.tar" | ||
"platforms": "${{ matrix.platform }}" | ||
"tags": "grafana/promtail:${{ steps.parse-metadata.outputs.version }}" | ||
- "name": "upload artifacts" | ||
"uses": "actions/upload-artifact@v3" | ||
"with": | ||
"name": "promtail-image-${{ matrix.platform }}" | ||
"path": "dist/promtail-${{ steps.parse-metadata.outputs.version}}-${{ steps.parse-metadata.outputs.platform }}.tar" | ||
"strategy": | ||
"fail-fast": true | ||
"matrix": | ||
"platform": | ||
- "linux/amd64" | ||
- "linux/arm64" | ||
- "linux/arm" | ||
"name": "release (jsonnet version)" | ||
"on": | ||
"push": | ||
"branches": | ||
- "main" | ||
- "release-[0-9].[0-9].x" | ||
- "k[0-9]*" | ||
"workflow_dispatch": {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
fetchLokiRepo: { | ||
name: 'pull loki code', | ||
uses: 'actions/checkout@v3', | ||
with: { | ||
repository: 'grafana/loki', | ||
ref: 'prepare-release-please', | ||
}, | ||
}, | ||
setupGo: { | ||
uses: 'actions/setup-go@v4', | ||
with: { | ||
'go-version-file': 'go.mod', | ||
}, | ||
}, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
local common = import 'common.libsonnet'; | ||
|
||
{ | ||
buildImage: function(name, path) { | ||
'runs-on': 'ubuntu-latest', | ||
strategy: { | ||
'fail-fast': true, | ||
matrix: { | ||
platform: [ | ||
'linux/amd64', | ||
'linux/arm64', | ||
'linux/arm', | ||
], | ||
}, | ||
}, | ||
steps: [ | ||
common.fetchLokiRepo, | ||
common.setupGo | ||
{ | ||
name: 'Set up QEMU', | ||
uses: 'docker/setup-qemu-action@v3', | ||
}, | ||
{ | ||
name: 'set up docker buildx', | ||
uses: 'docker/setup-buildx-action@v3', | ||
}, | ||
{ | ||
name: 'parse image metadata', | ||
id: 'parse-metadata', | ||
shell: 'bash', | ||
run: ||| | ||
mkdir -p dist | ||
platform="$(echo "${{ matrix.platform}}" | sed "s/\(.*\)\/\(.*\)/\1-\2/")" | ||
echo "platform=${platform}" >> $GITHUB_OUTPUT | ||
version=$(jq -r '."%s"' .release-please-manifest.json) | ||
echo "version=${version}" >> $GITHUB_OUTPUT | ||
||| % path, | ||
}, | ||
{ | ||
name: 'Build and export', | ||
uses: 'docker/build-push-action@v5', | ||
with: { | ||
context: '.', | ||
file: '%s/Dockerfile' % path, | ||
platforms: '${{ matrix.platform }}', | ||
tags: 'grafana/%s:${{ steps.parse-metadata.outputs.version }}' % name, | ||
outputs: 'type=docker,dest=dist/%s-${{ steps.parse-metadata.outputs.version}}-${{ steps.parse-metadata.outputs.platform }}.tar' % name, | ||
}, | ||
}, | ||
{ | ||
name: 'upload artifacts', | ||
uses: 'actions/upload-artifact@v3', | ||
with: { | ||
name: '%s-image-${{ matrix.platform }}' % name, | ||
path: 'dist/%s-${{ steps.parse-metadata.outputs.version}}-${{ steps.parse-metadata.outputs.platform }}.tar' % name, | ||
}, | ||
}, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
image: (import 'image.libsonnet'), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
local lib = import 'lib/lib.libsonnet'; | ||
|
||
std.manifestYamlDoc({ | ||
name: 'release (jsonnet version)', | ||
on: { | ||
workflow_dispatch: {}, | ||
push: { | ||
branches: [ | ||
'main', | ||
'release-[0-9].[0-9].x', | ||
'k[0-9]*', | ||
], | ||
}, | ||
}, | ||
jobs: { | ||
'loki-image': lib.image.buildImage("loki", "cmd/loki"), | ||
'promtail-image': lib.image.buildImage("promtail", "cmd/promtail"), | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters