diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..62af309
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,14 @@
+version: 2
+updates:
+ - package-ecosystem: "gomod"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ day: "sunday"
+ time: "16:00"
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ day: "sunday"
+ time: "16:00"
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 0000000..d0f8164
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,36 @@
+name: lint
+
+on:
+ pull_request:
+ branches:
+ - main
+ workflow_dispatch:
+ push:
+ branches:
+ - main
+ paths-ignore:
+ - "docs/**"
+ - README.md
+ - "releases/**"
+
+permissions:
+ contents: read
+
+jobs:
+ lint:
+ name: lint
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ - name: Setup go
+ uses: actions/setup-go@v5
+ with:
+ go-version: "1.22.2"
+ cache: false
+ - name: Go linter
+ uses: golangci/golangci-lint-action@v6
+ with:
+ version: v1.57.2
+ args: --timeout=30m
+ install-mode: binary
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..37c28de
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -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 }}
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..39915b1
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,49 @@
+name: test
+
+on:
+ pull_request:
+ branches:
+ - main
+ workflow_dispatch:
+ push:
+ branches:
+ - main
+ paths-ignore:
+ - "docs/**"
+ - README.md
+ - "releases/**"
+
+jobs:
+ test:
+ name: Test
+ strategy:
+ matrix:
+ platform:
+ - ubuntu-latest
+ - macos-latest
+ - windows-latest
+ runs-on: ${{matrix.platform}}
+ steps:
+ - name: Install Go
+ uses: actions/setup-go@v5
+ with:
+ go-version: "1.22.2"
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Test
+ run: go test -race -count 1 ./...
+
+ - name: Coverage Test
+ if: ${{ matrix.platform == 'ubuntu-latest' && github.ref_name == 'main' }}
+ run: go test -count 1 -coverprofile=coverage.txt ./...
+ - name: Upload Coverage
+ if: ${{ matrix.platform == 'ubuntu-latest' && github.ref_name == 'main' }}
+ uses: codecov/codecov-action@v4.5.0
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
+ slug: grafana/k6dist
+
+ - name: Generate Go Report Card
+ if: ${{ matrix.platform == 'ubuntu-latest' && github.ref_name == 'main' }}
+ uses: creekorful/goreportcard-action@v1.0
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a10ea6e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/build
+/dist
+/recent.json
+/k6dist
\ No newline at end of file
diff --git a/.golangci.yml b/.golangci.yml
new file mode 100644
index 0000000..b8b20f5
--- /dev/null
+++ b/.golangci.yml
@@ -0,0 +1,133 @@
+# v1.57.2
+# Please don't remove the first line. It uses in CI to determine the golangci version
+run:
+ timeout: 5m
+
+issues:
+ # Maximum issues count per one linter. Set to 0 to disable. Default is 50.
+ max-issues-per-linter: 0
+ # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
+ max-same-issues: 0
+
+ # We want to try and improve the comments in the k6 codebase, so individual
+ # non-golint items from the default exclusion list will gradually be added
+ # to the exclude-rules below
+ exclude-use-default: false
+
+ exclude-rules:
+ # Exclude duplicate code and function length and complexity checking in test
+ # files (due to common repeats and long functions in test code)
+ - path: _(test|gen)\.go
+ linters:
+ - cyclop
+ - dupl
+ - gocognit
+ - funlen
+ - lll
+ - forcetypeassert
+ - path: js\/modules\/k6\/html\/.*\.go
+ text: "exported: exported "
+ linters:
+ - revive
+ - path: js\/modules\/k6\/http\/.*_test\.go
+ linters:
+ # k6/http module's tests are quite complex because they often have several nested levels.
+ # The module is in maintainance mode, so we don't intend to port the tests to a parallel version.
+ - paralleltest
+ - tparallel
+ - linters:
+ - staticcheck # Tracked in https://github.com/grafana/xk6-grpc/issues/14
+ text: "The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated."
+ - linters:
+ - forbidigo
+ text: 'use of `os\.(SyscallError|Signal|Interrupt)` forbidden'
+
+linters-settings:
+ exhaustive:
+ default-signifies-exhaustive: true
+ cyclop:
+ max-complexity: 25
+ dupl:
+ threshold: 150
+ goconst:
+ min-len: 10
+ min-occurrences: 4
+ funlen:
+ lines: 80
+ statements: 60
+ forbidigo:
+ forbid:
+ - '^(fmt\\.Print(|f|ln)|print|println)$'
+ # Forbid everything in os, except os.Signal and os.SyscalError
+ - '^os\.(.*)$(# Using anything except Signal and SyscallError from the os package is forbidden )?'
+ # Forbid everything in syscall except the uppercase constants
+ - '^syscall\.[^A-Z_]+$(# Using anything except constants from the syscall package is forbidden )?'
+ - '^logrus\.Logger$'
+
+linters:
+ disable-all: true
+ enable:
+ - asasalint
+ - asciicheck
+ - bidichk
+ - bodyclose
+ - contextcheck
+ - cyclop
+ - dogsled
+ - dupl
+ - durationcheck
+ - errcheck
+ - errchkjson
+ - errname
+ - errorlint
+ - exhaustive
+ - exportloopref
+ - forbidigo
+ - forcetypeassert
+ - funlen
+ - gocheckcompilerdirectives
+ - gochecknoglobals
+ - gocognit
+ - goconst
+ - gocritic
+ - gofmt
+ - gofumpt
+ - goimports
+ - gomoddirectives
+ - goprintffuncname
+ - gosec
+ - gosimple
+ - govet
+ - importas
+ - ineffassign
+ - interfacebloat
+ - lll
+ - makezero
+ - misspell
+ - nakedret
+ - nestif
+ - nilerr
+ - nilnil
+ - noctx
+ - nolintlint
+ - nosprintfhostport
+ - paralleltest
+ - prealloc
+ - predeclared
+ - promlinter
+ - revive
+ - reassign
+ - rowserrcheck
+ - sqlclosecheck
+ - staticcheck
+ - stylecheck
+ - tenv
+ - tparallel
+ - typecheck
+ - unconvert
+ - unparam
+ - unused
+ - usestdlibvars
+ - wastedassign
+ - whitespace
+ fast: false
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
new file mode 100644
index 0000000..72d2d87
--- /dev/null
+++ b/.goreleaser.yaml
@@ -0,0 +1,99 @@
+project_name: k6dist
+version: 2
+env:
+ - IMAGE_OWNER=ghcr.io/grafana
+before:
+ hooks:
+ - go mod tidy
+dist: build/dist
+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/k6dist
+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:"
+
+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"
diff --git a/CODEOWNERS b/CODEOWNERS
new file mode 100644
index 0000000..f4cb4f9
--- /dev/null
+++ b/CODEOWNERS
@@ -0,0 +1 @@
+* @grafana/k6-extensions
\ No newline at end of file
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..45d257b
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,133 @@
+
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, caste, color, religion, or sexual
+identity and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the overall
+ community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or advances of
+ any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email address,
+ without their explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at
+[INSERT CONTACT METHOD].
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series of
+actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or permanent
+ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within the
+community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.1, available at
+[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
+
+Community Impact Guidelines were inspired by
+[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
+
+For answers to common questions about this code of conduct, see the FAQ at
+[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
+[https://www.contributor-covenant.org/translations][translations].
+
+[homepage]: https://www.contributor-covenant.org
+[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
+[Mozilla CoC]: https://github.com/mozilla/diversity
+[FAQ]: https://www.contributor-covenant.org/faq
+[translations]: https://www.contributor-covenant.org/translations
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..4ae0179
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,129 @@
+# How to contribute to k6registry
+
+Thank you for your interest in contributing to **k6registry**!
+
+Before you begin, make sure to familiarize yourself with the [Code of Conduct](CODE_OF_CONDUCT.md). If you've previously contributed to other open source project, you may recognize it as the classic [Contributor Covenant](https://contributor-covenant.org/).
+
+
+## Prerequisites
+
+The tools listed in the [tools] section should be installed before contributing. It is advisable to first install the [cdo] tool, which can be used to easily perform the tasks described here. The [cdo] tool can most conveniently be installed using the [eget] tool.
+
+```bash
+eget szkiba/cdo
+```
+
+The [cdo] tool can then be used to perform the tasks described in the following sections.
+
+Help about tasks:
+
+```
+cdo
+```
+
+[cdo]: (https://github.com/szkiba/cdo)
+[eget]: https://github.com/zyedidia/eget
+
+## tools - Install the required tools
+
+Contributing will require the use of some tools, which can be installed most easily with a well-configured [eget] tool.
+
+```bash
+eget mikefarah/yq
+eget atombender/go-jsonschema
+eget szkiba/mdcode
+eget golangci/golangci-lint
+eget goreleaser/goreleaser
+```
+
+## schema - Update schema and generate code
+
+After modifying registry schema ([registry.schema.json]), the [registry_gen.go] file must be regenerated.
+
+```bash
+curl -s -o internal/registry/registry.schema.json https://raw.githubusercontent.com/grafana/k6-extension-registry/main/registry.schema.json
+go-jsonschema --capitalization URL --capitalization OSS -p registry --only-models -o internal/registry/registry_gen.go internal/registry/registry.schema.json
+```
+
+[registry.schema.json]: internal/registry/registry.schema.json
+[registry_gen.go]: internal/registry/registry_gen.go
+
+## readme - Update README.md
+
+After changing the CLI tool or example registry, the documentation must be updated in README.md.
+
+```bash
+go run ./tools/gendoc README.md
+```
+
+### lint - Run the linter
+
+The `golangci-lint` tool is used for static analysis of the source code.
+It is advisable to run it before committing the changes.
+
+```bash
+golangci-lint run
+```
+
+### test - Run the tests
+
+```bash
+go test -count 1 -race -coverprofile=coverage.txt ./...
+```
+
+[test]: <#test---run-the-tests>
+
+### coverage - View the test coverage report
+
+Requires
+: [test]
+
+```bash
+go tool cover -html=coverage.txt
+```
+
+### build - Build the executable binary
+
+This is the easiest way to create an executable binary (although the release process uses the `goreleaser` tool to create release versions).
+
+```bash
+go build -ldflags="-w -s" -o k6dist ./cmd/k6dist
+```
+
+[build]: <#build---build-the-executable-binary>
+
+### snapshot - Creating an executable binary with a snapshot version
+
+The goreleaser command-line tool is used during the release process. During development, it is advisable to create binaries with the same tool from time to time.
+
+```bash
+rm -f k6registry
+goreleaser build --snapshot --clean --single-target -o k6dist
+```
+
+[snapshot]: <#snapshot---creating-an-executable-binary-with-a-snapshot-version>
+
+### docker - Build docker image
+
+Building a Docker image. Before building the image, it is advisable to perform a snapshot build using goreleaser. To build the image, it is advisable to use the same `Docker.goreleaser` file that `goreleaser` uses during release.
+
+Requires
+: snapshot
+
+```bash
+docker build -t k6dist -f Dockerfile.goreleaser .
+```
+
+### clean - Delete the build directory
+
+```bash
+rm -rf build
+```
+
+### update - Update everything
+
+The most robust thing is to update everything (both the schema and the example) after modifying the source.
+
+Requires
+: schema, readme
+
diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser
new file mode 100644
index 0000000..7459807
--- /dev/null
+++ b/Dockerfile.goreleaser
@@ -0,0 +1,10 @@
+FROM debian:12.6-slim
+
+RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && update-ca-certificates && \
+ addgroup --system --gid 127 docker && adduser --uid 1001 --gid 127 --disabled-password runner
+
+COPY k6dist /usr/bin/
+
+USER runner
+
+ENTRYPOINT ["k6dist"]
diff --git a/Dockerfile.tpl b/Dockerfile.tpl
new file mode 100644
index 0000000..b834d60
--- /dev/null
+++ b/Dockerfile.tpl
@@ -0,0 +1,31 @@
+# Browser-less bundle
+FROM alpine:3.18 AS release
+
+RUN adduser -D -u 12345 -g 12345 k6
+
+COPY {{.Executable}} /usr/bin/k6
+
+USER k6
+WORKDIR /home/k6
+
+ENTRYPOINT ["k6"]
+
+# Browser-enabled bundle
+FROM release AS with-browser
+
+USER root
+
+COPY --from=release /usr/bin/k6 /usr/bin/k6
+RUN apk --no-cache add chromium-swiftshader
+
+USER k6
+
+ENV CHROME_BIN=/usr/bin/chromium-browser
+ENV CHROME_PATH=/usr/lib/chromium/
+
+ENV K6_BROWSER_HEADLESS=true
+# no-sandbox chrome arg is required to run chrome browser in
+# alpine and avoids the usage of SYS_ADMIN Docker capability
+ENV K6_BROWSER_ARGS=no-sandbox
+
+ENTRYPOINT ["k6"]
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..0ad25db
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,661 @@
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU Affero General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+.
diff --git a/NOTES.md.tpl b/NOTES.md.tpl
new file mode 100644
index 0000000..766b4df
--- /dev/null
+++ b/NOTES.md.tpl
@@ -0,0 +1,18 @@
+π **{{.Name}}** `{{.Version}}` is here!
+
+## Contents
+
+Name | Version | Previous | Description
+-----|---------|----------|------------
+{{- range .Registry }}
+[{{.Repo.Name}}]({{.Repo.URL}}) | {{ template "version" (dict "Repo" .Repo "Version" (index .Versions 0)) }} | {{if eq (index .Versions 0) (index .Versions 1)}}β‘{{else}}{{if empty (index .Versions 1)}}β{{else}}{{ template "version" (dict "Repo" .Repo "Version" (index .Versions 1)) }}{{end}}{{end}} | {{ .Description }}
+{{- end }}
+
+β‘ means same, β means missing
+
+
+{{.Footer}}
+
+{{- define "version" -}}
+{{if hasPrefix "https://github.com" .Repo.URL }}[{{.Version}}](https://github.com/{{.Repo.Owner}}/{{.Repo.Name}}/releases/tag/{{.Version}}){{else}}{{.Version}}{{end}}
+{{- end -}}
\ No newline at end of file
diff --git a/README.md b/README.md
index f518760..965e6ab 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,132 @@
# k6dist
+
+**k6 distro builder**
+
+k6dist is a CLI tool and a GitHub Action that allows you to build k6 distributions with extensions.
+
+```bash
+k6dist https://registry.k6.io/tier/official.json
+```
+
+The extensions to be embedded can be specified with an extension registry. The location of the extension registry can be specified with HTTP(S) URL or filesystem path.
+
+k6dist builds k6 for the specified platforms with the extensions listed in the registry. After that, it also creates archive files corresponding to the platform (`.zip` for Windows, otherwise `.tar.gz` format).
+
+In addition to the executable, the readme and the license file can be included in the archive.
+
+A release notes file is also prepared, in which the extensions are listed with their current and previous versions and their description. The content of the release notes file can be customized, using a go template file.
+
+## Install
+
+Precompiled binaries can be downloaded and installed from the [Releases](https://github.com/grafana/k6dist/releases) page.
+
+If you have a go development environment, the installation can also be done with the following command:
+
+```
+go install github.com/grafana/k6dist/cmd/k6dist@latest
+```
+
+## GitHub Action
+
+`grafana/k6dist` is a GitHub Action that enables the building of k6 distibutions with extensions.
+
+The extensions to be embedded can be specified with an extension registry. The location of the extension registry can be specified with HTTP(S) URL or filesystem path.
+
+**Inputs**
+
+See the CLI [Flags](#flags) section for the default values ββfor these parameters.
+
+name | reqired | description
+---------------|---------|-------------
+in | yes | extension registry location (URL or file path)
+distro_name | no | distro name
+distro_version | no | distro version
+platform | no | list of target platforms
+executable | no | executable file name template
+archive | no | archive file name template
+docker | no | generated Dockerfile name template
+docker_template| no | template for the generated Dockerfile
+notes | no | generated release notes file name template
+notes_template | no | template for the generated release notes
+notes_latest | no | latest release notes file for change detection
+readme | no | readme file to be added to the archive
+license | no | license file to be added to the archive
+verbose | no | enable verbose logging
+quiet | no | disable normal logging
+
+The change can be indicated by comparing the generated release notes to the latest release notes. The location of the latest release notes path can be passed in the `notes_latest` action parameter. The `changed` output variable will be `true` or `false` depending on whether the release has changed or not compared to the latest release notes. If the release has not changed, the build step is skipped.
+
+**Outputs**
+
+name | description
+--------|------------
+changed | `true` if the release has changed compared to `notes_latest`, otherwise `false`
+version | the distro release version
+
+**Example usage**
+
+```yaml
+- name: Build k6 distro
+ uses: grafana/k6dist@v0.1.0
+ with:
+ in: "https://registry.k6.io/product/cloud.json"
+ notes_latest: "latest-release-notes.md"
+```
+
+## CLI
+
+
+## k6dist
+
+k6 distro builder
+
+### Synopsis
+
+Build k6 distribution with extensions.
+
+k6dist enables building k6 distributions with extensions. The extensions to be embedded can be specified with an extension registry. The location of the registry can be specified with http(s) URL or filesystem path.
+
+The location of the registry can be specified as a command line argument. If omitted, the URL of the registry subset containing the official k6 extensions is the default.
+
+Each flag has a meaningful default value.
+
+k6dist builds k6 for the specified platforms with the extensions listed in the registry. After that, it also creates archive files corresponding to the platform (`.zip` for Windows, otherwise `.tar.gz` format).
+
+In addition to the executable, the readme and the license file can be included in the archive. Their names are detected, but can also be specified using the `--readme` and `--license` flags.
+
+The locations of executables and archives can be specified with the go template expression using the `--executable` and `--archive` flags.
+
+A release notes file is also prepared, in which the extensions are listed with their current and previous versions and their description. The release notes file can be customized, using the `--notes-template` flag you can specify a go template file to generate the release notes.
+
+
+```
+k6dist [flags] [registry-location]
+```
+
+### Flags
+
+```
+ --distro-name string distro name (default detect)
+ --distro-version string distro version (default current date in YY.MM.DD format)
+ --platform strings target platforms (default [linux/amd64,darwin/amd64,windows/amd64])
+ --executable string executable file name (default "dist/{{.Name}}_{{.OS}}_{{.Arch}}/k6{{.ExeExt}}")
+ --archive string archive file name (default "dist/{{.Name}}_{{.Version}}_{{.OS}}_{{.Arch}}{{.ZipExt}}")
+ --docker string generated Dockerfile name (default Dockerfile next to the exe)
+ --docker-template string template for the generated Dockerfile (default embedded)
+ --notes string generated release notes file name (default "dist/{{.Name}}_{{.Version}}.md")
+ --notes-template string template for the generated release notes (default embedded)
+ --notes-latest string latest release notes file for change detection
+ --readme string readme file to be added to the archive (default detect)
+ --license string license file to be added to the archive (default detect)
+ --single-target build only for the current runtime platform
+ -v, --verbose enable verbose logging
+ -q, --quiet disable normal logging
+ -V, --version print version
+ -h, --help help for k6dist
+```
+
+
+
+## Contribure
+
+If you want to contribute, start by reading [CONTRIBUTING.md](CONTRIBUTING.md).
diff --git a/action.yml b/action.yml
new file mode 100644
index 0000000..2a2cd19
--- /dev/null
+++ b/action.yml
@@ -0,0 +1,79 @@
+name: k6dist
+description: k6 distribution builder
+author: Grafana Labs
+
+branding:
+ icon: archive
+ color: orange
+
+inputs:
+ in:
+ description: input file name
+ required: true
+
+ distro_name:
+ description: distro name
+ required: false
+
+ distro_version:
+ description: distro version
+ required: false
+
+ platform:
+ description: list of target platforms
+ required: false
+
+ executable:
+ description: executable file name template
+ required: false
+
+ archive:
+ description: archive file name template
+ required: false
+
+ docker:
+ description: generated Dockerfile name template
+ required: false
+
+ docker_template:
+ description: template for the generated Dockerfile
+ required: false
+
+ notes:
+ description: generated release notes file name template
+ required: false
+
+ notes_template:
+ description: template for the generated release notes
+ required: false
+
+ notes_latest:
+ description: latest release notes file for change detection
+ required: false
+
+ readme:
+ description: readme file to be added to the archive
+ required: false
+
+ license:
+ description: license file to be added to the archive
+ required: false
+
+ verbose:
+ description: enable verbose logging
+ required: false
+
+ quiet:
+ description: isable normal logging
+ required: false
+
+outputs:
+ changed:
+ description: "true if the release has changed compared to notes_latest"
+
+ version:
+ description: "the distro release version"
+
+runs:
+ using: docker
+ image: docker://ghcr.io/grafana/k6dist:v0
diff --git a/build.go b/build.go
new file mode 100644
index 0000000..0496863
--- /dev/null
+++ b/build.go
@@ -0,0 +1,282 @@
+package k6dist
+
+import (
+ "archive/tar"
+ "archive/zip"
+ "compress/gzip"
+ "context"
+ "io"
+ "log/slog"
+ "os"
+ "path/filepath"
+ "strings"
+
+ "github.com/grafana/k6dist/internal/registry"
+ "github.com/grafana/k6foundry"
+)
+
+func detectChange(registry registry.Registry, latest string) (bool, error) {
+ if len(latest) == 0 {
+ return true, nil
+ }
+
+ contents, err := os.ReadFile(filepath.Clean(latest)) //nolint:forbidigo
+ if err != nil {
+ return false, err
+ }
+
+ found, modules, err := parseNotes(contents)
+ if err != nil {
+ return false, err
+ }
+
+ if !found {
+ return false, nil
+ }
+
+ return registry.AddLatest(modules), nil
+}
+
+func newBuilder(ctx context.Context, modules registry.Modules) (k6foundry.Builder, error) {
+ cgo := "0"
+ if modules.Cgo() {
+ cgo = "1"
+ }
+
+ return k6foundry.NewNativeBuilder(
+ ctx,
+ k6foundry.NativeBuilderOpts{
+ Logger: slog.Default(),
+ Stdout: os.Stdout, //nolint:forbidigo
+ Stderr: os.Stderr, //nolint:forbidigo
+ GoOpts: k6foundry.GoOpts{
+ CopyGoEnv: true,
+ Env: map[string]string{"GOWORK": "off", "CGO_ENABLED": cgo},
+ },
+ },
+ )
+}
+
+// Build builds k6 binaries and archives based on opts parameter.
+func Build(ctx context.Context, opts *Options) (bool, error) {
+ opts.setDefaults()
+
+ registry, err := registry.LoadRegistry(ctx, opts.Registry)
+ if err != nil {
+ return false, err
+ }
+
+ changed, err := detectChange(registry, opts.NotesLatest)
+ if err != nil {
+ return false, err
+ }
+
+ if !changed {
+ return false, nil
+ }
+
+ notes, err := expandNotes(opts.Name, opts.Version, registry, opts.NotesTemplate)
+ if err != nil {
+ return false, err
+ }
+
+ filename, err := expandAsTargetPath("notes", opts.Notes, newInstsanceData(opts.Name, opts.Version, &Platform{}))
+ if err != nil {
+ return false, err
+ }
+
+ if err := os.WriteFile(filename, []byte(notes), 0o600); err != nil { //nolint:forbidigo
+ return false, err
+ }
+
+ modules := registry.ToModules()
+ k6Version, mods := modules.ToFoundry()
+
+ builder, err := newBuilder(ctx, modules)
+ if err != nil {
+ return false, err
+ }
+
+ for _, platform := range opts.Platforms {
+ data := newInstsanceData(opts.Name, opts.Version, platform)
+
+ filename, err := expandAsTargetPath("executable", opts.Executable, data)
+ if err != nil {
+ return false, err
+ }
+
+ err = buildExecutable(ctx, builder, platform, k6Version, mods, filename)
+ if err != nil {
+ return false, err
+ }
+
+ err = createDockerfile(filename, opts.DockerfileTemplate, opts.Dockerfile)
+ if err != nil {
+ return false, err
+ }
+
+ archive, err := expandAsTargetPath("archive", opts.Archive, data)
+ if err != nil {
+ return false, err
+ }
+
+ err = buildArchive(archive, filename, opts.Readme, opts.License)
+ if err != nil {
+ return false, err
+ }
+ }
+
+ return true, nil
+}
+
+func buildExecutable(
+ ctx context.Context,
+ builder k6foundry.Builder,
+ platform *Platform,
+ k6Version string,
+ mods []k6foundry.Module,
+ filename string,
+) error {
+ file, err := os.Create(filepath.Clean(filename)) //nolint:forbidigo
+ if err != nil {
+ return err
+ }
+
+ err = builder.Build(
+ ctx,
+ k6foundry.NewPlatform(platform.OS, platform.Arch),
+ k6Version,
+ mods,
+ []string{`-ldflags`, `-s -w`},
+ file,
+ )
+ if err != nil {
+ return err
+ }
+
+ err = file.Close()
+ if err != nil {
+ return err
+ }
+
+ return os.Chmod(filename, 0o700) //nolint:forbidigo,gosec
+}
+
+func buildArchive(archive string, exe, readme, license string) error {
+ files := []string{exe}
+
+ if len(readme) > 0 {
+ files = append(files, readme)
+ }
+
+ if len(license) > 0 {
+ files = append(files, license)
+ }
+
+ if strings.ToLower(filepath.Ext(archive)) == ".zip" {
+ return zipFor(archive, files...)
+ }
+
+ return tgzFor(archive, files...)
+}
+
+func tgzFor(archive string, files ...string) error {
+ tgz, err := os.Create(filepath.Clean(archive)) //nolint:forbidigo
+ if err != nil {
+ return err
+ }
+ defer tgz.Close() //nolint:errcheck
+
+ gzipWriter := gzip.NewWriter(tgz)
+ defer gzipWriter.Close() //nolint:errcheck
+
+ tarWriter := tar.NewWriter(gzipWriter)
+ defer tarWriter.Close() //nolint:errcheck
+
+ for _, file := range files {
+ if err := addToTar(tarWriter, file); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+func zipFor(archive string, files ...string) error {
+ out, err := os.Create(filepath.Clean(archive)) //nolint:forbidigo
+ if err != nil {
+ return err
+ }
+ defer out.Close() //nolint:errcheck
+
+ zipWriter := zip.NewWriter(out)
+ defer zipWriter.Close() //nolint:errcheck
+
+ for _, file := range files {
+ if err := addToZip(zipWriter, file); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+func addToTar(archive *tar.Writer, path string) error {
+ file, err := os.Open(filepath.Clean(path)) //nolint:forbidigo
+ if err != nil {
+ return err
+ }
+
+ defer file.Close() //nolint:errcheck
+
+ stat, err := file.Stat()
+ if err != nil {
+ return err
+ }
+
+ name := filepath.Base(path)
+
+ header := &tar.Header{ //nolint:exhaustruct
+ Name: name,
+ Size: stat.Size(),
+ Mode: int64(stat.Mode()),
+ ModTime: stat.ModTime(),
+ }
+
+ err = archive.WriteHeader(header)
+ if err != nil {
+ return err
+ }
+
+ _, err = io.Copy(archive, file)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func addToZip(archive *zip.Writer, path string) error {
+ file, err := os.Open(filepath.Clean(path)) //nolint:forbidigo
+ if err != nil {
+ return err
+ }
+
+ defer file.Close() //nolint:errcheck
+
+ _, err = file.Stat()
+ if err != nil {
+ return err
+ }
+
+ name := filepath.Base(path)
+
+ writer, err := archive.Create(name)
+ if err != nil {
+ return err
+ }
+
+ _, err = io.Copy(writer, file)
+
+ return err
+}
diff --git a/cmd/action.go b/cmd/action.go
new file mode 100644
index 0000000..ca679ee
--- /dev/null
+++ b/cmd/action.go
@@ -0,0 +1,96 @@
+package cmd
+
+import (
+ "fmt"
+ "log/slog"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+// AddGitHubArgs adds GitHub input parameters as arguments.
+func AddGitHubArgs(args []string) []string {
+ if !isGitHubAction() {
+ return args
+ }
+
+ args = ghinput(args, "distro_name", "--distro-name")
+ args = ghinput(args, "distro_version", "--distro-version")
+ args = ghinput(args, "executable", "--executable")
+ args = ghinput(args, "archive", "--archive")
+ args = ghinput(args, "docker", "--docker")
+ args = ghinput(args, "docker_template", "--docker-template")
+ args = ghinput(args, "notes", "--notes")
+ args = ghinput(args, "notes_template", "--notes-template")
+ args = ghinput(args, "notes_latest", "--notes-latest")
+ args = ghinput(args, "readme", "--readme")
+ args = ghinput(args, "license", "--license")
+ args = ghinput(args, "platform", "--platform")
+
+ if getenv("INPUT_VERBOSE", "false") == "true" {
+ args = append(args, "--verbose")
+ }
+
+ if getenv("INPUT_QUIET", "false") == "true" {
+ args = append(args, "--quiet")
+ }
+
+ if in := getenv("INPUT_IN", ""); len(in) > 0 {
+ args = append(args, in)
+ }
+
+ return args
+}
+
+//nolint:forbidigo
+func isGitHubAction() bool {
+ return os.Getenv("GITHUB_ACTIONS") == "true"
+}
+
+//nolint:forbidigo
+func getenv(name string, defval string) string {
+ value, found := os.LookupEnv(name)
+ if found {
+ return value
+ }
+
+ return defval
+}
+
+func ghinput(args []string, name string, flag string) []string {
+ val := getenv("INPUT_"+strings.ToUpper(name), "")
+ if len(val) > 0 {
+ args = append(args, flag, val)
+ }
+
+ return args
+}
+
+//nolint:forbidigo
+func emitOutput(changed bool, version string) error {
+ ghOutput := getenv("GITHUB_OUTPUT", "")
+ if len(ghOutput) == 0 {
+ return nil
+ }
+
+ file, err := os.Create(filepath.Clean(ghOutput))
+ if err != nil {
+ return err
+ }
+
+ slog.Debug("Emit changed", "changed", changed)
+
+ _, err = fmt.Fprintf(file, "changed=%t\n", changed)
+ if err != nil {
+ return err
+ }
+
+ slog.Debug("Emit version", "version", version)
+
+ _, err = fmt.Fprintf(file, "version=%s\n", version)
+ if err != nil {
+ return err
+ }
+
+ return file.Close()
+}
diff --git a/cmd/cmd.go b/cmd/cmd.go
new file mode 100644
index 0000000..d7db2d5
--- /dev/null
+++ b/cmd/cmd.go
@@ -0,0 +1,218 @@
+// Package cmd contains run cobra command factory function.
+package cmd
+
+import (
+ "context"
+ _ "embed"
+ "log/slog"
+ "os"
+ "path"
+ "path/filepath"
+ "runtime"
+ "strings"
+ "time"
+
+ "github.com/grafana/k6dist"
+ "github.com/spf13/cobra"
+)
+
+//go:embed help.md
+var help string
+
+type options struct {
+ k6dist.Options
+ quiet bool
+ verbose bool
+ single bool
+ platforms []string
+}
+
+var defaultPlatforms = []string{ //nolint:gochecknoglobals
+ "linux/amd64",
+ "darwin/amd64",
+ "windows/amd64",
+}
+
+// New creates new cobra command for exec command.
+func New(levelVar *slog.LevelVar) *cobra.Command {
+ opts := new(options)
+
+ root := &cobra.Command{
+ Use: "k6dist [flags] [registry-location]",
+ Short: "k6 distro builder",
+ Long: help,
+ SilenceUsage: true,
+ SilenceErrors: true,
+ DisableAutoGenTag: true,
+ CompletionOptions: cobra.CompletionOptions{DisableDefaultCmd: true},
+ Args: cobra.MaximumNArgs(1),
+ PreRunE: func(_ *cobra.Command, args []string) error {
+ return preRun(args, levelVar, opts)
+ },
+ RunE: func(cmd *cobra.Command, _ []string) error {
+ changed, err := run(cmd, opts)
+ if err != nil {
+ return err
+ }
+
+ return emitOutput(changed, opts.Version)
+ },
+ }
+
+ root.SetVersionTemplate(`{{with .Name}}{{printf "%s " .}}{{end}}{{printf "%s\n" .Version}}`)
+
+ flags := root.Flags()
+
+ flags.SortFlags = false
+
+ flags.StringVar(&opts.Name, "distro-name", "", "distro name (default detect)")
+ flags.StringVar(&opts.Version, "distro-version", "", "distro version (default current date in YY.MM.DD format)")
+ flags.StringSliceVar(&opts.platforms, "platform", defaultPlatforms, "target platforms")
+ flags.StringVar(&opts.Executable, "executable", k6dist.DefaultExecutableTemplate, "executable file name")
+ flags.StringVar(&opts.Archive, "archive", k6dist.DefaultArchiveTemplate, "archive file name")
+ flags.StringVar(&opts.Dockerfile, "docker", "", "generated Dockerfile name (default Dockerfile next to the exe)")
+ flags.StringVar(&opts.DockerfileTemplate, "docker-template", "",
+ "template for the generated Dockerfile (default embedded)")
+ flags.StringVar(&opts.Notes, "notes", k6dist.DefaultNotesTemplate, "generated release notes file name")
+ flags.StringVar(&opts.NotesTemplate, "notes-template", "",
+ "template for the generated release notes (default embedded)")
+ flags.StringVar(&opts.NotesLatest, "notes-latest", "", "latest release notes file for change detection")
+ flags.StringVar(&opts.Readme, "readme", "", "readme file to be added to the archive (default detect)")
+ flags.StringVar(&opts.License, "license", "", "license file to be added to the archive (default detect)")
+ flags.BoolVar(&opts.single, "single-target", false, "build only for the current runtime platform")
+ flags.BoolVarP(&opts.verbose, "verbose", "v", false, "enable verbose logging")
+ flags.BoolVarP(&opts.quiet, "quiet", "q", false, "disable normal logging")
+
+ flags.BoolP("version", "V", false, "print version")
+
+ return root
+}
+
+func preRun(args []string, levelVar *slog.LevelVar, opts *options) error {
+ if len(args) > 0 {
+ opts.Registry = args[0]
+ } else {
+ opts.Registry = k6dist.DefaultRegistryURL
+ }
+
+ if opts.verbose && levelVar != nil {
+ levelVar.Set(slog.LevelDebug)
+ }
+
+ if opts.quiet && levelVar != nil {
+ levelVar.Set(slog.LevelWarn)
+ }
+
+ if len(opts.Name) == 0 {
+ opts.Name = guessName(opts.Registry)
+ }
+
+ if len(opts.Version) == 0 {
+ opts.Version = defaultDate()
+ }
+
+ if len(opts.Readme) == 0 {
+ opts.Readme = findReadme()
+ }
+
+ if len(opts.License) == 0 {
+ opts.License = findLicense()
+ }
+
+ if opts.single {
+ opts.platforms = []string{runtime.GOOS + "/" + runtime.GOARCH}
+ } else {
+ var err error
+
+ opts.Platforms, err = parsePlatforms(opts.platforms)
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+func run(_ *cobra.Command, opts *options) (bool, error) {
+ if len(opts.Name) == 0 {
+ cwd, err := os.Getwd() //nolint:forbidigo
+ if err != nil {
+ return false, err
+ }
+
+ opts.Name = filepath.Base(cwd)
+ }
+
+ changed, err := k6dist.Build(context.TODO(), &opts.Options)
+ if err != nil {
+ return false, err
+ }
+
+ return changed, nil
+}
+
+func guessName(source string) string {
+ basename := func(filename string) string {
+ base := path.Base(filename)
+
+ if ext := path.Ext(base); len(ext) != 0 {
+ base = strings.TrimSuffix(base, ext)
+ }
+
+ return base
+ }
+
+ base := basename(filepath.ToSlash(source))
+
+ if base != "registry" {
+ return "k6-" + base
+ }
+
+ cwd, err := os.Getwd() //nolint:forbidigo
+ if err != nil {
+ return ""
+ }
+
+ return basename(filepath.ToSlash(cwd))
+}
+
+func findTextFile(basename string) string {
+ for _, ext := range []string{".md", "", ".txt"} {
+ filename := basename + ext
+
+ if _, err := os.Stat(filename); err == nil { //nolint:forbidigo
+ return filename
+ }
+ }
+
+ return ""
+}
+
+func findReadme() string {
+ return findTextFile("README")
+}
+
+func findLicense() string {
+ return findTextFile("LICENSE")
+}
+
+func defaultDate() string {
+ now := time.Now()
+
+ return now.Format("06.01.02")
+}
+
+func parsePlatforms(values []string) ([]*k6dist.Platform, error) {
+ platforms := make([]*k6dist.Platform, 0, len(values))
+
+ for _, value := range values {
+ platform, err := k6dist.ParsePlatform(value)
+ if err != nil {
+ return nil, err
+ }
+
+ platforms = append(platforms, platform)
+ }
+
+ return platforms, nil
+}
diff --git a/cmd/help.md b/cmd/help.md
new file mode 100644
index 0000000..240ddd8
--- /dev/null
+++ b/cmd/help.md
@@ -0,0 +1,15 @@
+Build k6 distribution with extensions.
+
+k6dist enables building k6 distributions with extensions. The extensions to be embedded can be specified with an extension registry. The location of the registry can be specified with http(s) URL or filesystem path.
+
+The location of the registry can be specified as a command line argument. If omitted, the URL of the registry subset containing the official k6 extensions is the default.
+
+Each flag has a meaningful default value.
+
+k6dist builds k6 for the specified platforms with the extensions listed in the registry. After that, it also creates archive files corresponding to the platform (`.zip` for Windows, otherwise `.tar.gz` format).
+
+In addition to the executable, the readme and the license file can be included in the archive. Their names are detected, but can also be specified using the `--readme` and `--license` flags.
+
+The locations of executables and archives can be specified with the go template expression using the `--executable` and `--archive` flags.
+
+A release notes file is also prepared, in which the extensions are listed with their current and previous versions and their description. The release notes file can be customized, using the `--notes-template` flag you can specify a go template file to generate the release notes.
diff --git a/cmd/k6dist/main.go b/cmd/k6dist/main.go
new file mode 100644
index 0000000..e625026
--- /dev/null
+++ b/cmd/k6dist/main.go
@@ -0,0 +1,54 @@
+// Package main contains the main function for k6dist.
+package main
+
+import (
+ "log/slog"
+ "os"
+
+ "github.com/grafana/k6dist/cmd"
+ sloglogrus "github.com/samber/slog-logrus/v2"
+ "github.com/sirupsen/logrus"
+ "github.com/spf13/cobra"
+)
+
+//nolint:gochecknoglobals
+var (
+ appname = "k6dist" //nolint:unused
+ version = "dev"
+)
+
+func initLogging() *slog.LevelVar {
+ levelVar := new(slog.LevelVar)
+
+ logrus.SetLevel(logrus.DebugLevel)
+
+ logger := slog.New(sloglogrus.Option{Level: levelVar}.NewLogrusHandler())
+
+ slog.SetDefault(logger)
+
+ return levelVar
+}
+
+func main() {
+ runCmd(newCmd(getArgs(), initLogging()))
+}
+
+func newCmd(args []string, levelVar *slog.LevelVar) *cobra.Command {
+ cmd := cmd.New(levelVar)
+
+ cmd.Version = version
+ cmd.SetArgs(args)
+
+ return cmd
+}
+
+func runCmd(cmd *cobra.Command) {
+ if err := cmd.Execute(); err != nil {
+ slog.Error(err.Error())
+ os.Exit(1) //nolint:forbidigo
+ }
+}
+
+func getArgs() []string {
+ return cmd.AddGitHubArgs(os.Args[1:]) //nolint:forbidigo
+}
diff --git a/coverage.txt b/coverage.txt
new file mode 100644
index 0000000..479e045
--- /dev/null
+++ b/coverage.txt
@@ -0,0 +1,272 @@
+mode: atomic
+github.com/grafana/k6dist/build.go:18.76,19.22 1 0
+github.com/grafana/k6dist/build.go:19.22,21.3 1 0
+github.com/grafana/k6dist/build.go:23.2,24.16 2 0
+github.com/grafana/k6dist/build.go:24.16,26.3 1 0
+github.com/grafana/k6dist/build.go:28.2,29.16 2 0
+github.com/grafana/k6dist/build.go:29.16,31.3 1 0
+github.com/grafana/k6dist/build.go:33.2,33.12 1 0
+github.com/grafana/k6dist/build.go:33.12,35.3 1 0
+github.com/grafana/k6dist/build.go:37.2,37.41 1 0
+github.com/grafana/k6dist/build.go:40.91,42.19 2 0
+github.com/grafana/k6dist/build.go:42.19,44.3 1 0
+github.com/grafana/k6dist/build.go:46.2,57.3 1 0
+github.com/grafana/k6dist/build.go:61.62,65.16 3 0
+github.com/grafana/k6dist/build.go:65.16,67.3 1 0
+github.com/grafana/k6dist/build.go:69.2,70.16 2 0
+github.com/grafana/k6dist/build.go:70.16,72.3 1 0
+github.com/grafana/k6dist/build.go:74.2,74.14 1 0
+github.com/grafana/k6dist/build.go:74.14,76.3 1 0
+github.com/grafana/k6dist/build.go:78.2,79.16 2 0
+github.com/grafana/k6dist/build.go:79.16,81.3 1 0
+github.com/grafana/k6dist/build.go:83.2,84.16 2 0
+github.com/grafana/k6dist/build.go:84.16,86.3 1 0
+github.com/grafana/k6dist/build.go:88.2,88.69 1 0
+github.com/grafana/k6dist/build.go:88.69,90.3 1 0
+github.com/grafana/k6dist/build.go:92.2,96.16 4 0
+github.com/grafana/k6dist/build.go:96.16,98.3 1 0
+github.com/grafana/k6dist/build.go:100.2,100.42 1 0
+github.com/grafana/k6dist/build.go:100.42,104.17 3 0
+github.com/grafana/k6dist/build.go:104.17,106.4 1 0
+github.com/grafana/k6dist/build.go:108.3,109.17 2 0
+github.com/grafana/k6dist/build.go:109.17,111.4 1 0
+github.com/grafana/k6dist/build.go:113.3,114.17 2 0
+github.com/grafana/k6dist/build.go:114.17,116.4 1 0
+github.com/grafana/k6dist/build.go:118.3,119.17 2 0
+github.com/grafana/k6dist/build.go:119.17,121.4 1 0
+github.com/grafana/k6dist/build.go:123.3,124.17 2 0
+github.com/grafana/k6dist/build.go:124.17,126.4 1 0
+github.com/grafana/k6dist/build.go:129.2,129.18 1 0
+github.com/grafana/k6dist/build.go:139.9,141.16 2 0
+github.com/grafana/k6dist/build.go:141.16,143.3 1 0
+github.com/grafana/k6dist/build.go:145.2,153.16 2 0
+github.com/grafana/k6dist/build.go:153.16,155.3 1 0
+github.com/grafana/k6dist/build.go:157.2,158.16 2 0
+github.com/grafana/k6dist/build.go:158.16,160.3 1 0
+github.com/grafana/k6dist/build.go:162.2,162.34 1 0
+github.com/grafana/k6dist/build.go:165.70,168.21 2 0
+github.com/grafana/k6dist/build.go:168.21,170.3 1 0
+github.com/grafana/k6dist/build.go:172.2,172.22 1 0
+github.com/grafana/k6dist/build.go:172.22,174.3 1 0
+github.com/grafana/k6dist/build.go:176.2,176.54 1 0
+github.com/grafana/k6dist/build.go:176.54,178.3 1 0
+github.com/grafana/k6dist/build.go:180.2,180.34 1 0
+github.com/grafana/k6dist/build.go:183.52,185.16 2 0
+github.com/grafana/k6dist/build.go:185.16,187.3 1 0
+github.com/grafana/k6dist/build.go:188.2,196.29 6 0
+github.com/grafana/k6dist/build.go:196.29,197.51 1 0
+github.com/grafana/k6dist/build.go:197.51,199.4 1 0
+github.com/grafana/k6dist/build.go:202.2,202.12 1 0
+github.com/grafana/k6dist/build.go:205.52,207.16 2 0
+github.com/grafana/k6dist/build.go:207.16,209.3 1 0
+github.com/grafana/k6dist/build.go:210.2,215.29 4 0
+github.com/grafana/k6dist/build.go:215.29,216.51 1 0
+github.com/grafana/k6dist/build.go:216.51,218.4 1 0
+github.com/grafana/k6dist/build.go:221.2,221.12 1 0
+github.com/grafana/k6dist/build.go:224.55,226.16 2 0
+github.com/grafana/k6dist/build.go:226.16,228.3 1 0
+github.com/grafana/k6dist/build.go:230.2,233.16 3 0
+github.com/grafana/k6dist/build.go:233.16,235.3 1 0
+github.com/grafana/k6dist/build.go:237.2,247.16 4 0
+github.com/grafana/k6dist/build.go:247.16,249.3 1 0
+github.com/grafana/k6dist/build.go:251.2,252.16 2 0
+github.com/grafana/k6dist/build.go:252.16,254.3 1 0
+github.com/grafana/k6dist/build.go:256.2,256.12 1 0
+github.com/grafana/k6dist/build.go:259.55,261.16 2 0
+github.com/grafana/k6dist/build.go:261.16,263.3 1 0
+github.com/grafana/k6dist/build.go:265.2,268.16 3 0
+github.com/grafana/k6dist/build.go:268.16,270.3 1 0
+github.com/grafana/k6dist/build.go:272.2,275.16 3 0
+github.com/grafana/k6dist/build.go:275.16,277.3 1 0
+github.com/grafana/k6dist/build.go:279.2,281.12 2 0
+github.com/grafana/k6dist/docker.go:12.80,15.24 2 0
+github.com/grafana/k6dist/docker.go:15.24,17.17 2 0
+github.com/grafana/k6dist/docker.go:17.17,19.4 1 0
+github.com/grafana/k6dist/docker.go:21.3,21.24 1 0
+github.com/grafana/k6dist/docker.go:22.8,24.3 1 0
+github.com/grafana/k6dist/docker.go:26.2,29.16 3 0
+github.com/grafana/k6dist/docker.go:29.16,31.3 1 0
+github.com/grafana/k6dist/docker.go:33.2,34.20 2 0
+github.com/grafana/k6dist/docker.go:34.20,36.3 1 0
+github.com/grafana/k6dist/docker.go:38.2,38.47 1 0
+github.com/grafana/k6dist/options.go:74.33,75.28 1 0
+github.com/grafana/k6dist/options.go:75.28,77.3 1 0
+github.com/grafana/k6dist/options.go:79.2,79.23 1 0
+github.com/grafana/k6dist/options.go:79.23,81.3 1 0
+github.com/grafana/k6dist/options.go:83.2,83.25 1 0
+github.com/grafana/k6dist/options.go:83.25,85.3 1 0
+github.com/grafana/k6dist/options.go:87.2,87.26 1 0
+github.com/grafana/k6dist/options.go:87.26,89.3 1 0
+github.com/grafana/k6dist/options.go:91.2,91.24 1 0
+github.com/grafana/k6dist/options.go:91.24,93.3 1 0
+github.com/grafana/k6dist/platform.go:19.35,21.2 1 0
+github.com/grafana/k6dist/platform.go:24.53,26.37 2 0
+github.com/grafana/k6dist/platform.go:26.37,28.3 1 0
+github.com/grafana/k6dist/platform.go:30.2,30.61 1 0
+github.com/grafana/k6dist/release.go:22.62,32.61 6 0
+github.com/grafana/k6dist/release.go:32.61,34.3 1 0
+github.com/grafana/k6dist/release.go:36.2,39.27 3 0
+github.com/grafana/k6dist/release.go:42.96,45.24 2 0
+github.com/grafana/k6dist/release.go:45.24,47.17 2 0
+github.com/grafana/k6dist/release.go:47.17,49.4 1 0
+github.com/grafana/k6dist/release.go:51.3,51.24 1 0
+github.com/grafana/k6dist/release.go:52.8,54.3 1 0
+github.com/grafana/k6dist/release.go:56.2,57.16 2 0
+github.com/grafana/k6dist/release.go:57.16,59.3 1 0
+github.com/grafana/k6dist/release.go:61.2,61.47 1 0
+github.com/grafana/k6dist/release.go:66.63,69.18 2 0
+github.com/grafana/k6dist/release.go:69.18,71.3 1 0
+github.com/grafana/k6dist/release.go:73.2,75.90 2 0
+github.com/grafana/k6dist/release.go:75.90,77.3 1 0
+github.com/grafana/k6dist/release.go:79.2,79.27 1 0
+github.com/grafana/k6dist/template.go:30.79,34.30 3 0
+github.com/grafana/k6dist/template.go:34.30,37.3 2 0
+github.com/grafana/k6dist/template.go:39.2,46.3 1 0
+github.com/grafana/k6dist/template.go:49.88,51.16 2 0
+github.com/grafana/k6dist/template.go:51.16,53.3 1 0
+github.com/grafana/k6dist/template.go:55.2,55.87 1 0
+github.com/grafana/k6dist/template.go:58.84,60.16 2 0
+github.com/grafana/k6dist/template.go:60.16,62.3 1 0
+github.com/grafana/k6dist/template.go:64.2,66.50 2 0
+github.com/grafana/k6dist/template.go:66.50,68.3 1 0
+github.com/grafana/k6dist/template.go:70.2,70.27 1 0
+github.com/grafana/k6dist/template.go:73.88,75.16 2 0
+github.com/grafana/k6dist/template.go:75.16,77.3 1 0
+github.com/grafana/k6dist/template.go:79.2,79.67 1 0
+github.com/grafana/k6dist/template.go:79.67,81.3 1 0
+github.com/grafana/k6dist/template.go:83.2,83.22 1 0
+github.com/grafana/k6dist/cmd/action.go:12.44,13.23 1 0
+github.com/grafana/k6dist/cmd/action.go:13.23,15.3 1 0
+github.com/grafana/k6dist/cmd/action.go:17.2,30.48 13 0
+github.com/grafana/k6dist/cmd/action.go:30.48,32.3 1 0
+github.com/grafana/k6dist/cmd/action.go:34.2,34.46 1 0
+github.com/grafana/k6dist/cmd/action.go:34.46,36.3 1 0
+github.com/grafana/k6dist/cmd/action.go:38.2,38.47 1 0
+github.com/grafana/k6dist/cmd/action.go:38.47,40.3 1 0
+github.com/grafana/k6dist/cmd/action.go:42.2,42.13 1 0
+github.com/grafana/k6dist/cmd/action.go:46.28,48.2 1 0
+github.com/grafana/k6dist/cmd/action.go:51.48,53.11 2 0
+github.com/grafana/k6dist/cmd/action.go:53.11,55.3 1 0
+github.com/grafana/k6dist/cmd/action.go:57.2,57.15 1 0
+github.com/grafana/k6dist/cmd/action.go:60.64,62.18 2 0
+github.com/grafana/k6dist/cmd/action.go:62.18,64.3 1 0
+github.com/grafana/k6dist/cmd/action.go:66.2,66.13 1 0
+github.com/grafana/k6dist/cmd/action.go:70.53,72.24 2 0
+github.com/grafana/k6dist/cmd/action.go:72.24,74.3 1 0
+github.com/grafana/k6dist/cmd/action.go:76.2,77.16 2 0
+github.com/grafana/k6dist/cmd/action.go:77.16,79.3 1 0
+github.com/grafana/k6dist/cmd/action.go:81.2,84.16 3 0
+github.com/grafana/k6dist/cmd/action.go:84.16,86.3 1 0
+github.com/grafana/k6dist/cmd/action.go:88.2,91.16 3 0
+github.com/grafana/k6dist/cmd/action.go:91.16,93.3 1 0
+github.com/grafana/k6dist/cmd/action.go:95.2,95.21 1 0
+github.com/grafana/k6dist/cmd/cmd.go:37.50,49.56 2 0
+github.com/grafana/k6dist/cmd/cmd.go:49.56,51.4 1 0
+github.com/grafana/k6dist/cmd/cmd.go:52.52,54.18 2 0
+github.com/grafana/k6dist/cmd/cmd.go:54.18,56.5 1 0
+github.com/grafana/k6dist/cmd/cmd.go:58.4,58.44 1 0
+github.com/grafana/k6dist/cmd/cmd.go:62.2,88.13 20 0
+github.com/grafana/k6dist/cmd/cmd.go:91.74,92.19 1 0
+github.com/grafana/k6dist/cmd/cmd.go:92.19,94.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:94.8,96.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:98.2,98.37 1 0
+github.com/grafana/k6dist/cmd/cmd.go:98.37,100.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:102.2,102.35 1 0
+github.com/grafana/k6dist/cmd/cmd.go:102.35,104.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:106.2,106.25 1 0
+github.com/grafana/k6dist/cmd/cmd.go:106.25,108.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:110.2,110.28 1 0
+github.com/grafana/k6dist/cmd/cmd.go:110.28,112.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:114.2,114.27 1 0
+github.com/grafana/k6dist/cmd/cmd.go:114.27,116.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:118.2,118.28 1 0
+github.com/grafana/k6dist/cmd/cmd.go:118.28,120.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:122.2,122.17 1 0
+github.com/grafana/k6dist/cmd/cmd.go:122.17,124.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:124.8,128.17 3 0
+github.com/grafana/k6dist/cmd/cmd.go:128.17,130.4 1 0
+github.com/grafana/k6dist/cmd/cmd.go:133.2,133.12 1 0
+github.com/grafana/k6dist/cmd/cmd.go:136.57,137.25 1 0
+github.com/grafana/k6dist/cmd/cmd.go:137.25,139.17 2 0
+github.com/grafana/k6dist/cmd/cmd.go:139.17,141.4 1 0
+github.com/grafana/k6dist/cmd/cmd.go:143.3,143.33 1 0
+github.com/grafana/k6dist/cmd/cmd.go:146.2,147.16 2 0
+github.com/grafana/k6dist/cmd/cmd.go:147.16,149.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:151.2,151.21 1 0
+github.com/grafana/k6dist/cmd/cmd.go:154.38,155.43 1 0
+github.com/grafana/k6dist/cmd/cmd.go:155.43,158.43 2 0
+github.com/grafana/k6dist/cmd/cmd.go:158.43,160.4 1 0
+github.com/grafana/k6dist/cmd/cmd.go:162.3,162.14 1 0
+github.com/grafana/k6dist/cmd/cmd.go:165.2,167.24 2 0
+github.com/grafana/k6dist/cmd/cmd.go:167.24,169.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:171.2,172.16 2 0
+github.com/grafana/k6dist/cmd/cmd.go:172.16,174.3 1 0
+github.com/grafana/k6dist/cmd/cmd.go:176.2,176.40 1 0
+github.com/grafana/k6dist/cmd/cmd.go:179.43,180.50 1 0
+github.com/grafana/k6dist/cmd/cmd.go:180.50,183.46 2 0
+github.com/grafana/k6dist/cmd/cmd.go:183.46,185.4 1 0
+github.com/grafana/k6dist/cmd/cmd.go:188.2,188.11 1 0
+github.com/grafana/k6dist/cmd/cmd.go:191.26,193.2 1 0
+github.com/grafana/k6dist/cmd/cmd.go:195.27,197.2 1 0
+github.com/grafana/k6dist/cmd/cmd.go:199.27,203.2 2 0
+github.com/grafana/k6dist/cmd/cmd.go:205.66,208.31 2 0
+github.com/grafana/k6dist/cmd/cmd.go:208.31,210.17 2 0
+github.com/grafana/k6dist/cmd/cmd.go:210.17,212.4 1 0
+github.com/grafana/k6dist/cmd/cmd.go:214.3,214.42 1 0
+github.com/grafana/k6dist/cmd/cmd.go:217.2,217.23 1 0
+github.com/grafana/k6dist/cmd/k6dist/main.go:20.35,30.2 5 0
+github.com/grafana/k6dist/cmd/k6dist/main.go:32.13,34.2 1 0
+github.com/grafana/k6dist/cmd/k6dist/main.go:36.68,43.2 4 0
+github.com/grafana/k6dist/cmd/k6dist/main.go:45.33,46.38 1 0
+github.com/grafana/k6dist/cmd/k6dist/main.go:46.38,49.3 2 0
+github.com/grafana/k6dist/cmd/k6dist/main.go:52.25,54.2 1 0
+github.com/grafana/k6dist/internal/registry/module.go:18.62,23.27 3 0
+github.com/grafana/k6dist/internal/registry/module.go:23.27,24.31 1 0
+github.com/grafana/k6dist/internal/registry/module.go:24.31,26.4 1 0
+github.com/grafana/k6dist/internal/registry/module.go:26.9,28.4 1 0
+github.com/grafana/k6dist/internal/registry/module.go:31.2,31.25 1 0
+github.com/grafana/k6dist/internal/registry/module.go:35.32,36.27 1 0
+github.com/grafana/k6dist/internal/registry/module.go:36.27,37.14 1 0
+github.com/grafana/k6dist/internal/registry/module.go:37.14,39.4 1 0
+github.com/grafana/k6dist/internal/registry/module.go:42.2,42.14 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:16.41,19.26 2 0
+github.com/grafana/k6dist/internal/registry/registry.go:19.26,20.29 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:20.29,21.12 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:24.3,24.88 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:27.2,27.13 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:31.81,32.79 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:32.79,34.3 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:34.8,36.3 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:38.2,38.16 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:38.16,40.3 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:42.2,42.38 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:42.38,43.36 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:43.36,45.4 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:47.3,47.36 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:47.36,49.4 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:51.3,51.39 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:54.2,54.23 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:54.23,56.3 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:58.2,58.17 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:61.54,63.16 2 0
+github.com/grafana/k6dist/internal/registry/registry.go:63.16,65.3 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:67.2,73.45 4 0
+github.com/grafana/k6dist/internal/registry/registry.go:73.45,75.3 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:77.2,77.17 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:80.77,82.16 2 0
+github.com/grafana/k6dist/internal/registry/registry.go:82.16,84.3 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:86.2,89.16 3 0
+github.com/grafana/k6dist/internal/registry/registry.go:89.16,91.3 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:93.2,93.38 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:93.38,95.3 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:97.2,103.45 4 0
+github.com/grafana/k6dist/internal/registry/registry.go:103.45,105.3 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:107.2,107.17 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:111.53,114.23 2 0
+github.com/grafana/k6dist/internal/registry/registry.go:114.23,116.3 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:118.2,120.30 2 0
+github.com/grafana/k6dist/internal/registry/registry.go:120.30,122.12 2 0
+github.com/grafana/k6dist/internal/registry/registry.go:122.12,125.4 2 0
+github.com/grafana/k6dist/internal/registry/registry.go:127.3,127.30 1 0
+github.com/grafana/k6dist/internal/registry/registry.go:130.2,130.16 1 0
+github.com/grafana/k6dist/tools/gendoc/main.go:9.13,12.2 2 0
diff --git a/docker.go b/docker.go
new file mode 100644
index 0000000..6b1a5f5
--- /dev/null
+++ b/docker.go
@@ -0,0 +1,39 @@
+package k6dist
+
+import (
+ _ "embed"
+ "os"
+ "path/filepath"
+)
+
+//go:embed Dockerfile.tpl
+var defaultDockerTemplate string
+
+func createDockerfile(executable string, tmplfile string, output string) error {
+ var tmplsrc string
+
+ if len(tmplfile) != 0 {
+ bin, err := os.ReadFile(filepath.Clean(tmplfile)) //nolint:forbidigo
+ if err != nil {
+ return err
+ }
+
+ tmplsrc = string(bin)
+ } else {
+ tmplsrc = defaultDockerTemplate
+ }
+
+ dir := filepath.Dir(executable)
+
+ str, err := expandTemplate("Dockerfile", tmplsrc, map[string]string{"Executable": filepath.Base(executable)})
+ if err != nil {
+ return err
+ }
+
+ name := output
+ if len(name) == 0 {
+ name = filepath.Join(dir, "Dockerfile")
+ }
+
+ return os.WriteFile(name, []byte(str), 0o600) //nolint:forbidigo
+}
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..c2c6eb2
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,22 @@
+module github.com/grafana/k6dist
+
+go 1.22.4
+
+require (
+ github.com/go-task/slim-sprig/v3 v3.0.0
+ github.com/grafana/clireadme v0.1.0
+ github.com/grafana/k6foundry v0.2.0
+ github.com/samber/slog-logrus/v2 v2.5.0
+ github.com/sirupsen/logrus v1.9.3
+ github.com/spf13/cobra v1.8.0
+)
+
+require (
+ github.com/inconshreveable/mousetrap v1.1.0 // indirect
+ github.com/samber/lo v1.44.0 // indirect
+ github.com/samber/slog-common v0.17.0 // indirect
+ github.com/spf13/pflag v1.0.5 // indirect
+ golang.org/x/mod v0.17.0 // indirect
+ golang.org/x/sys v0.1.0 // indirect
+ golang.org/x/text v0.16.0 // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..d77f9b1
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,42 @@
+github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
+github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
+github.com/grafana/clireadme v0.1.0 h1:KYEYSnYdSzmHf3bufaK6fQZ5j4dzvM/T+G6Ba+qNnAM=
+github.com/grafana/clireadme v0.1.0/go.mod h1:Wy4KIG2ZBGMYAYyF9l7qAy+yoJVasqk/txsRgoRI3gc=
+github.com/grafana/k6foundry v0.2.0 h1:+aE5wuCP0XNGNsxM7UiPj9hyw4RdWeW929PuGwLWIlg=
+github.com/grafana/k6foundry v0.2.0/go.mod h1:b6n4InFgXl+3yPobmlyJfcJmLozU9CI9IIUuq8YqEiM=
+github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
+github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/samber/lo v1.44.0 h1:5il56KxRE+GHsm1IR+sZ/6J42NODigFiqCWpSc2dybA=
+github.com/samber/lo v1.44.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
+github.com/samber/slog-common v0.17.0 h1:HdRnk7QQTa9ByHlLPK3llCBo8ZSX3F/ZyeqVI5dfMtI=
+github.com/samber/slog-common v0.17.0/go.mod h1:mZSJhinB4aqHziR0SKPqpVZjJ0JO35JfH+dDIWqaCBk=
+github.com/samber/slog-logrus/v2 v2.5.0 h1:0R1QlxBApEX6GOdCulqvDbeOK09LCSUDSEjVvm5ZeD4=
+github.com/samber/slog-logrus/v2 v2.5.0/go.mod h1:xN6h40pDGXSJDgZsttF9KtaIV7dtpjeoBDpw8TpvRr8=
+github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
+github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
+github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
+github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
+github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
+github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
+github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
+golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
+golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
+golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
+golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/internal/registry/module.go b/internal/registry/module.go
new file mode 100644
index 0000000..50be668
--- /dev/null
+++ b/internal/registry/module.go
@@ -0,0 +1,45 @@
+package registry
+
+import (
+ "github.com/grafana/k6foundry"
+)
+
+// Module representa a buildable k6 module.
+type Module struct {
+ Path string `json:"path,omitempty"`
+ Version string `json:"version,omitempty"`
+ Cgo bool `json:"cgo,omitempty"`
+}
+
+// Modules represents list of buildable modules.
+type Modules []Module
+
+// ToFoundry converts module list to k6foundry builder parameters.
+func (mods Modules) ToFoundry() (string, []k6foundry.Module) {
+ var k6Version string
+
+ fmods := make([]k6foundry.Module, 0, len(mods)-1)
+
+ for _, mod := range mods {
+ if mod.Path == k6ModulePath {
+ k6Version = mod.Version
+ } else {
+ fmods = append(fmods, k6foundry.Module{Path: mod.Path, Version: mod.Version})
+ }
+ }
+
+ return k6Version, fmods
+}
+
+// Cgo returns true if at least one module requires cgo.
+func (mods Modules) Cgo() bool {
+ for _, mod := range mods {
+ if mod.Cgo {
+ return true
+ }
+ }
+
+ return false
+}
+
+const k6ModulePath = "go.k6.io/k6"
diff --git a/internal/registry/registry.go b/internal/registry/registry.go
new file mode 100644
index 0000000..2102c69
--- /dev/null
+++ b/internal/registry/registry.go
@@ -0,0 +1,131 @@
+// Package registry contains extension registry related internal helpers.
+package registry
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "os"
+ "path/filepath"
+ "sort"
+ "strings"
+)
+
+// ToModules creates a module list from the registry.
+func (reg Registry) ToModules() Modules {
+ mods := make(Modules, 0, len(reg))
+
+ for _, ext := range reg {
+ if len(ext.Versions) == 0 {
+ continue
+ }
+
+ mods = append(mods, Module{Path: ext.Module, Version: ext.Versions[0], Cgo: ext.Cgo})
+ }
+
+ return mods
+}
+
+// LoadRegistry loads registry from URL of filesystem path.
+func LoadRegistry(ctx context.Context, source string) (reg Registry, err error) {
+ if strings.HasPrefix(source, "http:") || strings.HasPrefix(source, "https:") {
+ reg, err = loadRegistryHTTP(ctx, source)
+ } else {
+ reg, err = loadRegistryFS(source)
+ }
+
+ if err != nil {
+ return nil, err
+ }
+
+ sort.Slice(reg, func(i, j int) bool {
+ if reg[i].Module == k6ModulePath {
+ return true
+ }
+
+ if reg[j].Module == k6ModulePath {
+ return false
+ }
+
+ return reg[i].Module < reg[j].Module
+ })
+
+ for idx := range reg {
+ reg[idx].Versions = []string{reg[idx].Versions[0], ""}
+ }
+
+ return reg, nil
+}
+
+func loadRegistryFS(source string) (Registry, error) {
+ file, err := os.Open(filepath.Clean(source)) //nolint:forbidigo
+ if err != nil {
+ return nil, err
+ }
+
+ defer file.Close() //nolint:errcheck
+
+ decoder := json.NewDecoder(file)
+
+ var reg Registry
+
+ if err := decoder.Decode(®); err != nil {
+ return nil, err
+ }
+
+ return reg, nil
+}
+
+func loadRegistryHTTP(ctx context.Context, source string) (Registry, error) {
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, source, nil)
+ if err != nil {
+ return nil, err
+ }
+
+ client := &http.Client{}
+
+ resp, err := client.Do(req)
+ if err != nil {
+ return nil, err
+ }
+
+ if resp.StatusCode != http.StatusOK {
+ return nil, fmt.Errorf("%w: %s", os.ErrNotExist, resp.Status) //nolint:forbidigo
+ }
+
+ defer resp.Body.Close() //nolint:errcheck
+
+ decoder := json.NewDecoder(resp.Body)
+
+ var reg Registry
+
+ if err := decoder.Decode(®); err != nil {
+ return nil, err
+ }
+
+ return reg, nil
+}
+
+// AddLatest adds latest versions to extensions.
+func (reg Registry) AddLatest(modules Modules) bool {
+ dict := make(map[string]*Extension, len(reg))
+
+ for idx := range reg {
+ dict[reg[idx].Module] = ®[idx]
+ }
+
+ changed := false
+
+ for _, mod := range modules {
+ ext, found := dict[mod.Path]
+ if found {
+ ext.Versions[1] = mod.Version
+ changed = changed || (ext.Versions[0] != mod.Version)
+ }
+
+ changed = changed || !found
+ }
+
+ return changed
+}
diff --git a/internal/registry/registry.schema.json b/internal/registry/registry.schema.json
new file mode 100644
index 0000000..95e601b
--- /dev/null
+++ b/internal/registry/registry.schema.json
@@ -0,0 +1,385 @@
+{
+ "$id": "https://registry.k6.io/registry.schema.json",
+ "$schema": "http://json-schema.org/draft-07/schema",
+ "$ref": "#/$defs/registry",
+ "$defs": {
+ "registry": {
+ "description": "k6 Extension Registry.\n\nThe k6 extension registry contains the most important properties of registered extensions.\n",
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/extension"
+ }
+ },
+ "catalog": {
+ "description": "k6 Extension Catalog.\n\nThe k6 extension catalog is an alternative representation of the k6 extension registry.\nThe catalog stores the extension data in an associative array (object),\nwhere the key is the import path for JavaScript extensions, and the output name for output extensions.\nThis data structure is optimized to resolve extensions as dependencies.\n",
+ "type": "object",
+ "additionalProperties": {
+ "$ref": "#/$defs/extension"
+ }
+ },
+ "extension": {
+ "type": "object",
+ "description": "Properties of the registered k6 extension.\n\nOnly those properties of the extensions are registered, which either cannot be detected automatically, or delegation to the extension is not allowed.\n\nProperties that are available using the repository manager API are intentionally not registered.\n\nThe string like properties that are included in the generated Grafana documentation are intentionally not accessed via the API of the repository manager. It is not allowed to inject arbitrary text into the Grafana documentation site without approval. Therefore, these properties are registered (eg `description`)\n",
+ "properties": {
+ "module": {
+ "type": "string",
+ "description": "The extension's go module path.\n\nThis is the unique identifier of the extension.\nMore info about module paths: https://go.dev/ref/mod#module-path\n\nThe extension has no name property, the module path or part of it can be used as the extension name. For example, using the first two elements of the module path after the host name, the name `grafana/xk6-dashboard` can be formed from the module path `github.com/grafana/xk6-dashboard`. This is typically the repository owner name and the repository name in the repository manager.\n\nThe extension has no URL property, a URL can be created from the module path that refers to the extension within the repository manager.\n",
+ "examples": [
+ "github.com/grafana/xk6-dashboard",
+ "github.com/szkiba/xk6-top"
+ ]
+ },
+ "imports": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "pattern": "^k6/x/"
+ },
+ "description": "List of JavaScript import paths registered by the extension.\n\nCurrently, paths must start with the prefix `k6/x/`.\n\nThe extensions used by k6 scripts are automatically detected based on the values specified here, therefore it is important that the values used here are consistent with the values registered by the extension at runtime.\n",
+ "examples": [
+ [
+ "k6/x/csv",
+ "k6/x/csv/stream"
+ ],
+ [
+ "k6/x/toml"
+ ]
+ ]
+ },
+ "outputs": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "List of output names registered by the extension.\n\nThe extensions used by k6 scripts are automatically detected based on the values specified here, therefore it is important that the values used here are consistent with the values registered by the extension at runtime.\n",
+ "examples": [
+ [
+ "dashboard"
+ ],
+ [
+ "plugin"
+ ]
+ ]
+ },
+ "description": {
+ "type": "string",
+ "default": "",
+ "description": "Brief description of the extension.\n",
+ "examples": [
+ "This is a very cool extension, it displays the message 'Hello World!'"
+ ]
+ },
+ "versions": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "List of supported versions.\n\nVersions are tags whose format meets the requirements of semantic versioning. Version tags often start with the letter `v`, which is not part of the semantic version.\n",
+ "examples": [
+ [
+ "v0.1.0",
+ "v0.2.0",
+ "v0.2.1"
+ ]
+ ]
+ },
+ "cgo": {
+ "type": "boolean",
+ "default": false,
+ "description": "Flag indicating the need for cgo.\n\nThe `cgo` property value `true` indicates that cgo must be enabled to build the extension.\n"
+ },
+ "constraints": {
+ "type": "string",
+ "pattern": "[vxX*|,&\\^0-9.+-><=, ~]+",
+ "default": "",
+ "description": "Version constraints.\n\nVersion constraints are primarily used to filter automatically detected versions.\nIt can also be used to filter the versions property imported from the origin registry.\n",
+ "examples": [
+ [
+ ">=v0.4.0",
+ ">v0.50.0"
+ ]
+ ]
+ },
+ "repo": {
+ "$ref": "#/$defs/repository",
+ "description": "Repository metadata.\n\nMetadata provided by the extension's git repository manager. Repository metadata are not registered, they are queried at runtime using the repository manager API.\n"
+ },
+ "tier": {
+ "$ref": "#/$defs/tier",
+ "default": "community",
+ "description": "Maintainer of the extension.\n\nPossible values:\n\n - official: Extensions owned, maintained, and designated by Grafana as \"official\"\n - partner: Extensions written, maintained, validated, and published by third-party companies against their own projects.\n - community: Extensions are listed on the Registry by individual maintainers, groups of maintainers, or other members of the k6 community.\n\nExtensions owned by the `grafana` GitHub organization are not officially supported by Grafana by default.\nThere are several k6 extensions owned by the `grafana` GitHub organization, which were created for experimental or example purposes only.\nThe `official` tier value is needed so that officially supported extensions can be distinguished from them.\n\nIf it is missing from the registry source, it will be set with the default \"community\" value during generation.\n",
+ "examples": [
+ "community",
+ "official"
+ ]
+ },
+ "products": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/product"
+ },
+ "description": "Products in which the extension can be used.\n\nSome extensions are not available in all k6 products.\nThis may be for a technological or business reason, or the functionality of the extension may not make sense in the given product.\n\nPossible values:\n\n - oss: Extensions are available in k6 OSS\n - cloud: Extensions are available in Grafana Cloud k6\n - synthetic: Extensions are available in Grafana Synthetic Monitoring\n\nIf the property is missing or empty in the source of the registry, it means that the extension is only available in the k6 OSS product.\nIn this case, the registry will be filled in accordingly during generation.\n",
+ "examples": [
+ [
+ "cloud",
+ "synthetic",
+ "oss"
+ ],
+ [
+ "cloud"
+ ],
+ [
+ "oss"
+ ]
+ ]
+ },
+ "categories": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/category"
+ },
+ "description": "The categories to which the extension belongs.\n\nIf the property is missing or empty in the registry source, the default value is `[\"misc\"]`.\n",
+ "examples": [
+ [
+ "data",
+ "reporting"
+ ],
+ [
+ "observability",
+ "protocol"
+ ]
+ ]
+ },
+ "compliance": {
+ "$ref": "#/$defs/compliance",
+ "description": "The result of the extension's k6 compliance checks.\n"
+ }
+ },
+ "required": [
+ "module"
+ ],
+ "additionalProperties": false
+ },
+ "compliance": {
+ "description": "The result of the extension's k6 compliance checks.\n",
+ "type": "object",
+ "required": [
+ "grade",
+ "level"
+ ],
+ "properties": {
+ "level": {
+ "description": "Compliance expressed as a percentage.\n\nThe `level` property contains a percentage of how well the extension complies with best practices.\nThe value of the `level` can be between `0-100` and is determined by the weighted and normalized sum of the scores of the compliance checks.\n",
+ "examples": [
+ 87,
+ 34,
+ 100
+ ],
+ "type": "integer",
+ "minimum": 0,
+ "maximum": 100
+ },
+ "grade": {
+ "$ref": "#/$defs/grade",
+ "description": "Compliance expressed as a grade.\n\nThe `grade` property contains a grade (A-F) of how well the extension complies with best practices.\nThe value of the `grade` can be `A`,`B`,`C`,`D`,`E`,`F` and is calculated from the `level` property.\n",
+ "examples": [
+ "C",
+ "A"
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
+ "grade": {
+ "description": "The results of the checks are in the form of a grade.\n",
+ "type": "string",
+ "enum": [
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G"
+ ],
+ "examples": [
+ "C",
+ "A"
+ ]
+ },
+ "repository": {
+ "type": "object",
+ "description": "Repository metadata.\n\nMetadata provided by the extension's git repository manager. Repository metadata are not registered, they are queried at runtime using the repository manager API.\n",
+ "required": [
+ "name",
+ "owner",
+ "url"
+ ],
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "The name of the repository.\n",
+ "examples": [
+ "xk6-dashboard",
+ "xk6-sql"
+ ]
+ },
+ "owner": {
+ "type": "string",
+ "description": "The owner of the repository.\n",
+ "examples": [
+ "grafana"
+ ]
+ },
+ "url": {
+ "type": "string",
+ "description": "URL of the repository.\n\nThe URL is provided by the repository manager and can be displayed in a browser.\n",
+ "examples": [
+ "https://github.com/grafana/xk6-dashboard"
+ ]
+ },
+ "homepage": {
+ "type": "string",
+ "default": "",
+ "description": "The URL to the project homepage.\n\nIf no homepage is set, the value is the same as the url property.\n",
+ "examples": [
+ "https://github.com/grafana/xk6-dashboard"
+ ]
+ },
+ "description": {
+ "type": "string",
+ "default": "",
+ "description": "Repository description.\n",
+ "examples": [
+ "This is a wonderful extension, it says 'Hello Wonderful World!'"
+ ]
+ },
+ "stars": {
+ "type": "integer",
+ "default": "0",
+ "description": "The number of stars in the extension's repository.\n\nThe extension's popularity is indicated by how many users have starred the extension's repository.\n",
+ "examples": [
+ 365,
+ 202
+ ]
+ },
+ "topics": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Repository topics.\n\nTopics make it easier to find the repository. It is recommended to set the xk6 topic to the extensions repository.\n",
+ "examples": [
+ [
+ "xk6",
+ "testing"
+ ],
+ [
+ "xk6"
+ ]
+ ]
+ },
+ "public": {
+ "type": "boolean",
+ "default": "false",
+ "description": "Public repository flag.\n\nA `true` value indicates that the repository is public, available to anyone.\n",
+ "examples": [
+ true
+ ]
+ },
+ "license": {
+ "type": "string",
+ "default": "",
+ "description": "The SPDX ID of the extension's license.\n\nFor more information about SPDX, visit https://spdx.org/licenses/\n",
+ "examples": [
+ "AGPL-3.0-only",
+ "MIT"
+ ]
+ },
+ "archived": {
+ "type": "boolean",
+ "default": "false",
+ "description": "Archived repository flag.\n\nA `true` value indicates that the repository is archived, read only.\n\nIf a repository is archived, it usually means that the owner has no intention of maintaining it. Such extensions should be removed from the registry.\n"
+ },
+ "timestamp": {
+ "type": "number",
+ "default": 0,
+ "description": "Last modification timestamp.\n\nThe timestamp property contains the timestamp of the last modification of the repository in UNIX time format (the number of non-leap seconds that have elapsed since 00:00:00 UTC on 1st January 1970).\nIts value depends on the repository manager, in the case of GitHub it contains the time of the last push operation, in the case of GitLab the time of the last repository activity.\n",
+ "examples": [
+ 1725277028,
+ 1690893368
+ ]
+ },
+ "clone_url": {
+ "type": "string",
+ "default": "",
+ "description": "URL for the git clone operation.\n\nThe clone_url property contains a (typically HTTP) URL, which is used to clone the repository.\n",
+ "examples": [
+ "https://github.com/grafana/xk6-dashboard.git",
+ "https://github.com/grafana/xk6-sql.git"
+ ]
+ }
+ }
+ },
+ "tier": {
+ "type": "string",
+ "enum": [
+ "official",
+ "partner",
+ "community"
+ ],
+ "description": "Maintainer of the extension.\n\nExtensions can be classified according to who maintains the extension.\nThis usually also specifies who the user can get support from.\n\nPossible values:\n\n - official: Extensions owned, maintained, and designated by Grafana as \"official\"\n - partner: Extensions written, maintained, validated, and published by third-party companies against their own projects.\n - community: Extensions are listed on the Registry by individual maintainers, groups of maintainers, or other members of the k6 community.\n\nExtensions owned by the `grafana` GitHub organization are not officially supported by Grafana by default.\nThere are several k6 extensions owned by the `grafana` GitHub organization, which were created for experimental or example purposes only.\nThe `official` tier value is needed so that officially supported extensions can be distinguished from them.\n\nIf it is missing from the registry source, it will be set with the default `community` value during generation.\n",
+ "examples": [
+ "community",
+ "official"
+ ]
+ },
+ "product": {
+ "type": "string",
+ "enum": [
+ "oss",
+ "cloud",
+ "synthetic"
+ ],
+ "description": "Products in which the extension can be used.\n\nSome extensions are not available in all k6 products.\nThis may be for a technological or business reason, or the functionality of the extension may not make sense in the given product.\n\nPossible values:\n\n - oss: Extensions are available in k6 OSS\n - cloud: Extensions are available in Grafana Cloud k6\n - synthetic: Extensions are available in Grafana Synthetic Monitoring\n\nIf it is missing from the registry source, it will be set with the default `[\"community\"]` value during generation.\n",
+ "examples": [
+ [
+ "cloud",
+ "synthetic",
+ "oss"
+ ],
+ [
+ "cloud"
+ ],
+ [
+ "oss"
+ ]
+ ]
+ },
+ "category": {
+ "type": "string",
+ "enum": [
+ "authentication",
+ "browser",
+ "data",
+ "kubernetes",
+ "messaging",
+ "misc",
+ "observability",
+ "protocol",
+ "reporting"
+ ],
+ "description": "The categories to which the extension belongs.\n\nIf it is missing from the registry source, it will be set with the default `[\"misc\"]` value during generation.\n",
+ "examples": [
+ [
+ "data",
+ "reporting"
+ ],
+ [
+ "observability",
+ "protocol"
+ ]
+ ]
+ }
+ }
+}
diff --git a/internal/registry/registry_gen.go b/internal/registry/registry_gen.go
new file mode 100644
index 0000000..ec08182
--- /dev/null
+++ b/internal/registry/registry_gen.go
@@ -0,0 +1,296 @@
+// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.
+
+package registry
+
+// k6 Extension Catalog.
+//
+// The k6 extension catalog is an alternative representation of the k6 extension
+// registry.
+// The catalog stores the extension data in an associative array (object),
+// where the key is the import path for JavaScript extensions, and the output name
+// for output extensions.
+// This data structure is optimized to resolve extensions as dependencies.
+type Catalog map[string]Extension
+
+type Category string
+
+const CategoryAuthentication Category = "authentication"
+const CategoryBrowser Category = "browser"
+const CategoryData Category = "data"
+const CategoryKubernetes Category = "kubernetes"
+const CategoryMessaging Category = "messaging"
+const CategoryMisc Category = "misc"
+const CategoryObservability Category = "observability"
+const CategoryProtocol Category = "protocol"
+const CategoryReporting Category = "reporting"
+
+// The result of the extension's k6 compliance checks.
+type Compliance struct {
+ // Compliance expressed as a grade.
+ //
+ // The `grade` property contains a grade (A-F) of how well the extension complies
+ // with best practices.
+ // The value of the `grade` can be `A`,`B`,`C`,`D`,`E`,`F` and is calculated from
+ // the `level` property.
+ //
+ Grade Grade `json:"grade" yaml:"grade" mapstructure:"grade"`
+
+ // Compliance expressed as a percentage.
+ //
+ // The `level` property contains a percentage of how well the extension complies
+ // with best practices.
+ // The value of the `level` can be between `0-100` and is determined by the
+ // weighted and normalized sum of the scores of the compliance checks.
+ //
+ Level int `json:"level" yaml:"level" mapstructure:"level"`
+}
+
+// Properties of the registered k6 extension.
+//
+// Only those properties of the extensions are registered, which either cannot be
+// detected automatically, or delegation to the extension is not allowed.
+//
+// Properties that are available using the repository manager API are intentionally
+// not registered.
+//
+// The string like properties that are included in the generated Grafana
+// documentation are intentionally not accessed via the API of the repository
+// manager. It is not allowed to inject arbitrary text into the Grafana
+// documentation site without approval. Therefore, these properties are registered
+// (eg `description`)
+type Extension struct {
+ // The categories to which the extension belongs.
+ //
+ // If the property is missing or empty in the registry source, the default value
+ // is `["misc"]`.
+ //
+ Categories []Category `json:"categories,omitempty" yaml:"categories,omitempty" mapstructure:"categories,omitempty"`
+
+ // Flag indicating the need for cgo.
+ //
+ // The `cgo` property value `true` indicates that cgo must be enabled to build the
+ // extension.
+ //
+ Cgo bool `json:"cgo,omitempty" yaml:"cgo,omitempty" mapstructure:"cgo,omitempty"`
+
+ // The result of the extension's k6 compliance checks.
+ //
+ Compliance *Compliance `json:"compliance,omitempty" yaml:"compliance,omitempty" mapstructure:"compliance,omitempty"`
+
+ // Version constraints.
+ //
+ // Version constraints are primarily used to filter automatically detected
+ // versions.
+ // It can also be used to filter the versions property imported from the origin
+ // registry.
+ //
+ Constraints string `json:"constraints,omitempty" yaml:"constraints,omitempty" mapstructure:"constraints,omitempty"`
+
+ // Brief description of the extension.
+ //
+ Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
+
+ // List of JavaScript import paths registered by the extension.
+ //
+ // Currently, paths must start with the prefix `k6/x/`.
+ //
+ // The extensions used by k6 scripts are automatically detected based on the
+ // values specified here, therefore it is important that the values used here are
+ // consistent with the values registered by the extension at runtime.
+ //
+ Imports []string `json:"imports,omitempty" yaml:"imports,omitempty" mapstructure:"imports,omitempty"`
+
+ // The extension's go module path.
+ //
+ // This is the unique identifier of the extension.
+ // More info about module paths: https://go.dev/ref/mod#module-path
+ //
+ // The extension has no name property, the module path or part of it can be used
+ // as the extension name. For example, using the first two elements of the module
+ // path after the host name, the name `grafana/xk6-dashboard` can be formed from
+ // the module path `github.com/grafana/xk6-dashboard`. This is typically the
+ // repository owner name and the repository name in the repository manager.
+ //
+ // The extension has no URL property, a URL can be created from the module path
+ // that refers to the extension within the repository manager.
+ //
+ Module string `json:"module" yaml:"module" mapstructure:"module"`
+
+ // List of output names registered by the extension.
+ //
+ // The extensions used by k6 scripts are automatically detected based on the
+ // values specified here, therefore it is important that the values used here are
+ // consistent with the values registered by the extension at runtime.
+ //
+ Outputs []string `json:"outputs,omitempty" yaml:"outputs,omitempty" mapstructure:"outputs,omitempty"`
+
+ // Products in which the extension can be used.
+ //
+ // Some extensions are not available in all k6 products.
+ // This may be for a technological or business reason, or the functionality of the
+ // extension may not make sense in the given product.
+ //
+ // Possible values:
+ //
+ // - oss: Extensions are available in k6 OSS
+ // - cloud: Extensions are available in Grafana Cloud k6
+ // - synthetic: Extensions are available in Grafana Synthetic Monitoring
+ //
+ // If the property is missing or empty in the source of the registry, it means
+ // that the extension is only available in the k6 OSS product.
+ // In this case, the registry will be filled in accordingly during generation.
+ //
+ Products []Product `json:"products,omitempty" yaml:"products,omitempty" mapstructure:"products,omitempty"`
+
+ // Repository metadata.
+ //
+ // Metadata provided by the extension's git repository manager. Repository
+ // metadata are not registered, they are queried at runtime using the repository
+ // manager API.
+ //
+ Repo *Repository `json:"repo,omitempty" yaml:"repo,omitempty" mapstructure:"repo,omitempty"`
+
+ // Maintainer of the extension.
+ //
+ // Possible values:
+ //
+ // - official: Extensions owned, maintained, and designated by Grafana as
+ // "official"
+ // - partner: Extensions written, maintained, validated, and published by
+ // third-party companies against their own projects.
+ // - community: Extensions are listed on the Registry by individual maintainers,
+ // groups of maintainers, or other members of the k6 community.
+ //
+ // Extensions owned by the `grafana` GitHub organization are not officially
+ // supported by Grafana by default.
+ // There are several k6 extensions owned by the `grafana` GitHub organization,
+ // which were created for experimental or example purposes only.
+ // The `official` tier value is needed so that officially supported extensions can
+ // be distinguished from them.
+ //
+ // If it is missing from the registry source, it will be set with the default
+ // "community" value during generation.
+ //
+ Tier Tier `json:"tier,omitempty" yaml:"tier,omitempty" mapstructure:"tier,omitempty"`
+
+ // List of supported versions.
+ //
+ // Versions are tags whose format meets the requirements of semantic versioning.
+ // Version tags often start with the letter `v`, which is not part of the semantic
+ // version.
+ //
+ Versions []string `json:"versions,omitempty" yaml:"versions,omitempty" mapstructure:"versions,omitempty"`
+}
+
+type Grade string
+
+const GradeA Grade = "A"
+const GradeB Grade = "B"
+const GradeC Grade = "C"
+const GradeD Grade = "D"
+const GradeE Grade = "E"
+const GradeF Grade = "F"
+const GradeG Grade = "G"
+
+type Product string
+
+const ProductCloud Product = "cloud"
+const ProductOSS Product = "oss"
+const ProductSynthetic Product = "synthetic"
+
+// k6 Extension Registry.
+//
+// The k6 extension registry contains the most important properties of registered
+// extensions.
+type Registry []Extension
+
+// Repository metadata.
+//
+// Metadata provided by the extension's git repository manager. Repository metadata
+// are not registered, they are queried at runtime using the repository manager
+// API.
+type Repository struct {
+ // Archived repository flag.
+ //
+ // A `true` value indicates that the repository is archived, read only.
+ //
+ // If a repository is archived, it usually means that the owner has no intention
+ // of maintaining it. Such extensions should be removed from the registry.
+ //
+ Archived bool `json:"archived,omitempty" yaml:"archived,omitempty" mapstructure:"archived,omitempty"`
+
+ // URL for the git clone operation.
+ //
+ // The clone_url property contains a (typically HTTP) URL, which is used to clone
+ // the repository.
+ //
+ CloneURL string `json:"clone_url,omitempty" yaml:"clone_url,omitempty" mapstructure:"clone_url,omitempty"`
+
+ // Repository description.
+ //
+ Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
+
+ // The URL to the project homepage.
+ //
+ // If no homepage is set, the value is the same as the url property.
+ //
+ Homepage string `json:"homepage,omitempty" yaml:"homepage,omitempty" mapstructure:"homepage,omitempty"`
+
+ // The SPDX ID of the extension's license.
+ //
+ // For more information about SPDX, visit https://spdx.org/licenses/
+ //
+ License string `json:"license,omitempty" yaml:"license,omitempty" mapstructure:"license,omitempty"`
+
+ // The name of the repository.
+ //
+ Name string `json:"name" yaml:"name" mapstructure:"name"`
+
+ // The owner of the repository.
+ //
+ Owner string `json:"owner" yaml:"owner" mapstructure:"owner"`
+
+ // Public repository flag.
+ //
+ // A `true` value indicates that the repository is public, available to anyone.
+ //
+ Public bool `json:"public,omitempty" yaml:"public,omitempty" mapstructure:"public,omitempty"`
+
+ // The number of stars in the extension's repository.
+ //
+ // The extension's popularity is indicated by how many users have starred the
+ // extension's repository.
+ //
+ Stars int `json:"stars,omitempty" yaml:"stars,omitempty" mapstructure:"stars,omitempty"`
+
+ // Last modification timestamp.
+ //
+ // The timestamp property contains the timestamp of the last modification of the
+ // repository in UNIX time format (the number of non-leap seconds that have
+ // elapsed since 00:00:00 UTC on 1st January 1970).
+ // Its value depends on the repository manager, in the case of GitHub it contains
+ // the time of the last push operation, in the case of GitLab the time of the last
+ // repository activity.
+ //
+ Timestamp float64 `json:"timestamp,omitempty" yaml:"timestamp,omitempty" mapstructure:"timestamp,omitempty"`
+
+ // Repository topics.
+ //
+ // Topics make it easier to find the repository. It is recommended to set the xk6
+ // topic to the extensions repository.
+ //
+ Topics []string `json:"topics,omitempty" yaml:"topics,omitempty" mapstructure:"topics,omitempty"`
+
+ // URL of the repository.
+ //
+ // The URL is provided by the repository manager and can be displayed in a
+ // browser.
+ //
+ URL string `json:"url" yaml:"url" mapstructure:"url"`
+}
+
+type Tier string
+
+const TierCommunity Tier = "community"
+const TierOfficial Tier = "official"
+const TierPartner Tier = "partner"
diff --git a/options.go b/options.go
new file mode 100644
index 0000000..18767cb
--- /dev/null
+++ b/options.go
@@ -0,0 +1,94 @@
+// Package k6dist contains k6dists's go API.
+package k6dist
+
+import (
+ "runtime"
+)
+
+// Options contains the optional parameters of the Build function.
+type Options struct {
+ // Name contains short name of the distribution.
+ // Templating is not supported.
+ Name string
+ // Version contains distribution version.
+ // Templating is not supported.
+ Version string
+ // Executable is the name of the k6 executable file to be built.
+ // Templating is supported.
+ // It defaults to DefaultExecutableTemplate.
+ Executable string
+ // Archive is the name of the archive file to be created.
+ // Templating is supported.
+ // It defaults to DefaultArchiveTemplate.
+ Archive string
+ // Readme is the name of the readme file to be added.
+ // Templating is not supported.
+ // No readme will be added if it is empty.
+ Readme string
+ // License is the name of the license file to be added.
+ // Templating is not supported.
+ // No license will be added if it is empty.
+ License string
+ // NotesTemplate is the name of the release notes (go) template file.
+ // Templating is not supported in filename.
+ // Default is an embedded template.
+ NotesTemplate string
+ // Notes is the name of the generated release notes file.
+ // Templating is supported.
+ // It defaults to DefaultNotesTemplate.
+ Notes string
+ // DockerfileTemplate is the name of the Dockerfile template.
+ // Templating is not supported in filename.
+ // Default is an embedded template.
+ DockerfileTemplate string
+ // Dockerfile is the name of the generated Dockerfile.
+ // Templating is supported.
+ // It defaults to Dockerfile in the same directory as the executable.
+ Dockerfile string
+ // NotesLatest contains the name of the latest release notes file.
+ // It is used for change detection, if the release notes have not changed, no new release is made.
+ // Within the release notes, an HTML comment contains the module list.
+ // Change detection is done by comparing this.
+ // Templating is not supported.
+ NotesLatest string
+ // Platforms contains the target platforms.
+ // If absent, the current runtime platform will be used.
+ Platforms []*Platform
+ // Registry contains the location of the registry. Its value is http(s) URL or filesystem path.
+ // Templating is not supported.
+ // It defaults to the URL of the registry subset containing the official k6 extensions.
+ Registry string
+}
+
+const (
+ // DefaultExecutableTemplate is a default go template for executable file path.
+ DefaultExecutableTemplate = `dist/{{.Name}}_{{.OS}}_{{.Arch}}/k6{{.ExeExt}}`
+ // DefaultNotesTemplate is a default go template for release notes file path.
+ DefaultNotesTemplate = `dist/{{.Name}}_{{.Version}}.md`
+ // DefaultArchiveTemplate is a default go template for archive file path.
+ DefaultArchiveTemplate = `dist/{{.Name}}_{{.Version}}_{{.OS}}_{{.Arch}}{{.ZipExt}}`
+ // DefaultRegistryURL is a default registry URL.
+ DefaultRegistryURL = `https://registry.k6.io/tier/official.json`
+)
+
+func (o *Options) setDefaults() {
+ if len(o.Executable) == 0 {
+ o.Executable = DefaultExecutableTemplate
+ }
+
+ if len(o.Notes) == 0 {
+ o.Notes = DefaultNotesTemplate
+ }
+
+ if len(o.Archive) == 0 {
+ o.Archive = DefaultArchiveTemplate
+ }
+
+ if len(o.Registry) == 0 {
+ o.Registry = DefaultRegistryURL
+ }
+
+ if o.Platforms == nil {
+ o.Platforms = []*Platform{{OS: runtime.GOOS, Arch: runtime.GOARCH}}
+ }
+}
diff --git a/platform.go b/platform.go
new file mode 100644
index 0000000..18eea51
--- /dev/null
+++ b/platform.go
@@ -0,0 +1,31 @@
+package k6dist
+
+import (
+ "errors"
+ "fmt"
+ "strings"
+)
+
+// ErrInvalidPlatform thrown when platform cannot be parsed.
+var ErrInvalidPlatform = errors.New("invalid platform")
+
+// Platform contains a target platform (OS and architecture) for building.
+type Platform struct {
+ OS string
+ Arch string
+}
+
+// String returns the platform in string format.
+func (p Platform) String() string {
+ return p.OS + "/" + p.Arch
+}
+
+// ParsePlatform parses string representation of Platform.
+func ParsePlatform(value string) (*Platform, error) {
+ idx := strings.IndexRune(value, '/')
+ if idx <= 0 || idx == len(value)-1 {
+ return nil, fmt.Errorf("%w: %s", ErrInvalidPlatform, value)
+ }
+
+ return &Platform{OS: value[:idx], Arch: value[idx+1:]}, nil
+}
diff --git a/release.go b/release.go
new file mode 100644
index 0000000..7e10d8d
--- /dev/null
+++ b/release.go
@@ -0,0 +1,80 @@
+package k6dist
+
+import (
+ "bytes"
+ _ "embed"
+ "encoding/json"
+ "os"
+ "path/filepath"
+ "regexp"
+
+ "github.com/grafana/k6dist/internal/registry"
+)
+
+//go:embed NOTES.md.tpl
+var defaultNotesTemplate string
+
+const (
+ notesFooterBegin = ""
+)
+
+func notesFooter(registry registry.Registry) (string, error) {
+ var buff bytes.Buffer
+
+ buff.WriteString(notesFooterBegin)
+ buff.WriteRune('\n')
+
+ encoder := json.NewEncoder(&buff)
+
+ encoder.SetEscapeHTML(false)
+
+ if err := encoder.Encode(registry.ToModules()); err != nil {
+ return "", err
+ }
+
+ buff.WriteString(notesFooterEnd)
+ buff.WriteRune('\n')
+
+ return buff.String(), nil
+}
+
+func expandNotes(name, version string, reg registry.Registry, tmplfile string) (string, error) {
+ var tmplsrc string
+
+ if len(tmplfile) != 0 {
+ bin, err := os.ReadFile(filepath.Clean(tmplfile)) //nolint:forbidigo
+ if err != nil {
+ return "", err
+ }
+
+ tmplsrc = string(bin)
+ } else {
+ tmplsrc = defaultNotesTemplate
+ }
+
+ data, err := newReleaseData(name, version, reg)
+ if err != nil {
+ return "", err
+ }
+
+ return expandTemplate("notes", tmplsrc, data)
+}
+
+var reModules = regexp.MustCompile("(?ms:^" + notesFooterBegin + "(?P.*)" + notesFooterEnd + ")")
+
+func parseNotes(notes []byte) (bool, registry.Modules, error) {
+ match := reModules.FindSubmatch(notes)
+
+ if match == nil {
+ return false, nil, nil
+ }
+
+ var modules registry.Modules
+
+ if err := json.Unmarshal(match[reModules.SubexpIndex("modules")], &modules); err != nil {
+ return false, nil, err
+ }
+
+ return true, modules, nil
+}
diff --git a/releases/v0.1.0.md b/releases/v0.1.0.md
new file mode 100644
index 0000000..fa4bdb0
--- /dev/null
+++ b/releases/v0.1.0.md
@@ -0,0 +1,3 @@
+π k6dist `v0.1.1` is here!
+
+This is the initial release.
diff --git a/template.go b/template.go
new file mode 100644
index 0000000..17712a2
--- /dev/null
+++ b/template.go
@@ -0,0 +1,84 @@
+package k6dist
+
+import (
+ "bytes"
+ "os"
+ "path/filepath"
+ "text/template"
+
+ sprig "github.com/go-task/slim-sprig/v3"
+
+ "github.com/grafana/k6dist/internal/registry"
+)
+
+type instanceData struct {
+ Name string
+ Version string
+ OS string
+ Arch string
+ ExeExt string
+ ZipExt string
+}
+
+type releaseData struct {
+ Name string
+ Version string
+ Registry registry.Registry
+ Footer string
+}
+
+func newInstsanceData(name, version string, platform *Platform) *instanceData {
+ exe := ""
+ zip := ".tar.gz"
+
+ if platform.OS == "windows" {
+ exe = ".exe"
+ zip = ".zip"
+ }
+
+ return &instanceData{
+ Name: name,
+ Version: version,
+ OS: platform.OS,
+ Arch: platform.Arch,
+ ExeExt: exe,
+ ZipExt: zip,
+ }
+}
+
+func newReleaseData(name, version string, reg registry.Registry) (*releaseData, error) {
+ footer, err := notesFooter(reg)
+ if err != nil {
+ return nil, err
+ }
+
+ return &releaseData{Name: name, Version: version, Registry: reg, Footer: footer}, nil
+}
+
+func expandTemplate(name string, tmplsrc string, data interface{}) (string, error) {
+ tmpl, err := template.New(name).Funcs(sprig.TxtFuncMap()).Parse(tmplsrc)
+ if err != nil {
+ return "", err
+ }
+
+ var buff bytes.Buffer
+
+ if err := tmpl.Execute(&buff, data); err != nil {
+ return "", err
+ }
+
+ return buff.String(), nil
+}
+
+func expandAsTargetPath(name string, tmplsrc string, data interface{}) (string, error) {
+ filename, err := expandTemplate(name, tmplsrc, data)
+ if err != nil {
+ return "", err
+ }
+
+ if err := os.MkdirAll(filepath.Dir(filename), 0o700); err != nil { //nolint:forbidigo
+ return "", err
+ }
+
+ return filename, nil
+}
diff --git a/testdata/k6-official.md b/testdata/k6-official.md
new file mode 100644
index 0000000..b78ea76
--- /dev/null
+++ b/testdata/k6-official.md
@@ -0,0 +1,28 @@
+π **k6-official** `24.10.04` is here!
+
+## Contents
+
+Name | Version | Previous | Description
+-----|---------|----------|------------
+[k6](https://github.com/grafana/k6) | [v0.54.0](https://github.com/grafana/k6/releases/tag/v0.54.0) | β‘ | A modern load testing tool, using Go and JavaScript
+[xk6-client-prometheus-remote](https://github.com/grafana/xk6-client-prometheus-remote) | [v0.3.2](https://github.com/grafana/xk6-client-prometheus-remote/releases/tag/v0.3.2) | β‘ | Test Prometheus Remote Write performance
+[xk6-dashboard](https://github.com/grafana/xk6-dashboard) | [v0.7.5](https://github.com/grafana/xk6-dashboard/releases/tag/v0.7.5) | β‘ | Create a web-based metrics dashboard
+[xk6-disruptor](https://github.com/grafana/xk6-disruptor) | [v0.3.12](https://github.com/grafana/xk6-disruptor/releases/tag/v0.3.12) | β‘ | Inject faults to test π£
+[xk6-exec](https://github.com/grafana/xk6-exec) | [v0.4.1](https://github.com/grafana/xk6-exec/releases/tag/v0.4.1) | β‘ | Run external commands
+[xk6-faker](https://github.com/grafana/xk6-faker) | [v0.4.0](https://github.com/grafana/xk6-faker/releases/tag/v0.4.0) | β‘ | Generate random fake data
+[xk6-kubernetes](https://github.com/grafana/xk6-kubernetes) | [v0.10.0](https://github.com/grafana/xk6-kubernetes/releases/tag/v0.10.0) | β‘ | Interact with Kubernetes clusters
+[xk6-loki](https://github.com/grafana/xk6-loki) | [v1.0.0](https://github.com/grafana/xk6-loki/releases/tag/v1.0.0) | β‘ | Client for load testing Loki
+[xk6-notification](https://github.com/grafana/xk6-notification) | [v0.1.2](https://github.com/grafana/xk6-notification/releases/tag/v0.1.2) | β‘ | Create notifications
+[xk6-output-influxdb](https://github.com/grafana/xk6-output-influxdb) | [v0.5.0](https://github.com/grafana/xk6-output-influxdb/releases/tag/v0.5.0) | β‘ | Export results to InfluxDB v2
+[xk6-output-kafka](https://github.com/grafana/xk6-output-kafka) | [v0.7.1](https://github.com/grafana/xk6-output-kafka/releases/tag/v0.7.1) | β‘ | Export k6 results in real-time to Kafka
+[xk6-output-opentelemetry](https://github.com/grafana/xk6-output-opentelemetry) | [v0.2.0](https://github.com/grafana/xk6-output-opentelemetry/releases/tag/v0.2.0) | β‘ | Export k6 results in OpenTelemetry format
+[xk6-output-timescaledb](https://github.com/grafana/xk6-output-timescaledb) | [v0.2.1](https://github.com/grafana/xk6-output-timescaledb/releases/tag/v0.2.1) | β‘ | Export k6 results to TimescaleDB
+[xk6-sql](https://github.com/grafana/xk6-sql) | [v0.4.1](https://github.com/grafana/xk6-sql/releases/tag/v0.4.1) | β‘ | Load-test SQL Servers
+[xk6-ssh](https://github.com/grafana/xk6-ssh) | [v0.1.1](https://github.com/grafana/xk6-ssh/releases/tag/v0.1.1) | β‘ | SSH
+
+β‘ means same, β means missing
+
+
+
diff --git a/testdata/official.json b/testdata/official.json
new file mode 100644
index 0000000..cc087f1
--- /dev/null
+++ b/testdata/official.json
@@ -0,0 +1,806 @@
+[
+ {
+ "categories": [
+ "observability"
+ ],
+ "compliance": {
+ "grade": "A",
+ "level": 100
+ },
+ "description": "Test Prometheus Remote Write performance",
+ "imports": [
+ "k6/x/remotewrite"
+ ],
+ "module": "github.com/grafana/xk6-client-prometheus-remote",
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-client-prometheus-remote.git",
+ "description": "A k6 extension for testing Prometheus Remote Write endpoints",
+ "homepage": "https://github.com/grafana/xk6-client-prometheus-remote",
+ "license": "Apache-2.0",
+ "name": "xk6-client-prometheus-remote",
+ "owner": "grafana",
+ "public": true,
+ "stars": 24,
+ "timestamp": 1718976971,
+ "topics": [
+ "prometheus",
+ "remote-write",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-client-prometheus-remote"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.3.2",
+ "v0.3.1",
+ "v0.3.0",
+ "v0.2.4",
+ "v0.2.3",
+ "v0.2.2",
+ "v0.2.1",
+ "v0.2.0",
+ "v0.1.0",
+ "v0.0.3",
+ "v0.0.2",
+ "v0.0.1"
+ ]
+ },
+ {
+ "categories": [
+ "reporting",
+ "observability"
+ ],
+ "compliance": {
+ "grade": "C",
+ "level": 80
+ },
+ "description": "Create a web-based metrics dashboard",
+ "module": "github.com/grafana/xk6-dashboard",
+ "outputs": [
+ "dashboard"
+ ],
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-dashboard.git",
+ "description": "A k6 extension that makes k6 metrics available on a web-based dashboard.",
+ "homepage": "https://github.com/grafana/xk6-dashboard",
+ "license": "AGPL-3.0",
+ "name": "xk6-dashboard",
+ "owner": "grafana",
+ "public": true,
+ "stars": 345,
+ "timestamp": 1719907965,
+ "topics": [
+ "xk6",
+ "xk6-official",
+ "xk6-output-dashboard"
+ ],
+ "url": "https://github.com/grafana/xk6-dashboard"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.7.5",
+ "v0.7.4",
+ "v0.7.3",
+ "v0.7.3-alpha.1",
+ "v0.7.2",
+ "v0.7.1",
+ "v0.7.0",
+ "v0.7.0-apha.3",
+ "v0.7.0-alpha.5",
+ "v0.7.0-alpha.4",
+ "v0.7.0-alpha.3",
+ "v0.7.0-alpha.2",
+ "v0.7.0-alpha.1",
+ "v0.6.1",
+ "v0.6.0",
+ "v0.5.5",
+ "v0.5.4",
+ "v0.5.3",
+ "v0.5.2",
+ "v0.5.1",
+ "v0.5.0",
+ "v0.4.4",
+ "v0.4.3",
+ "v0.4.2",
+ "v0.4.1",
+ "v0.4.0",
+ "v0.3.2",
+ "v0.3.1",
+ "v0.3.0",
+ "v0.2.0",
+ "v0.1.3",
+ "v0.1.2",
+ "v0.1.1",
+ "v0.1.0"
+ ]
+ },
+ {
+ "categories": [
+ "kubernetes"
+ ],
+ "compliance": {
+ "grade": "C",
+ "level": 80
+ },
+ "description": "Inject faults to test π£",
+ "imports": [
+ "k6/x/disruptor"
+ ],
+ "module": "github.com/grafana/xk6-disruptor",
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-disruptor.git",
+ "description": "Extension for injecting faults into k6 tests",
+ "homepage": "https://k6.io/docs/javascript-api/xk6-disruptor/",
+ "license": "AGPL-3.0",
+ "name": "xk6-disruptor",
+ "owner": "grafana",
+ "public": true,
+ "stars": 93,
+ "timestamp": 1728033717,
+ "topics": [
+ "chaos-engineering",
+ "fault-injection",
+ "k6",
+ "testing",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-disruptor"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.3.12",
+ "v0.3.11",
+ "v0.3.10",
+ "v0.3.9",
+ "v0.3.8",
+ "v0.3.7",
+ "v0.3.6",
+ "v0.3.5",
+ "v0.3.5-rc2",
+ "v0.3.5-rc1",
+ "v0.3.4",
+ "v0.3.3",
+ "v0.3.2",
+ "v0.3.1",
+ "v0.3.0",
+ "v0.2.1",
+ "v0.2.0",
+ "v0.1.3",
+ "v0.1.2",
+ "v0.1.1",
+ "v0.1.0"
+ ]
+ },
+ {
+ "categories": [
+ "misc"
+ ],
+ "compliance": {
+ "grade": "A",
+ "level": 100
+ },
+ "description": "Run external commands",
+ "imports": [
+ "k6/x/exec"
+ ],
+ "module": "github.com/grafana/xk6-exec",
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-exec.git",
+ "description": "A k6 extension for running external commands. ",
+ "homepage": "https://github.com/grafana/xk6-exec",
+ "license": "Apache-2.0",
+ "name": "xk6-exec",
+ "owner": "grafana",
+ "public": true,
+ "stars": 20,
+ "timestamp": 1725464620,
+ "topics": [
+ "exec",
+ "k6",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-exec"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.4.1",
+ "v0.4.0",
+ "v0.3.0",
+ "v0.2.0",
+ "v0.1.0",
+ "v0.0.1"
+ ]
+ },
+ {
+ "categories": [
+ "data"
+ ],
+ "compliance": {
+ "grade": "A",
+ "level": 100
+ },
+ "description": "Generate random fake data",
+ "imports": [
+ "k6/x/faker"
+ ],
+ "module": "github.com/grafana/xk6-faker",
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-faker.git",
+ "description": "Random fake data generator for k6.",
+ "homepage": "https://faker.x.k6.io",
+ "license": "AGPL-3.0",
+ "name": "xk6-faker",
+ "owner": "grafana",
+ "public": true,
+ "stars": 56,
+ "timestamp": 1725533453,
+ "topics": [
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-faker"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.4.0",
+ "v0.3.1",
+ "v0.3.0",
+ "v0.3.0-alpha.1",
+ "v0.2.2",
+ "v0.2.1",
+ "v0.2.0",
+ "v0.1.0"
+ ]
+ },
+ {
+ "categories": [
+ "kubernetes"
+ ],
+ "compliance": {
+ "grade": "A",
+ "level": 100
+ },
+ "description": "Interact with Kubernetes clusters",
+ "imports": [
+ "k6/x/kubernetes"
+ ],
+ "module": "github.com/grafana/xk6-kubernetes",
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-kubernetes.git",
+ "description": "Client extension for interacting with Kubernetes clusters from your k6 tests.",
+ "homepage": "https://github.com/grafana/xk6-kubernetes",
+ "license": "Apache-2.0",
+ "name": "xk6-kubernetes",
+ "owner": "grafana",
+ "public": true,
+ "stars": 62,
+ "timestamp": 1722251942,
+ "topics": [
+ "kubernetes",
+ "kubernetes-client",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-kubernetes"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.10.0",
+ "v0.9.0",
+ "v0.8.0",
+ "v0.7.0",
+ "v0.6.0",
+ "v0.5.0",
+ "v0.4.0",
+ "v0.3.0",
+ "v0.2.2",
+ "v0.2.1",
+ "v0.2.0",
+ "v0.1.1",
+ "v0.1.0",
+ "v0.0.5",
+ "v0.0.4",
+ "v0.0.3",
+ "v0.0.2",
+ "v0.0.1"
+ ]
+ },
+ {
+ "categories": [
+ "observability",
+ "messaging"
+ ],
+ "compliance": {
+ "grade": "B",
+ "level": 92
+ },
+ "description": "Client for load testing Loki",
+ "imports": [
+ "k6/x/loki"
+ ],
+ "module": "github.com/grafana/xk6-loki",
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-loki.git",
+ "description": "k6 extension for Loki",
+ "homepage": "https://github.com/grafana/xk6-loki",
+ "license": "Apache-2.0",
+ "name": "xk6-loki",
+ "owner": "grafana",
+ "public": true,
+ "stars": 38,
+ "timestamp": 1724212557,
+ "topics": [
+ "k6",
+ "loki",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-loki"
+ },
+ "tier": "official",
+ "versions": [
+ "v1.0.0"
+ ]
+ },
+ {
+ "categories": [
+ "reporting"
+ ],
+ "compliance": {
+ "grade": "A",
+ "level": 100
+ },
+ "description": "Create notifications",
+ "imports": [
+ "k6/x/notification"
+ ],
+ "module": "github.com/grafana/xk6-notification",
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-notification.git",
+ "description": "A k6 extension for creating notifications. ",
+ "homepage": "https://github.com/grafana/xk6-notification",
+ "license": "Apache-2.0",
+ "name": "xk6-notification",
+ "owner": "grafana",
+ "public": true,
+ "stars": 18,
+ "timestamp": 1718008202,
+ "topics": [
+ "k6",
+ "k6-extension",
+ "shoutrrr",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-notification"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.1.2",
+ "v0.1.1",
+ "v0.1.0"
+ ]
+ },
+ {
+ "categories": [
+ "data"
+ ],
+ "compliance": {
+ "grade": "C",
+ "level": 80
+ },
+ "description": "Export results to InfluxDB v2",
+ "module": "github.com/grafana/xk6-output-influxdb",
+ "outputs": [
+ "xk6-influxdb"
+ ],
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-output-influxdb.git",
+ "description": "k6 extension to output real-time test metrics to an InfluxDB 2.x database.",
+ "homepage": "https://github.com/grafana/xk6-output-influxdb",
+ "license": "Apache-2.0",
+ "name": "xk6-output-influxdb",
+ "owner": "grafana",
+ "public": true,
+ "stars": 62,
+ "timestamp": 1724921925,
+ "topics": [
+ "grafana-dashboard",
+ "influxdb",
+ "k6",
+ "k6-output",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-output-influxdb"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.5.0",
+ "v0.4.3",
+ "v0.4.2",
+ "v0.4.1",
+ "v0.4.0",
+ "v0.3.0",
+ "v0.2.2",
+ "v0.2.1",
+ "v0.2.0",
+ "v0.1.0"
+ ]
+ },
+ {
+ "categories": [
+ "reporting",
+ "messaging"
+ ],
+ "compliance": {
+ "grade": "A",
+ "level": 100
+ },
+ "description": "Export k6 results in real-time to Kafka",
+ "module": "github.com/grafana/xk6-output-kafka",
+ "outputs": [
+ "xk6-kafka"
+ ],
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-output-kafka.git",
+ "description": "k6 extension to output real-time test metrics to a Kafka topic.",
+ "homepage": "https://github.com/grafana/xk6-output-kafka",
+ "license": "Apache-2.0",
+ "name": "xk6-output-kafka",
+ "owner": "grafana",
+ "public": true,
+ "stars": 21,
+ "timestamp": 1718012070,
+ "topics": [
+ "k6",
+ "k6-output",
+ "kafka",
+ "kafka-streams",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-output-kafka"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.7.1",
+ "v0.7.0",
+ "v0.6.0",
+ "v0.5.0",
+ "v0.4.1",
+ "v0.4.0",
+ "v0.3.0",
+ "v0.2.0",
+ "v0.1.1",
+ "v0.1.0"
+ ]
+ },
+ {
+ "categories": [
+ "reporting",
+ "observability"
+ ],
+ "compliance": {
+ "grade": "A",
+ "level": 100
+ },
+ "description": "Export k6 results in OpenTelemetry format",
+ "module": "github.com/grafana/xk6-output-opentelemetry",
+ "outputs": [
+ "opentelemetry"
+ ],
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-output-opentelemetry.git",
+ "description": "A k6 extension to output real-time test metrics in OpenTelemetry format.",
+ "homepage": "https://github.com/grafana/xk6-output-opentelemetry",
+ "license": "AGPL-3.0",
+ "name": "xk6-output-opentelemetry",
+ "owner": "grafana",
+ "public": true,
+ "stars": 11,
+ "timestamp": 1725275530,
+ "topics": [
+ "k6",
+ "k6-output",
+ "opentelemetry",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-output-opentelemetry"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.2.0",
+ "v0.1.1",
+ "v0.1.0"
+ ]
+ },
+ {
+ "categories": [
+ "reporting",
+ "data"
+ ],
+ "compliance": {
+ "grade": "C",
+ "level": 80
+ },
+ "description": "Export k6 results to TimescaleDB",
+ "module": "github.com/grafana/xk6-output-timescaledb",
+ "outputs": [
+ "timescaledb"
+ ],
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-output-timescaledb.git",
+ "description": "k6 extension to output real-time test metrics to TimescaleDB.",
+ "homepage": "https://github.com/grafana/xk6-output-timescaledb",
+ "license": "Apache-2.0",
+ "name": "xk6-output-timescaledb",
+ "owner": "grafana",
+ "public": true,
+ "stars": 30,
+ "timestamp": 1718012137,
+ "topics": [
+ "grafana-dashboard",
+ "k6",
+ "k6-output",
+ "timescaledb",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-output-timescaledb"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.2.1",
+ "v0.2.0",
+ "v0.1.1",
+ "v0.1.0",
+ "v0.0.4",
+ "v0.0.3",
+ "v0.0.2",
+ "v0.0.1"
+ ]
+ },
+ {
+ "categories": [
+ "data"
+ ],
+ "compliance": {
+ "grade": "A",
+ "level": 100
+ },
+ "description": "Load-test SQL Servers",
+ "imports": [
+ "k6/x/sql"
+ ],
+ "module": "github.com/grafana/xk6-sql",
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-sql.git",
+ "description": "k6 extension to load test RDBMSs (PostgreSQL, MySQL, MS SQL and SQLite3)",
+ "homepage": "https://github.com/grafana/xk6-sql",
+ "license": "Apache-2.0",
+ "name": "xk6-sql",
+ "owner": "grafana",
+ "public": true,
+ "stars": 111,
+ "timestamp": 1725979901,
+ "topics": [
+ "k6",
+ "sql",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-sql"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.4.1",
+ "v0.4.0",
+ "v0.3.0",
+ "v0.2.1",
+ "v0.2.0",
+ "v0.1.1",
+ "v0.1.0",
+ "v0.0.1"
+ ]
+ },
+ {
+ "categories": [
+ "misc"
+ ],
+ "compliance": {
+ "grade": "A",
+ "level": 100
+ },
+ "description": "SSH",
+ "imports": [
+ "k6/x/ssh"
+ ],
+ "module": "github.com/grafana/xk6-ssh",
+ "products": [
+ "oss"
+ ],
+ "repo": {
+ "clone_url": "https://github.com/grafana/xk6-ssh.git",
+ "description": "Client extension for interacting with a host over SSH as part of your k6 test.",
+ "homepage": "https://github.com/grafana/xk6-ssh",
+ "license": "Apache-2.0",
+ "name": "xk6-ssh",
+ "owner": "grafana",
+ "public": true,
+ "stars": 9,
+ "timestamp": 1718011915,
+ "topics": [
+ "ssh",
+ "ssh-client",
+ "xk6"
+ ],
+ "url": "https://github.com/grafana/xk6-ssh"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.1.1",
+ "v0.1.0",
+ "v0.0.1"
+ ]
+ },
+ {
+ "categories": [
+ "misc"
+ ],
+ "description": "A modern load testing tool, using Go and JavaScript",
+ "imports": [
+ "k6"
+ ],
+ "module": "go.k6.io/k6",
+ "products": [
+ "cloud",
+ "synthetic",
+ "oss"
+ ],
+ "repo": {
+ "description": "A modern load testing tool, using Go and JavaScript - https://k6.io",
+ "homepage": "https://github.com/grafana/k6",
+ "license": "AGPL-3.0",
+ "name": "k6",
+ "owner": "grafana",
+ "public": true,
+ "topics": [
+ "es6",
+ "go",
+ "golang",
+ "hacktoberfest",
+ "javascript",
+ "load-generator",
+ "load-testing",
+ "performance"
+ ],
+ "url": "https://github.com/grafana/k6"
+ },
+ "tier": "official",
+ "versions": [
+ "v0.54.0",
+ "v0.53.0",
+ "v0.52.0",
+ "v0.51.0",
+ "v0.50.0",
+ "v0.49.0",
+ "v0.48.0",
+ "v0.47.0",
+ "v0.46.0",
+ "v0.45.1",
+ "v0.45.0",
+ "v0.44.1",
+ "v0.44.0",
+ "v0.43.1",
+ "v0.43.0",
+ "v0.42.0",
+ "v0.41.0",
+ "v0.40.0",
+ "v0.39.0",
+ "v0.38.3",
+ "v0.38.2",
+ "v0.38.1",
+ "v0.38.0",
+ "v0.37.0",
+ "v0.36.0",
+ "v0.35.0",
+ "v0.34.1",
+ "v0.34.0",
+ "v0.33.0",
+ "v0.32.0",
+ "v0.31.1",
+ "v0.31.0",
+ "v0.30.0",
+ "v0.29.0",
+ "v0.28.0",
+ "v0.27.1",
+ "v0.27.0",
+ "v0.26.2",
+ "v0.26.1",
+ "v0.26.0",
+ "v0.25.1",
+ "v0.25.0",
+ "v0.24.0",
+ "v0.23.1",
+ "v0.23.0",
+ "v0.22.1",
+ "v0.22.0",
+ "v0.21.1",
+ "v0.21.0",
+ "v0.20.0",
+ "v0.19.0",
+ "v0.18.2",
+ "v0.18.1",
+ "v0.18.0",
+ "v0.17.2",
+ "v0.17.1",
+ "v0.17.0",
+ "v0.16.0",
+ "v0.15.0",
+ "v0.14.0",
+ "v0.13.0",
+ "v0.12.2",
+ "v0.12.1",
+ "v0.11.0",
+ "v0.10.0",
+ "v0.9.3",
+ "v0.9.2",
+ "v0.9.1",
+ "v0.9.0",
+ "v0.8.5",
+ "v0.8.4",
+ "v0.8.3",
+ "v0.8.2",
+ "v0.8.1",
+ "v0.8.0",
+ "v0.7.0",
+ "v0.6.0",
+ "v0.5.2",
+ "v0.5.1",
+ "v0.5.0",
+ "v0.4.5",
+ "v0.4.4",
+ "v0.4.3",
+ "v0.4.2",
+ "v0.4.1",
+ "v0.4.0",
+ "v0.3.0",
+ "v0.2.1",
+ "v0.2.0",
+ "v0.0.2",
+ "v0.0.1"
+ ]
+ }
+]
diff --git a/tools/gendoc/main.go b/tools/gendoc/main.go
new file mode 100644
index 0000000..881ba9f
--- /dev/null
+++ b/tools/gendoc/main.go
@@ -0,0 +1,12 @@
+// Package main contains CLI documentation generator tool.
+package main
+
+import (
+ "github.com/grafana/clireadme"
+ "github.com/grafana/k6dist/cmd"
+)
+
+func main() {
+ root := cmd.New(nil)
+ clireadme.Main(root, 1)
+}