Skip to content

Commit

Permalink
Merge pull request #4 from DataDog/more-improvements
Browse files Browse the repository at this point in the history
Build & release pipelines
  • Loading branch information
christophetd authored Jun 14, 2024
2 parents 389e349 + ab42e01 commit ef546db
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/go.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ jobs:
run: go build -v ./...
- name: Test
run: go test -v ./...
- name: Local docker build
run: docker build . -t attache
41 changes: 41 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: docker

on:
push:
tags:
- "*"

env:
REGISTRY: ghcr.io
IMAGE_NAME: datadog/attache

permissions:
contents: read

jobs:
docker-build-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: release

on:
push:
tags:
- "*"

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22

- name: Run GoReleaser
timeout-minutes: 60
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
args: release --rm-dist --config .goreleaser.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
dir: ./cmd/attache
binary: attache
archives:
- name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.22-alpine AS builder
WORKDIR /build
RUN apk add --update make
ADD . /build
RUN make attache

FROM golang:1.22-alpine AS runner
LABEL org.opencontainers.image.source="https://github.com/DataDog/attache/"
COPY --from=builder /build/attache /attache
ENTRYPOINT ["/attache"]
1 change: 1 addition & 0 deletions cmd/attache/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func main() {

if len(os.Args) != 2 {
log.Error("usage: attache <config-file>")
os.Exit(12)
}

filePath := os.Args[1]
Expand Down

0 comments on commit ef546db

Please sign in to comment.