Skip to content

Commit

Permalink
goreleaser experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
mxssl committed Feb 10, 2024
1 parent 832ca73 commit 9a42379
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 14 deletions.
45 changes: 33 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,50 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3

docker-release:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
- name: Docker login
run: docker login --username ${{ secrets.DOCKER_LOGIN }} --password ${{ secrets.DOCKER_PASSWORD }}
- name: Docker release
run: make docker-release

github-release:
release:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"

# Get values for cache paths to be used in later steps
- name: Get cache paths
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
# Cache go "build cache", used to speedup go test
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-build-
# Cache go mod cache, used to speedup builds
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-mod-
- name: Docker login
run: docker login --username ${{ secrets.DOCKER_LOGIN }} --password ${{ secrets.DOCKER_PASSWORD }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
app
.vscode
dist
15 changes: 15 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,18 @@ changelog:
exclude:
- '^docs:'
- '^test:'
dockers:
- goos: linux
goarch: amd64
image_templates:
- "mxssl/selectel-billing-exporter:latest"
- "mxssl/selectel-billing-exporter:{{ .Tag }}"
dockerfile: Dockerfile.ci
use: buildx
build_flag_templates:
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--platform=linux/amd64"
- "--pull"
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ENV GO111MODULE=on
WORKDIR /go/src/github.com/mxssl/selectel-billing-exporter
COPY . .

# install deps
RUN apk add --no-cache \
ca-certificates \
curl \
Expand All @@ -14,7 +13,6 @@ RUN apk add --no-cache \
RUN CGO_ENABLED=0 \
go build -v -o app

# copy compiled binary to a clear Alpine Linux image
FROM alpine:3.19.1
WORKDIR /
RUN apk add --no-cache \
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# syntax=docker/dockerfile:1
FROM alpine:3.19.1
WORKDIR /
RUN <<EOF
apk add --no-cache ca-certificates
EOF
COPY selectel-billing-exporter /app
RUN chmod +x app
CMD ["./app"]

0 comments on commit 9a42379

Please sign in to comment.