Skip to content

Commit

Permalink
fix: fix cicd build project
Browse files Browse the repository at this point in the history
  • Loading branch information
cubxxw committed Mar 16, 2024
1 parent cc37d6e commit 95da5c4
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 67 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/create-release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ jobs:
MINOR_VERSION=${BASH_REMATCH[2]}
PATCH_VERSION=${BASH_REMATCH[3]}
# 检查是否满足创建分支的条件
if [[ ${PATCH_VERSION} -eq 0 && ! ${TAG_NAME} =~ [A-Za-z-] ]]; then
RELEASE_BRANCH_NAME="release-v${MAJOR_VERSION}.0"
# 创建分支
git branch "${RELEASE_BRANCH_NAME}" "${TAG_NAME}"
git push origin "${RELEASE_BRANCH_NAME}"
Expand Down
85 changes: 28 additions & 57 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,9 @@ report_sizes: true
dist: _output/dist

builds:
- binary: syncer
id: syncer
main: ./cmd/syncer/main.go
goos:
- windows
- darwin
- linux
- freebsd
goarch:
- amd64
- 386
- arm
- arm64
goarm:
- 6
- 7
- binary: exporter
id: exporter
main: ./cmd/exporter/main.go
- binary: cld
id: cld
main: ./cmd/cld/main.go
goos:
- windows
- darwin
Expand Down Expand Up @@ -192,26 +176,13 @@ changelog:


kos:
- repository: ghcr.io/kubecub/syncer
id: syncer
tags:
- '{{.Version}}'
- latest
bare: true
main: ./cmd/syncer/main.go
preserve_import_paths: false
base_image: alpine
platforms:
- linux/amd64
- linux/arm64

- repository: ghcr.io/kubecub/exporter
id: exporter
- repository: ghcr.io/kubecub/cld
id: cld
tags:
- '{{.Version}}'
- latest
bare: true
main: ./cmd/exporter/main.go
main: ./cmd/cld/main.go
base_image: alpine
preserve_import_paths: false
platforms:
Expand Down Expand Up @@ -293,53 +264,53 @@ checksum:

# - use: buildx
# ids:
# - exporter
# - cld
# goos: linux
# goarch: amd64
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/exporter:{{ .Tag }}-amd64
# dockerfile: deploy/exporter/Dockerfile.exporter
# - ghcr.io/{{ .Env.USERNAME }}/cld:{{ .Tag }}-amd64
# dockerfile: deploy/cld/Dockerfile.cld
# build_flag_templates:
# - --pull
# - --platform=linux/amd64
# - --label=io.exporter.image.created={{.Date}}
# - --label=io.exporter.image.title=exporter
# - --label=io.exporter.image.revision={{.ShortCommit}}
# - --label=io.exporter.image.version={{.Tag }}
# - --label=io.exporter.image.auth={{ .Env.USERNAME }}
# - --label=io.cld.image.created={{.Date}}
# - --label=io.cld.image.title=cld
# - --label=io.cld.image.revision={{.ShortCommit}}
# - --label=io.cld.image.version={{.Tag }}
# - --label=io.cld.image.auth={{ .Env.USERNAME }}

# - use: buildx
# ids:
# - exporter
# - cld
# goos: linux
# goarch: arm64
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/exporter:{{ .Tag }}-arm64
# dockerfile: docker/exporter/Dockerfile.exporter
# - ghcr.io/{{ .Env.USERNAME }}/cld:{{ .Tag }}-arm64
# dockerfile: docker/cld/Dockerfile.cld
# build_flag_templates:
# - --pull
# - --platform=linux/arm64
# - --label=io.exporter.image.created={{.Date}}
# - --label=io.exporter.image.title=exporter
# - --label=io.exporter.image.revision={{.ShortCommit}}
# - --label=io.exporter.image.version={{.Tag }}
# - --label=io.exporter.image.auth={{ .Env.USERNAME }}
# - --label=io.cld.image.created={{.Date}}
# - --label=io.cld.image.title=cld
# - --label=io.cld.image.revision={{.ShortCommit}}
# - --label=io.cld.image.version={{.Tag }}
# - --label=io.cld.image.auth={{ .Env.USERNAME }}


