Skip to content

Commit 76d1a86

Browse files
committed
feat: testing infra-agent oci multi-os-arch artifacts push
1 parent 6a3ca5e commit 76d1a86

File tree

1 file changed

+21
-84
lines changed

1 file changed

+21
-84
lines changed

.github/workflows/push_oci_artifact.yml

Lines changed: 21 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,9 @@
1-
# This action creates a new Testing Infra-agent OCI package version in the agent-control package registry
1+
# This action creates a new Testing Infra-agent OCI package version in the agent-control GitHub's package registry.
22
#
33
# The blob is a zip or tar containing:
44
# - newrelic-infra (.exe)
55
# - integrations/nri-docker (.exe)
66
#
7-
# The format for this package is a multiplatform index and one manifest with the artifact blob for each architecture.
8-
# The created index will be as the following:
9-
#
10-
# {
11-
# "schemaVersion": 2,
12-
# "mediaType": "application/vnd.oci.image.index.v1+json",
13-
# "manifests": [
14-
# {
15-
# "mediaType": "application/vnd.oci.image.manifest.v1+json",
16-
# "digest": "sha256:9b34549b8f5002df0518b002c8ba0ddcb2e004dee988620642fe71ac8d05c780",
17-
# "size": 696,
18-
# "platform": {
19-
# "architecture": "amd64",
20-
# "os": "darwin"
21-
# },
22-
# "artifactType": "application/vnd.newrelic.agent.v1+tar"
23-
# }
24-
# [...]
25-
# }
26-
#
27-
# Then each of the different manifests for each artifact
28-
#
29-
# {
30-
# "schemaVersion": 2,
31-
# "mediaType": "application/vnd.oci.image.manifest.v1+json",
32-
# "artifactType": "application/vnd.newrelic.agent.v1+zip",
33-
# "config": {
34-
# "mediaType": "application/vnd.oci.image.config.v1+json",
35-
# "digest": "sha256:7758599fc4d06bd93a65bf28bc98fbff6c559a9a56be1ec3d75ff6aa8a8cfe6e",
36-
# "size": 39
37-
# },
38-
# "layers": [
39-
# {
40-
# "mediaType": "application/vnd.newrelic.agent.v1+zip",
41-
# "digest": "sha256:a66a406acbaf188f0f9a2b34464fc18c66bb45742894f23ca5f9ed65e6c5ad8c",
42-
# "size": 21676600,
43-
# "annotations": {
44-
# "com.newrelic.artifact.type": "binary",
45-
# "org.opencontainers.image.title": "newrelic-infra-amd64.zip",
46-
# "org.opencontainers.image.version": "1.71.3"
47-
# }
48-
# }
49-
# ],
50-
# "annotations": {
51-
# "org.opencontainers.image.created": "2026-01-12T14:33:18Z"
52-
# }
53-
# }
54-
#
55-
# We require the artifactType to know the type of the artifact (it's also present as mediaType in the layer but it's more
56-
# correct to also place it as artifactType )
57-
#
58-
# The required annotations are:
59-
# - image.title
60-
# - com.newrelic.artifact.type
61-
#
62-
# The other 2 annotations, org.opencontainers.image.version and org.opencontainers.image.created are for info purposes.
63-
#
64-
# When pushing the artifact with oras with --artifact-platform, the config will be populated with platform.ach and platform.os
65-
# that are needed when creating the oras index to have a multiarch registry.
66-
#
67-
# At the end the resulting registry will be:
68-
# TAG (ex v1.7.7) --> Index (Pointing to different manifest digests per os/arch) --> manifest (identified by digest) -> Blob
697

708
name: OCI test repo - compile & push multi-platform testing-infra-agent
719
on:
@@ -90,11 +28,12 @@ jobs:
9028
strategy:
9129
matrix:
9230
include:
93-
- { os: linux, arch: amd64, binary: newrelic-infra, format: tar }
94-
- { os: linux, arch: arm64, binary: newrelic-infra, format: tar }
31+
- { os: linux, arch: amd64, binary: newrelic-infra, format: tar+gzip }
32+
- { os: linux, arch: arm64, binary: newrelic-infra, format: tar+gzip }
9533
- { os: windows, arch: amd64, binary: newrelic-infra.exe, format: zip }
96-
- { os: darwin, arch: arm64, binary: newrelic-infra, format: tar }
97-
- { os: darwin, arch: amd64, binary: newrelic-infra, format: tar }
34+
- { os: windows, arch: arm64, binary: newrelic-infra.exe, format: zip }
35+
- { os: darwin, arch: arm64, binary: newrelic-infra, format: tar+gzip }
36+
- { os: darwin, arch: amd64, binary: newrelic-infra, format: tar+gzip }
9837

