Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build in Github CI #41

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 30 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'

template: |
## General Changes

$CHANGES

categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'

version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
58 changes: 58 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Docker Build Action
on:
pull_request:
branches:
- master
release:
types:
- published
push:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:

build:
name: compile, build and push container
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: false
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v4

# TODO: enable once all linter issues are solved
# - name: Lint
# uses: golangci/golangci-lint-action@v4
# with:
# args: -p bugs -p unused --timeout=3m

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Make tag
run: |
[ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "tag=${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true
[ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV || true
[ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true

- name: Build and push image
uses: docker/build-push-action@v5
majst01 marked this conversation as resolved.
Show resolved Hide resolved
with:
context: .
push: true
tags: ghcr.io/lightbitslabs/los-csi:${{ env.tag }}
majst01 marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions .github/workflows/release-drafter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Release Drafter Action

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 21 additions & 6 deletions deploy/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
FROM golang:1.22-alpine3.19 AS builder

RUN apk update && \
apk add --no-cache \
curl \
docker-cli \
bash \
make \
git \
g++

WORKDIR /work
COPY . .

RUN make build

# update alpine to get cryptsetup 2.4.x
FROM alpine:3.19

Expand All @@ -24,18 +40,17 @@ ENV CSI_ENDPOINT=unix:///csi/csi.sock \
LB_CSI_LOG_TIME=true \
LB_CSI_LOG_FMT=text

RUN apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/v3.14/main \
RUN apk add --no-cache \
cryptsetup \
e2fsprogs e2fsprogs-extra \
xfsprogs=5.12.0-r0 \
xfsprogs-extra=5.12.0-r0 \
xfsprogs \
xfsprogs-extra \
lsblk \
blkid \
kmod \
$EXTRA_PACKAGES

COPY licenses /licenses

COPY lb-csi-plugin /
COPY deploy/licenses /licenses
COPY --from=builder /work/deploy/lb-csi-plugin /

ENTRYPOINT ["/lb-csi-plugin"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ LDFLAGS ?= \
$(and $(BUILD_HASH), -X $(PKG_PREFIX)/pkg/driver.versionBuildHash=$(BUILD_HASH)) \
$(and $(BUILD_ID), -X $(PKG_PREFIX)/pkg/driver.versionBuildID=$(BUILD_ID)) \
-extldflags "-static"
override GO_VARS := GOPROXY=off GO111MODULE=on GOFLAGS=-mod=vendor CGO_ENABLED=0
override GO_VARS := CGO_ENABLED=0

override LABELS := \
--label org.opencontainers.image.title="Lightbits CSI Plugin" \
Expand Down
50 changes: 27 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
module github.com/lightbitslabs/los-csi

go 1.22
go 1.22.0

toolchain go1.22.2

require (
github.com/container-storage-interface/spec v1.3.0
github.com/fsnotify/fsnotify v1.4.9
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.1.2
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/fsnotify/fsnotify v1.7.0
github.com/golang/protobuf v1.5.4
github.com/google/uuid v1.6.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/kubernetes-csi/csi-test/v3 v3.1.1
github.com/sirupsen/logrus v1.8.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
golang.org/x/sys v0.0.0-20210510120138-977fb7262007
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c
google.golang.org/grpc v1.38.0
google.golang.org/protobuf v1.26.0
github.com/stretchr/testify v1.9.0
golang.org/x/sys v0.20.0
google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae
google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.34.1
gopkg.in/yaml.v2 v2.4.0
k8s.io/mount-utils v0.21.4
k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9
k8s.io/mount-utils v0.30.0
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/hpcloud/tail v1.0.0 // indirect
github.com/onsi/ginkgo v1.11.0 // indirect
github.com/onsi/gomega v1.7.1 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/moby/sys/mountinfo v0.7.1 // indirect
github.com/nxadm/tail v1.4.11 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.33.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.1.1 // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/text v0.3.5 // indirect
gopkg.in/fsnotify.v1 v1.4.7 // indirect
github.com/stretchr/objx v0.5.2 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/text v0.15.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
k8s.io/klog/v2 v2.8.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
)
Loading