# docker_manifests:
# - name_template: ghcr.io/{{ .Env.USERNAME }}/exporter:{{ .Tag }}
# - name_template: ghcr.io/{{ .Env.USERNAME }}/cld:{{ .Tag }}
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/exporter:{{ .Tag }}-amd64
# - ghcr.io/{{ .Env.USERNAME }}/exporter:{{ .Tag }}-arm64
# - ghcr.io/{{ .Env.USERNAME }}/cld:{{ .Tag }}-amd64
# - ghcr.io/{{ .Env.USERNAME }}/cld:{{ .Tag }}-arm64
# - name_template: ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}-amd64
# - ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}-arm64

# - name_template: ghcr.io/{{ .Env.USERNAME }}/exporter:latest
# - name_template: ghcr.io/{{ .Env.USERNAME }}/cld:latest
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/exporter:{{ .Tag }}-amd64
# - ghcr.io/{{ .Env.USERNAME }}/exporter:{{ .Tag }}-arm64
# - ghcr.io/{{ .Env.USERNAME }}/cld:{{ .Tag }}-amd64
# - ghcr.io/{{ .Env.USERNAME }}/cld:{{ .Tag }}-arm64
# - name_template: ghcr.io/{{ .Env.USERNAME }}/syncer:latest
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}-amd64
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
- delete issue template

### Feat
- complete base exporter
- complete base cld
- add labels standard
- synchronous tag
- partial optimization
Expand Down
20 changes: 13 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.

FROM golang AS build
FROM golang:1.20 as builder

WORKDIR /build

ENV GOPROXY=https://goproxy.cn

WORKDIR /go/src/app

COPY . /go/src/app
COPY . .

# RUN go build -o /go/bin/app cmd/exporter/main.go
RUN make build

FROM alpine
COPY --from=build /go/bin/app/_output /
CMD ["/app"]
FROM alpine:latest

WORKDIR /app

COPY --from=builder /build/_output/bin/platforms/linux/amd64/cld .
COPY --from=builder /build/config.yaml .

ENTRYPOINT ["./cld", "-config", "config.yaml"]
17 changes: 17 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,20 @@
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.

name: 'Code Language Detector'
description: 'Detects specified languages in comments within code files.'
inputs:
config-path:
description: 'Path to the configuration file.'
required: true
default: '.github/code-language-detector.yml'

runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.config-path }}

branding:
icon: tool
color: blue
4 changes: 4 additions & 0 deletions deploy/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
reviewers:
- cubxxw
approvers:
- cubxxw
11 changes: 11 additions & 0 deletions deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `/build`

Packaging and Continuous Integration.

Put your cloud (AMI), container (Docker), OS (deb, rpm, pkg) package configurations and scripts in the `/build/package` directory.

Put your CI (travis, circle, drone) configurations and scripts in the `/build/ci` directory. Note that some of the CI tools (e.g., Travis CI) are very picky about the location of their config files. Try putting the config files in the `/build/ci` directory linking them to the location where the CI tools expect them when possible (don't worry if it's not and if keeping those files in the root directory makes your life easier :-)).

Examples:

* https://github.com/cockroachdb/cockroach/tree/master/build
13 changes: 13 additions & 0 deletions deploy/cld/Dockerfile.cld
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang AS builder

WORKDIR /app

ENV GOPROXY=https://goproxy.cn

COPY . /app/

RUN cd /app; go build -o _output/bin/cld cmd/cld/main.go

FROM scratch
COPY --from=builder /app/_output/bin/cld /app
ENTRYPOINT ["/app/cld --help"]

0 comments on commit 95da5c4

Please sign in to comment.