Skip to content

Commit b7ad17b

Browse files
authored
Build binaries and docker images on release. (#14)
* Add initial release workflow. * Build docker images on release.
1 parent ead9bf4 commit b7ad17b

5 files changed

Lines changed: 122 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
build:
14+
strategy:
15+
matrix:
16+
include:
17+
- goos: linux
18+
goarch: amd64
19+
- goos: linux
20+
goarch: arm64
21+
- goos: darwin
22+
goarch: amd64
23+
- goos: darwin
24+
goarch: arm64
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-go@v5
29+
with:
30+
go-version-file: go.mod
31+
32+
- run: make install-builder
33+
34+
- run: builder --config collector/manifest.yaml
35+
env:
36+
GOOS: ${{ matrix.goos }}
37+
GOARCH: ${{ matrix.goarch }}
38+
39+
- run: |
40+
mv dist/otelcol-oxide dist/otelcol-oxide-${{ matrix.goos }}-${{ matrix.goarch }}
41+
42+
- uses: actions/upload-artifact@v4
43+
with:
44+
name: otelcol-oxide-${{ matrix.goos }}-${{ matrix.goarch }}
45+
path: dist/otelcol-oxide-${{ matrix.goos }}-${{ matrix.goarch }}
46+
47+
release:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/download-artifact@v4
52+
with:
53+
path: dist
54+
merge-multiple: true
55+
56+
- working-directory: dist
57+
run: sha256sum otelcol-oxide-* > checksums.txt
58+
59+
- uses: softprops/action-gh-release@v2
60+
with:
61+
files: |
62+
dist/otelcol-oxide-*
63+
dist/checksums.txt
64+
generate_release_notes: true
65+
66+
docker:
67+
needs: build
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- uses: actions/download-artifact@v4
73+
with:
74+
pattern: otelcol-oxide-linux-*
75+
merge-multiple: true
76+
77+
- uses: docker/setup-buildx-action@v3
78+
79+
- uses: docker/login-action@v3
80+
with:
81+
registry: ghcr.io
82+
username: ${{ github.actor }}
83+
password: ${{ secrets.GITHUB_TOKEN }}
84+
85+
- uses: docker/metadata-action@v5
86+
id: meta
87+
with:
88+
images: ghcr.io/${{ github.repository }}
89+
tags: |
90+
type=semver,pattern={{version}}
91+
type=semver,pattern={{major}}.{{minor}}
92+
type=semver,pattern={{major}}
93+
type=raw,value=latest
94+
95+
# Note: Use Dockerfile.release and copy in images from the `build` step.
96+
# This is much faster than using `docker buildx` with the standard
97+
# Dockerfile, which relies on qemu for multi-arch builds and takes too long
98+
# to complete on GitHub Actions.
99+
- uses: docker/build-push-action@v6
100+
with:
101+
context: .
102+
file: collector/Dockerfile.release
103+
platforms: linux/amd64,linux/arm64
104+
push: true
105+
tags: ${{ steps.meta.outputs.tags }}
106+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v4
1212
- uses: actions/setup-go@v5
13+
with:
14+
go-version-file: go.mod
1315
- run: go test -v ./...
1416

1517
build-collector:
File renamed without changes.

collector/Dockerfile.release

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM alpine:3.21
2+
3+
ARG TARGETARCH
4+
5+
RUN apk add --no-cache ca-certificates
6+
7+
COPY otelcol-oxide-linux-${TARGETARCH} /otelcol-oxide
8+
RUN chmod +x /otelcol-oxide
9+
10+
EXPOSE 9091 8888
11+
12+
ENTRYPOINT ["/otelcol-oxide"]
13+
CMD ["--config", "/etc/otelcol/config.yaml"]

example/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
otelcol:
33
build:
44
context: ..
5-
dockerfile: example/Dockerfile
5+
dockerfile: collector/Dockerfile
66
environment:
77
- OXIDE_HOST=${OXIDE_HOST}
88
- OXIDE_TOKEN=${OXIDE_TOKEN}

0 commit comments

Comments
 (0)