forked from DataDog/dd-trace-dotnet
164 lines (144 loc) · 7.12 KB
/
lib-injection.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: "Lib Injection Images"
on:
# This GitHub Action will be invoked automatically from the main Azure DevOps build
workflow_dispatch:
inputs:
azdo_build_id:
description: 'The specific AzDo build from which the release artifacts will be downloaded.'
required: true
commit_id:
description: 'Use a specific commit? If provided, this commit will be checked out, and the github images will be tagged with this commit'
required: false
default: ''
is_latest:
description: 'Does this commit represent a build that should be tagged as latest?'
required: false
default: false
jobs:
build-and-publish-init-image:
runs-on: ubuntu-latest
env:
AZURE_DEVOPS_TOKEN: "${{ secrets.AZURE_DEVOPS_TOKEN }}"
COMMIT_SHA: "${{ github.event.inputs.commit_id || github.sha }}"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: '${{ env.COMMIT_SHA }}'
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.100'
- name: "Get current version"
id: versions
run: ./tracer/build.sh OutputCurrentVersionToGitHub
- name: "Download build assets from Azure Pipelines"
id: assets
run: ./tracer/build.sh DownloadAzurePipelineFromBuild
env:
AzureDevopsBuildId: "${{ github.event.inputs.azdo_build_id }}"
- name: Copy ./lib-injection files to artifacts path
shell: bash
run: |
cp ./lib-injection/* ${{steps.assets.outputs.artifacts_path}}
# Temporarily create a placeholder linux-musl-arm directory
mkdir -p ${{steps.assets.outputs.artifacts_path}}/linux-musl-arm
touch ${{steps.assets.outputs.artifacts_path}}/linux-musl-arm/placeholder.txt
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
version: v0.12.1 # 0.13.0 is causing the builds to fail
- name: Login to Docker
run: docker login -u publisher -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
- name: Build and push dd-lib-dotnet-init:<SHA>-amd64
id: build-image-amd64
uses: docker/build-push-action@v3
with:
push: true
tags: 'ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:${{ env.COMMIT_SHA }}'
platforms: 'linux/amd64' # for windows, we can run windows/amd64,windows/386,windows/arm64
context: ${{steps.assets.outputs.artifacts_path}}
build-args: |
LINUX_PACKAGE=datadog-dotnet-apm-${{steps.versions.outputs.version}}.tar.gz
- name: Build and push dd-lib-dotnet-init:<SHA>-arm64v8
id: build-image-arm64v8
uses: docker/build-push-action@v3
with:
push: true
tags: 'ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:${{ env.COMMIT_SHA }}'
platforms: 'linux/arm64/v8'
context: ${{steps.assets.outputs.artifacts_path}}
build-args: |
LINUX_PACKAGE=datadog-dotnet-apm-${{steps.versions.outputs.version}}.arm64.tar.gz
- name: Build and push dd-lib-dotnet-init:<SHA>-musl-amd64
id: build-image-musl-amd64
uses: docker/build-push-action@v3
with:
push: true
tags: 'ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:${{ env.COMMIT_SHA }}-musl'
platforms: 'linux/amd64'
context: ${{steps.assets.outputs.artifacts_path}}
build-args: |
LINUX_PACKAGE=datadog-dotnet-apm-${{steps.versions.outputs.version}}-musl.tar.gz
- name: Build and push dd-lib-dotnet-init:<SHA>-musl-arm64v8
id: build-image-musl-arm64v8
uses: docker/build-push-action@v3
with:
push: true
tags: 'ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:${{ env.COMMIT_SHA }}-musl'
platforms: 'linux/arm64/v8'
context: ${{steps.assets.outputs.artifacts_path}}
# When we actually produce linux-musl-arm64 binaries, use that instead of the placeholder 'linux-musl-arm' directory
build-args: |
LINUX_PACKAGE=linux-musl-arm
- name: Publish multiarch images with all platforms
shell: bash
run: |
# Issue: The above 'docker buildx build' commands only create an image for one platform at a time because we have different build-args for each invocation.
# This results in the 'dd-lib-dotnet-init:<SHA>[-musl]' tag being overwritten by the latest build command, so the result is not a multiarch image
# Fix: The following lines create and publish a new manifest to overwrite the 'dd-lib-dotnet-init:<SHA>[-musl]' tag.
# In the new manifest we directly reference each platform-specific image, so the tag becomes a multiarch image.
docker manifest create \
ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:${{ env.COMMIT_SHA }} \
--amend "ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init@${{steps.build-image-amd64.outputs.digest}}" \
--amend "ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init@${{steps.build-image-arm64v8.outputs.digest}}"
docker manifest push ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:${{ env.COMMIT_SHA }}
docker manifest create \
ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:${{ env.COMMIT_SHA }}-musl \
--amend "ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init@${{steps.build-image-musl-amd64.outputs.digest}}" \
--amend "ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init@${{steps.build-image-musl-arm64v8.outputs.digest}}"
docker manifest push ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:${{ env.COMMIT_SHA }}-musl
- name: Publish latest multiarch images with all platforms
if: github.event.inputs.is_latest == true
shell: bash
run: |
# We also create latest_snapshot images
docker manifest create \
ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:latest_snapshot \
--amend "ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init@${{steps.build-image-amd64.outputs.digest}}" \
--amend "ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init@${{steps.build-image-arm64v8.outputs.digest}}"
docker manifest push ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:latest_snapshot
docker manifest create \
ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:latest_snapshot-musl \
--amend "ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init@${{steps.build-image-musl-amd64.outputs.digest}}" \
--amend "ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init@${{steps.build-image-musl-arm64v8.outputs.digest}}"
docker manifest push ghcr.io/datadog/dd-trace-dotnet/dd-lib-dotnet-init:latest_snapshot-musl
lib-injection-image-test:
needs:
- build-and-publish-init-image
permissions:
contents: read
packages: write
strategy:
matrix:
runtime: ['bullseye-slim','alpine']
fail-fast: false
uses: ./.github/workflows/lib-injection-test.yml
with:
commit_id: ${{ github.event.inputs.commit_id || github.sha }}
runtime: ${{ matrix.runtime }}
secrets:
DOCKER_REGISTRY_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}