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 5, 2023
1 parent 4084b5e commit af2f05c
Show file tree
Hide file tree
Showing 16 changed files with 151 additions and 131 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
21 changes: 0 additions & 21 deletions .github/release-drafter.yml

This file was deleted.

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.

2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ linters:
enable:
- gofmt
- goimports
- structcheck
- varcheck
- staticcheck
- unconvert
- revive
Expand Down
24 changes: 19 additions & 5 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
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"]
FROM golang:1.21-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 add --update --no-cache ca-certificates
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"]
21 changes: 17 additions & 4 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.55-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.55.2 golangci-lint run -v --timeout=5m
docker run --rm -v $(PWD):/app -w /app ${GOLANGCI_LINT_IMG} golangci-lint run -v

.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
Loading

0 comments on commit af2f05c

Please sign in to comment.