forked from jriguera/otel-helloworldprocessor
-
Notifications
You must be signed in to change notification settings - Fork 4
109 lines (95 loc) · 3.42 KB
/
release-artifacts.yml
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
name: Release Docker image
on:
workflow_dispatch: { }
push:
branches:
- "main"
env:
# Default image for the Chart
DOCKER_IMAGE_NAME: otel-collector
DOCKER_REGISTRY: ghcr.io/${{ github.repository }}
DOCKER_BUILD_DIR: '.'
permissions: {}
jobs:
compile:
runs-on: ubuntu-latest
outputs:
artifact: ${{ steps.artifact.outputs.artifact-id }}
version: ${{ steps.versions.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup golang stable
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Get build versions
id: versions
run: |
awk -F':' '/^[[:blank:]]+otelcol_version[[:blank:]]*:/{ gsub("\"","",$2); gsub(" ", "", $2); print "otelcol-version="$2 }' builder-config.yaml >> $GITHUB_OUTPUT
awk -F':' '/^[[:blank:]]+output_path[[:blank:]]*:/{ gsub("\"","",$2); gsub(" ", "", $2); print "build-path="$2 }' builder-config.yaml >> $GITHUB_OUTPUT
awk -F':' '/^[[:blank:]]+name[[:blank:]]*:/{ gsub("\"","",$2); gsub(" ", "", $2); print "build-name="$2 }' builder-config.yaml >> $GITHUB_OUTPUT
awk -F':' '/^[[:blank:]]+version[[:blank:]]*:/{ gsub("\"","",$2); gsub(" ", "", $2); print "version="$2 }' builder-config.yaml >> $GITHUB_OUTPUT
- name: Download the collector builder
run: |
curl -Ss -fL -o ocb https://github.com/open-telemetry/opentelemetry-collector/releases/download/cmd%2Fbuilder%2Fv${VERSION}/ocb_${VERSION}_linux_amd64
chmod +x ocb
env:
VERSION: "${{ steps.versions.outputs.otelcol-version }}"
- name: Build the OTEL collectory binary
run: |
./ocb --config builder-config.yaml
- name: Archive binary
id: artifact
uses: actions/upload-artifact@v4
with:
name: otelcol-${{ steps.versions.outputs.version }}
retention-days: 1
path: "${{ steps.versions.outputs.build-path }}/${{ steps.versions.outputs.build-name }}"
if-no-files-found: error
overwrite: true
build-image:
permissions:
contents: read
packages: write
needs:
- compile
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: otelcol-${{ needs.compile.outputs.version }}
path: otelcol-dev
- name: Get metadata for Docker image
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}/${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=ref,event=branch
type=sha
- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push to Github Packages
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_BUILD_DIR }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ steps.meta.outputs.tags }}
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.compile.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}