diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..59bc948 --- /dev/null +++ b/.github/release-drafter.yml @@ -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 diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..4a6ed24 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,59 @@ +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 + with: + context: . + file: deploy/Dockerfile + push: true + tags: ghcr.io/lightbitslabs/los-csi:${{ env.tag }} \ No newline at end of file diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml new file mode 100644 index 0000000..f0e8eae --- /dev/null +++ b/.github/workflows/release-drafter.yaml @@ -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 }} diff --git a/deploy/Dockerfile b/deploy/Dockerfile index e279086..f2c66d0 100644 --- a/deploy/Dockerfile +++ b/deploy/Dockerfile @@ -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 @@ -34,7 +50,7 @@ RUN apk add --no-cache \ 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"]