Skip to content

Commit

Permalink
update release process: docker build redone, helm chart to release ar…
Browse files Browse the repository at this point in the history
…tifact, migrate to main branch
  • Loading branch information
luthermonson committed Dec 1, 2023
1 parent 8086249 commit 6a78795
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 67 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Continuous Integration
on:
workflow_dispatch: null
push:
branches:
- main
pull_request: null

jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ 'stable', 'oldstable' ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Vet
run: make vet
- name: Lint
run: make lint
- name: Helm Lint
run: make helm-lint
- name: Test
run: make test
- name: Build
run: make build
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Docker Meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
linode/linode-cloud-controller-manager
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=semver,pattern={{raw}},value=${{ github.ref_name }}
- name: Build Dockerfile
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
REV=${{ github.ref_name }}
18 changes: 0 additions & 18 deletions .github/workflows/docker-hub.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/label-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Sync labels
on:
push:
branches:
- master
- main
paths:
- .github/labels.yml
jobs:
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/release-drafter.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release
on:
push:
tags:
- "v*.*.*"

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Release Artifacts
run: make release
env:
IMAGE_VERSION: ${{ github.ref_name }}
- name: Upload Release Artifacts
uses: softprops/action-gh-release@v1
with:
files: |
./release/helm-chart-${{ github.ref_name }}.tgz
- name: Docker Meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
linode/linode-cloud-controller-manager
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=semver,pattern={{raw}},value=${{ github.ref_name }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push to Docker Hub
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
22 changes: 0 additions & 22 deletions .github/workflows/test.yml

This file was deleted.

22 changes: 18 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# NB: We now cross-compile the go binary locally using the Makefile
FROM alpine:latest
FROM golang:1.20-alpine as builder
RUN mkdir -p /linode
WORKDIR /linode

COPY go.mod .
COPY go.sum .
COPY main.go .
COPY cloud ./cloud
COPY sentry ./sentry

RUN go mod download
RUN go build -a -ldflags '-extldflags "-static"' -o /bin/linode-cloud-controller-manager-linux /linode

FROM alpine:3.18.4
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
COPY dist/linode-cloud-controller-manager-linux-amd64 /
ENTRYPOINT ["/linode-cloud-controller-manager-linux-amd64"]
LABEL maintainers="Linode"
LABEL description="Linode Cloud Controller Manager"
COPY --from=builder /bin/linode-cloud-controller-manager-linux /linode-cloud-controller-manager-linux
ENTRYPOINT ["/linode-cloud-controller-manager-linux"]
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
IMG ?= linode/linode-cloud-controller-manager:canary
RELEASE_DIR ?= release
GOLANGCI_LINT_IMG := golangci/golangci-lint:v1.44-alpine

export GO111MODULE=on

Expand All @@ -7,17 +9,22 @@ all: build

.PHONY: clean
clean:
go clean .
rm -r dist/*
@go clean .
@rm -rf ./.tmp
@rm -rf dist/*
@rm -rf $(RELEASE_DIR)

.PHONY: codegen
codegen:
go generate ./...

.PHONY: vet
vet: fmt
go vet ./...

.PHONY: lint
lint:
docker run --rm -v "$(shell pwd):/var/work:ro" -w /var/work \
golangci/golangci-lint:v1.44.0 golangci-lint run -v --timeout=5m
lint: vet
docker run --rm -v $(PWD):/app -w /app ${GOLANGCI_LINT_IMG} golangci-lint run -v --timeout=5m

.PHONY: fmt
fmt:
Expand All @@ -41,6 +48,12 @@ build: codegen
CGO_ENABLED=0 \
go build -o dist/linode-cloud-controller-manager .

.PHONY: release
release:
mkdir -p $(RELEASE_DIR)
sed -e 's/appVersion: "latest"/appVersion: "$(IMAGE_VERSION)"/g' ./deploy/chart/Chart.yaml
tar -czvf ./$(RELEASE_DIR)/helm-chart-$(IMAGE_VERSION).tgz -C ./deploy/chart .

.PHONY: imgname
# print the Docker image name that will be used
# useful for subsequently defining it on the shell
Expand Down
2 changes: 1 addition & 1 deletion deploy/chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ name: ccm-linode
description: The Linode Cloud Controller Manager (CCM) provides a way for Kubernetes clusters to access additional Linode services. Linode's CCM will automatically provision a Linode NodeBalancer for Kubernetes Services of type "LoadBalancer".
type: application
version: 1.0.0
appVersion: "v0.3.16"
appVersion: "latest"

0 comments on commit 6a78795

Please sign in to comment.