From 8496eaa69df8ee9fd68386fddfd1d8ae0a539dd5 Mon Sep 17 00:00:00 2001 From: Edmund Ochieng Date: Tue, 17 Mar 2026 11:47:07 -0500 Subject: [PATCH 1/2] add a release workflow powered by goreleaser Signed-off-by: Edmund Ochieng --- .github/workflows/release.yml | 39 +++++++++++++++++ .goreleaser.yaml | 82 +++++++++++++++++++++++++++++++++++ Dockerfile.ci | 32 ++++++++++++++ 3 files changed, 153 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yaml create mode 100644 Dockerfile.ci diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3144f75 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: Goreleaser + +on: + push: + tags: + - "v*" + +permissions: + contents: write + +jobs: + + release: + name: release + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - name: Setup Go + uses: actions/setup-go@v6 + with: + go-version-file: "go.mod" + + - name: Login to Quay.io + uses: docker/login-action@v4 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_ROBOT_TOKEN }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v7 + with: + distribution: doreleaser + version: '~> v2' + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..4cb9709 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,82 @@ +version: 2 + +project_name: virtwork + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... + +builds: + - id: linux-amd64 + env: + - CGO_ENABLED=1 + goos: + - linux + goarch: + - amd64 + flags: + - -trimpath + ldflags: + - -s -w -X main.version={{ .Version }} -X main.commit={{ .Commit }} -X main.date={{ .CommitDate }} + main: ./cmd/virtwork/ + +archives: + - formats: [tar.gz] + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + formats: [zip] + +dockers_v2: + - images: + - "quay.io/opdev/virtwork" + + tags: + - latest + - "{{ .Tag }}" + dockerfile: ./Dockerfile.ci + labels: + org.opencontainers.image.created: "{{ .Date }}" + org.opencontainers.image.name: "{{ .ProjectName }}" + org.opencontainers.image.revision: "{{ .FullCommit }}" + org.opencontainers.image.version: "{{ .Version }}" + org.opencontainers.image.source: "{{ .GitURL }}" + org.opencontainers.image.description: "CLI tool that creates VMs on OpenShift clusters with KubeVirt and runs continuous CPU, memory, database, network, and disk I/O workloads" + + annotations: + project: "{{ .ProjectName }}" + + platforms: + - linux/amd64 + + extra_files: + - entrypoint.sh + + ids: + - linux-amd64 + + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +release: + footer: >- + + --- + + Released by [GoReleaser](https://github.com/goreleaser/goreleaser). diff --git a/Dockerfile.ci b/Dockerfile.ci new file mode 100644 index 0000000..f35bcdc --- /dev/null +++ b/Dockerfile.ci @@ -0,0 +1,32 @@ +# Stage: Runtime image +# Copies binaries from the Goreleaser build context +FROM registry.access.redhat.com/ubi9/ubi-minimal:latest + +LABEL io.k8s.display-name="virtwork" \ + io.k8s.description="Creates virtual machines on OpenShift with continuous workloads for metrics generation" \ + io.openshift.tags="virtwork,kubevirt,openshift,workload-generator" \ + summary="virtwork workload generator for OpenShift Virtualization" \ + description="CLI tool that creates VMs on OpenShift clusters with KubeVirt and runs continuous CPU, memory, database, network, and disk I/O workloads" \ + name="virtwork" + +# sqlite-libs provides the runtime shared library for the CGO-compiled go-sqlite3 +RUN microdnf install -y sqlite-libs && \ + microdnf clean all + +# Create data directory for audit database. +# OpenShift runs containers with an arbitrary UID but always GID 0. +# Setting group ownership to 0 and mode 775 ensures writability. +RUN mkdir -p /data && \ + chown 1001:0 /data && \ + chmod 775 /data + +COPY linux/amd64/virtwork /usr/local/bin/virtwork +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +RUN chmod +x /usr/local/bin/entrypoint.sh + +USER 1001 +WORKDIR /data + +ENV VIRTWORK_AUDIT_DB=/data/virtwork.db + +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] From 28397da6e700086224888a548c0c290420a09cdd Mon Sep 17 00:00:00 2001 From: Edmund Ochieng Date: Wed, 18 Mar 2026 11:05:30 -0500 Subject: [PATCH 2/2] Update release.yml Fix spelling error --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3144f75..291b4f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ jobs: - name: Run GoReleaser uses: goreleaser/goreleaser-action@v7 with: - distribution: doreleaser + distribution: goreleaser version: '~> v2' args: release --clean env: