-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (112 loc) · 4.46 KB
/
release.yaml
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
123
124
125
126
127
128
129
130
name: otlpinf-release
on:
push:
branches: [ "main" ]
schedule:
- cron: '0 0 * * 1'
permissions:
packages: write
contents: write
jobs:
check:
outputs:
release: ${{ steps.early.outputs.release }}
runs-on: ubuntu-latest
steps:
- id: early
name: New version check
run: |
OTEL_LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/open-telemetry/opentelemetry-collector-releases/releases/latest)
OTEL_LATEST_VERSION=$(echo $OTEL_LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
INF_LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/netboxlabs/opentelemetry-infinity/releases/latest)
INF_LATEST_VERSION=$(echo $INF_LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
release=''
if [[ $OTEL_LATEST_VERSION != $INF_LATEST_VERSION ]]; then
release=$OTEL_LATEST_VERSION
fi
echo "release=$release" >> $GITHUB_OUTPUT
release:
runs-on: ubuntu-latest
needs: check
if: needs.check.outputs.release != ''
steps:
- uses: actions/checkout@v4
- name: Download Version
env:
RELEASE: ${{needs.check.outputs.release}}
run: |
echo "LAST_TAG=`git tag --sort=committerdate | tail -1`" >> $GITHUB_ENV
ARTIFACT_VERSION=${RELEASE:1}
echo "ARTIFACT_VERSION=$ARTIFACT_VERSION" >> $GITHUB_ENV
ARTIFACT="otelcol-contrib_${ARTIFACT_VERSION}_linux_amd64.tar.gz"
ARTIFACT_URL="https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/$RELEASE/$ARTIFACT"
mkdir .temp/
wget -O .temp/otelcol-contrib.tar.gz $ARTIFACT_URL
tar -xvzf .temp/otelcol-contrib.tar.gz -C .temp/
mv .temp/otelcol-contrib runner/
rm -rf .temp/
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build Binary
run: make build
- name: Unit Tests
run: make test
- name: Zip files
run: |
zip -j otlpinf-amd64.zip build/otlpinf
zip -j otelcol-contrib-amd64.zip runner/otelcol-contrib
- name: Download and zip arm64
env:
RELEASE: ${{needs.check.outputs.release}}
ARTIFACT_VERSION: ${{ env.ARTIFACT_VERSION }}
run: |
ARTIFACT="otelcol-contrib_${ARTIFACT_VERSION}_linux_arm64.tar.gz"
ARTIFACT_URL="https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/$RELEASE/$ARTIFACT"
mkdir .temp/
wget -O .temp/otelcol-contrib.tar.gz $ARTIFACT_URL
tar -xvzf .temp/otelcol-contrib.tar.gz -C .temp/
zip -j otelcol-contrib-arm64.zip .temp/otelcol-contrib
rm -rf .temp/
- name: Generate release changelog
env:
LAST_TAG: ${{ env.LAST_TAG }}
run: |
echo "# What's new" > changelog.md
git log ${{ env.LAST_TAG }}..HEAD --pretty=format:"$ad- %s [%an]" >> changelog.md
sed -i -e "s/- /• /g" changelog.md
- name: Release
uses: softprops/action-gh-release@v1
env:
TAG: ${{needs.check.outputs.release}}
with:
tag_name: ${{ env.TAG }}
body_path: ./changelog.md
files: |
otlpinf-amd64.zip
otelcol-contrib-amd64.zip
otelcol-contrib-arm64.zip
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf #v3.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 #v3.8.0
- name: Login to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 #v3.3.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build image and push
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 #v6.10.0
env:
TAG: ${{needs.check.outputs.release}}
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64, linux/arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
netboxlabs/opentelemetry-infinity:latest
netboxlabs/opentelemetry-infinity:${{ env.TAG }}