9938
permissions:
10039
packages: write
@@ -118,41 +57,39 @@ jobs:
11857
mkdir -p integrations
11958
12059
if [ "${{ matrix.os }}" = "windows" ]; then
121-
URL="https://download.newrelic.com/infrastructure_agent/binaries/windows/${{ matrix.arch }}/nri-docker-${{ matrix.arch }}.${{ env.NRI_DOCKER_VERSION }}.zip"
60+
# we always package amd64 docker because arm64 doesn't exist.
61+
URL="https://download.newrelic.com/infrastructure_agent/binaries/windows/amd64/nri-docker-amd64.${{ env.NRI_DOCKER_VERSION }}.zip"
12262
curl -L -o nri-docker.zip "$URL"
123-
mkdir -p integrations-tmp
124-
unzip -j nri-docker.zip -d integrations-tmp/
125-
mv integrations-tmp/nri-docker.exe integrations/nri-docker.exe
126-
rm -rf integrations-tmp
63+
unzip -j nri-docker.zip '*/nri-docker.exe' -d integrations
12764
rm nri-docker.zip
12865
elif [ "${{ matrix.os }}" = "linux" ]; then
12966
URL="https://download.newrelic.com/infrastructure_agent/binaries/linux/${{ matrix.arch }}/nri-docker_linux_${{ env.NRI_DOCKER_VERSION }}_${{ matrix.arch }}.tar.gz"
13067
echo $URL
13168
curl -L -o nri-docker.tar.gz "$URL"
132-
mkdir -p integrations-tmp
133-
tar -xzf nri-docker.tar.gz -C integrations-tmp/ --strip-components=1
134-
mv integrations-tmp/var/db/newrelic-infra/newrelic-integrations/bin/nri-docker integrations/nri-docker
135-
rm -rf integrations-tmp
69+
tar -xzf nri-docker.tar.gz --strip-components=6 -C integrations
13670
rm nri-docker.tar.gz
13771
fi
13872
13973
- name: Compile Binary
14074
run: |
141-
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build \
142-
-o ${{ matrix.binary }} \
143-
./cmd/newrelic-infra
75+
# force amd64 if OS is windows because compiling infra arm64 is unsupported
76+
GOARCH_VALUE=${{ matrix.os == 'windows' && 'amd64' || matrix.arch }}
77+
78+
GOOS=${{ matrix.os }} GOARCH=$GOARCH_VALUE go build \
79+
-o ${{ matrix.binary }} \
80+
./cmd/newrelic-infra
14481
14582
- name: Package Artifact
14683
id: package
14784
run: |
14885
if [ "${{ matrix.os }}" = "windows" ]; then
14986
FILENAME="newrelic-infra-${{ matrix.arch }}.zip"
15087
zip -r $FILENAME ${{ matrix.binary }} integrations/
151-
echo "mime=application/zip" >> $GITHUB_OUTPUT
88+
echo "mime=application/vnd.newrelic.agent.content.v1.tar+gzip" >> $GITHUB_OUTPUT
15289
else
15390
FILENAME="newrelic-infra-${{ matrix.os }}-${{ matrix.arch }}.tar.gz"
15491
tar -cvzf $FILENAME ${{ matrix.binary }} integrations/
155-
echo "mime=application/vnd.oci.image.layer.v1.tar+gzip" >> $GITHUB_OUTPUT
92+
echo "mime=application/vnd.newrelic.agent.content.v1.zip" >> $GITHUB_OUTPUT
15693
fi
15794
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
15895
@@ -168,16 +105,16 @@ jobs:
168105
"${{ steps.package.outputs.filename }}": {
169106
"org.opencontainers.image.title": "${{ steps.package.outputs.filename }}",
170107
"org.opencontainers.image.version": "${{ env.AGENT_VERSION }}",
171-
"com.newrelic.artifact.type": "binary"
108+
"com.newrelic.artifact.type": "package"
172109
}
173110
}
174111
EOF
175112
176113
DIGEST=$(oras push ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} \
177-
--artifact-type application/vnd.newrelic.agent.v1+${{ matrix.format }} \
114+
--artifact-type application/vnd.newrelic.agent.v1 \
178115
--artifact-platform ${{ matrix.os }}/${{ matrix.arch }} \
179116
--annotation-file layer_annotations.json \
180-
${{ steps.package.outputs.filename }}:application/vnd.newrelic.agent.v1+${{ matrix.format }} | grep "Digest:" | awk '{print $2}')
117+
${{ steps.package.outputs.filename }}:application/vnd.newrelic.agent.v1.${{ matrix.format }} | grep "Digest:" | awk '{print $2}')
181118
182119
echo "$DIGEST" > digest-${{ matrix.os }}-${{ matrix.arch }}.txt
183120

0 commit comments

Comments
 (0)