Skip to content

Commit

Permalink
Merge pull request #4 from grafana/1-k6exec-cli
Browse files Browse the repository at this point in the history
feat: reintroduce k6exec CLI + Docker image
  • Loading branch information
szkiba authored Jul 5, 2024
2 parents 4fa3450 + 02d1c6f commit 9e50427
Show file tree
Hide file tree
Showing 15 changed files with 982 additions and 2 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: release
on:
push:
tags:
- "v*"
permissions:
contents: write
packages: write

jobs:
release:
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22.2"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: "amd64,arm64"
- name: Login to GitHub packages
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "2.0.1"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/node_modules
/package.json
/yarn.lock
/coverage.txt
/coverage.txt
/k6exec
/k6exec.exe
/dist
103 changes: 103 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
project_name: k6exec
version: 2
env:
- IMAGE_OWNER=ghcr.io/grafana
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos: ["darwin", "linux", "windows"]
goarch: ["amd64", "arm64"]
ldflags:
- "-s -w -X main.version={{.Version}} -X main.appname={{.ProjectName}}"
dir: cmd/k6exec
source:
enabled: true
name_template: "{{ .ProjectName }}_{{ .Version }}_source"

archives:
- id: bundle
format: tar.gz
format_overrides:
- goos: windows
format: zip

checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"

snapshot:
name_template: "{{ incpatch .Version }}-next+{{.ShortCommit}}{{if .IsGitDirty}}.dirty{{else}}{{end}}"

changelog:
sort: asc
abbrev: -1
filters:
exclude:
- "^chore:"
- "^docs:"
- "^test:"

git:
ignore_tags:
- "nightly"
- "before-grafana"

dockers:
- id: amd64
dockerfile: Dockerfile.goreleaser
use: buildx
image_templates:
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:v{{ .Major }}-amd64"
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}-amd64"
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:latest-amd64"

build_flag_templates:
- "--platform=linux/amd64"
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=AGPL-3.0-only"
- id: arm64
dockerfile: Dockerfile.goreleaser
use: buildx
image_templates:
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:{{ .Tag }}-arm64"
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:v{{ .Major }}-arm64"
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}-arm64"
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:latest-arm64"

build_flag_templates:
- "--platform=linux/arm64"
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.licenses=AGPL-3.0-only"

docker_manifests:
- id: tag
name_template: "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:{{ .Tag }}"
image_templates:
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:{{ .Tag }}-amd64"
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:{{ .Tag }}-arm64"
- id: major
name_template: "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:v{{ .Major }}"
image_templates:
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:v{{ .Major }}-amd64"
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:v{{ .Major }}-arm64"
- id: major-minor
name_template: "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}"
image_templates:
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}-amd64"
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}-arm64"
- id: latest
name_template: "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:latest"
image_templates:
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:latest-amd64"
- "{{ .Env.IMAGE_OWNER }}/{{ .ProjectName }}:latest-arm64"
12 changes: 12 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM debian:12.6-slim
VOLUME /cache
VOLUME /state
RUN adduser -D -u 1000 -g 1000 -h /home/k6exec k6exec && \
mkdir -p /cache/k6exec /state/k6exec && \
chown -R 1000:1000 /cache /state
ENV CGO_ENABLED=1 XDG_CACHE_HOME="/cache" XDG_STATE_HOME="/state"
COPY k6exec /usr/bin/k6exec

USER 1000
WORKDIR /home/k6exec
ENTRYPOINT ["k6exec"]
Loading

0 comments on commit 9e50427

Please sign in to comment.