-
Notifications
You must be signed in to change notification settings - Fork 1
122 lines (106 loc) · 3.21 KB
/
release.yml
File metadata and controls
122 lines (106 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: go tool builder --config collector/manifest.yaml --skip-compilation
- run: cd dist && go build -trimpath -o otelcol-oxide .
env:
CGO_ENABLED: "0"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
- run: |
mv dist/otelcol-oxide dist/otelcol-oxide-${{ matrix.goos }}-${{ matrix.goarch }}
- uses: actions/upload-artifact@v4
with:
name: otelcol-oxide-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/otelcol-oxide-${{ matrix.goos }}-${{ matrix.goarch }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- working-directory: dist
run: sha256sum otelcol-oxide-* > checksums.txt
- name: Create or update release
run: |
PREV=$(git tag -l 'v*' --sort=-version:refname | sed -n '2p')
NOTES_ARGS="--generate-notes"
if [ -n "$PREV" ]; then
NOTES_ARGS="$NOTES_ARGS --notes-start-tag $PREV"
fi
if gh release view ${{ github.ref_name }} > /dev/null 2>&1; then
gh release upload ${{ github.ref_name }} \
dist/otelcol-oxide-* dist/checksums.txt --clobber
else
gh release create ${{ github.ref_name }} \
$NOTES_ARGS \
dist/otelcol-oxide-* dist/checksums.txt
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: otelcol-oxide-linux-*
merge-multiple: true
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
# Note: Use Dockerfile.release and copy in images from the `build` step.
# This is much faster than using `docker buildx` with the standard
# Dockerfile, which relies on qemu for multi-arch builds and takes too long
# to complete on GitHub Actions.
- uses: docker/build-push-action@v6
with:
context: .
file: collector/Dockerfile.release
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}