Skip to content

Commit

Permalink
Earthfile and blueprint.cue
Browse files Browse the repository at this point in the history
  • Loading branch information
benbooth493 committed Nov 12, 2024
1 parent d781e90 commit 73074ca
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
69 changes: 69 additions & 0 deletions tools/github-job-checker/Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
VERSION 0.8

deps:
FROM golang:1.23.0-alpine3.19

WORKDIR /work

RUN apk add git file

RUN mkdir -p /go/cache && mkdir -p /go/modcache
ENV GOCACHE=/go/cache
ENV GOMODCACHE=/go/modcache
CACHE --persist --sharing shared /go

COPY ../lib/project+src/src /lib/project
COPY ../lib/tools+src/src /lib/tools

COPY go.mod go.sum .
RUN go mod download

src:
FROM +deps

CACHE --persist --sharing shared /go

COPY . .
RUN go generate ./...

check:
FROM +src

RUN gofmt -l . | grep . && exit 1 || exit 0
RUN go vet ./...

build:
FROM +src

ARG GOOS
ARG GOARCH
ARG version="0.0.0"

ENV CGO_ENABLED=0
RUN go build -ldflags="-extldflags=-static -X main.version=$version" -o bin/gh-job-checker main.go
RUN file bin/gh-job-checker

SAVE ARTIFACT bin/gh-job-checker gh-job-checker

test:
FROM +build

RUN go test ./...

github:
FROM scratch

ARG version="dev"

ARG TARGETOS
ARG TARGETARCH
ARG USERPLATFORM

COPY \
--platform=$USERPLATFORM \
(+build/forge \
--GOOS=$TARGETOS \
--GOARCH=$TARGETARCH \
--version=$version) bin/gh-job-checker

SAVE ARTIFACT bin/gh-job-checker gh-job-checker
31 changes: 31 additions & 0 deletions tools/github-job-checker/blueprint.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: "1.0"
project: {
name: "gh-job-checker"
ci: targets: {
github: {
args: {
version: string | *"dev" @forge(name="GIT_TAG")
}
platforms: [
"linux/amd64",
"linux/arm64",
"darwin/amd64",
"darwin/arm64",
]
}
test: retries: 3
}
release: {
github: {
on: tag: {}
config: {
name: string | *"dev" @forge(name="GIT_TAG")
prefix: project.name
token: {
provider: "env"
path: "GITHUB_TOKEN"
}
}
}
}
}

0 comments on commit 73074ca

Please sign in to comment.