ci: split between tags and normal branches
This commit is contained in:
parent
6e66ab6084
commit
d5883b8419
16
.github/workflows/release.yml
vendored
Normal file
16
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
name: Earthly snapshot
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
FORCE_COLOR: 1
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Download latest earthly
|
||||||
|
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.6/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
|
||||||
|
- name: Run earthly
|
||||||
|
run: earthly --ci --push +ci --SNAPSHOT=false --GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
@ -1,9 +1,11 @@
|
|||||||
name: Earthly +build
|
name: Earthly snapshot
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches:
|
||||||
|
- '*'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches:
|
||||||
|
- '*'
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -13,5 +15,5 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Download latest earthly
|
- name: Download latest earthly
|
||||||
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.6/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
|
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.6/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
|
||||||
- name: Run build
|
- name: Run earthly
|
||||||
run: earthly --ci --push +ci
|
run: earthly --ci +ci --SNAPSHOT=true
|
41
.goreleaser.yml
Normal file
41
.goreleaser.yml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
project_name: "glucose_exporter"
|
||||||
|
builds:
|
||||||
|
- env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
ldflags:
|
||||||
|
- "-s"
|
||||||
|
- "-w"
|
||||||
|
- "-extldflags '-static'"
|
||||||
|
- "-X git.wobcom.de/smartmetering/kerouac/cmd.version={{.Version}}"
|
||||||
|
- "-X git.wobcom.de/smartmetering/kerouac/cmd.commit={{.ShortCommit}}"
|
||||||
|
- "-X git.wobcom.de/smartmetering/kerouac/cmd.date={{.Date}}"
|
||||||
|
checksum:
|
||||||
|
name_template: "checksums.txt"
|
||||||
|
snapshot:
|
||||||
|
name_template: "{{.Tag}}-next"
|
||||||
|
source:
|
||||||
|
format: tar.gz
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- "^docs:"
|
||||||
|
- "^test"
|
||||||
|
- "^ci"
|
||||||
|
- "^lint"
|
||||||
|
- "^build"
|
||||||
|
- "happy linting"
|
||||||
|
- "^chore"
|
||||||
|
- "^style"
|
||||||
|
- "^Revert"
|
||||||
|
release:
|
||||||
|
github:
|
||||||
|
owner: xsteadfastx
|
||||||
|
name: glucose_exporter
|
||||||
|
footer: |-
|
||||||
|
## docker
|
||||||
|
`docker pull ghcr.io/xsteadfastx/glucose_exporter:{{ trimprefix .Tag "v"}}`
|
28
Earthfile
28
Earthfile
@ -22,8 +22,14 @@ code:
|
|||||||
SAVE ARTIFACT . code
|
SAVE ARTIFACT . code
|
||||||
|
|
||||||
ci:
|
ci:
|
||||||
|
FROM +deps
|
||||||
|
ARG SNAPSHOT=true
|
||||||
|
ARG GITHUB_TOKEN
|
||||||
BUILD +test
|
BUILD +test
|
||||||
BUILD +lint
|
BUILD +lint
|
||||||
|
COPY (+goreleaser/dist/metadata.json --SNAPSHOT=$SNAPSHOT --GITHUB_TOKEN=$GITHUB_TOKEN) /tmp/metadata.json
|
||||||
|
ARG DOCKER_TAG=$(cat /tmp/metadata.json|jq -r .version)
|
||||||
|
BUILD +docker --DOCKER_TAG=$DOCKER_TAG
|
||||||
|
|
||||||
test:
|
test:
|
||||||
COPY +code/code ./
|
COPY +code/code ./
|
||||||
@ -42,9 +48,31 @@ deps:
|
|||||||
FROM +base
|
FROM +base
|
||||||
RUN (cd /tmp; go install github.com/golangci/golangci-lint/cmd/golangci-lint@$GOLANGCILINT_VERSION)
|
RUN (cd /tmp; go install github.com/golangci/golangci-lint/cmd/golangci-lint@$GOLANGCILINT_VERSION)
|
||||||
RUN (cd /tmp; go install github.com/goreleaser/goreleaser@$GORELEASER_VERSION)
|
RUN (cd /tmp; go install github.com/goreleaser/goreleaser@$GORELEASER_VERSION)
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
git \
|
||||||
|
jq
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
FROM +deps
|
FROM +deps
|
||||||
COPY +code/code ./
|
COPY +code/code ./
|
||||||
COPY .golangci.yml .golangci.yml
|
COPY .golangci.yml .golangci.yml
|
||||||
RUN golangci-lint run
|
RUN golangci-lint run
|
||||||
|
|
||||||
|
goreleaser:
|
||||||
|
FROM +deps
|
||||||
|
ARG SNAPSHOT=true
|
||||||
|
ARG GITHUB_TOKEN
|
||||||
|
IF [ "$SNAPSHOT" = "true" ]
|
||||||
|
ARG CMD="release --snapshot --clean"
|
||||||
|
ELSE
|
||||||
|
ARG CMD="release --clean"
|
||||||
|
END
|
||||||
|
COPY . .
|
||||||
|
RUN goreleaser $CMD
|
||||||
|
SAVE ARTIFACT dist dist
|
||||||
|
|
||||||
|
docker:
|
||||||
|
FROM scratch
|
||||||
|
ARG DOCKER_TAG
|
||||||
|
COPY +goreleaser/dist/glucose_exporter_linux_amd64_v1/glucose_exporter /bin/glucose_exporter
|
||||||
|
SAVE IMAGE --push ghcr.io/xsteadfastx/glucose_exporter:$DOCKER_TAG
|
||||||
|
Loading…
Reference in New Issue
Block a user