Skip to content

Commit d8c8fa1

Browse files
feat: add nri-docker and right format to testing infra-agent oci repo (#2049)
* feat: add nri-docker and right format to testing infra-agent oci repo * feat: testing infra-agent oci multi-os-arch artifacts push
1 parent 90ce8dd commit d8c8fa1

File tree

1 file changed

+89
-21
lines changed

1 file changed

+89
-21
lines changed
Lines changed: 89 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
1+
# This action creates a new Testing Infra-agent OCI package version in the agent-control GitHub's package registry.
2+
#
3+
# The blob is a zip or tar containing:
4+
# - newrelic-infra (.exe)
5+
# - integrations/nri-docker (.exe)
6+
#
7+
18
name: OCI test repo - compile & push multi-platform testing-infra-agent
29
on:
310
workflow_dispatch:
411
inputs:
5-
tag:
12+
agent_version:
613
description: 'Version tag'
714
required: true
15+
nri_docker_version:
16+
description: 'Embedded docker version'
17+
required: false
18+
default: "2.6.6"
819

920
env:
1021
IMAGE_NAME: "testing-infra-agent"
1122
AGENT_VERSION: ${{ github.event.inputs.agent_version }}
23+
NRI_DOCKER_VERSION: ${{ github.event.inputs.nri_docker_version }}
1224

1325
jobs:
1426
build-and-push:
1527
runs-on: ubuntu-latest
1628
strategy:
1729
matrix:
1830
include:
19-
- { os: linux, arch: amd64, goos: linux, goarch: amd64, binary: newrelic-infra }
20-
- { os: linux, arch: arm64, goos: linux, goarch: arm64, binary: newrelic-infra }
21-
- { os: windows, arch: amd64, goos: windows, goarch: amd64, binary: newrelic-infra.exe }
22-
- { os: darwin, arch: arm64, goos: darwin, goarch: arm64, binary: newrelic-infra }
23-
- { os: darwin, arch: amd64, goos: darwin, goarch: amd64, binary: newrelic-infra }
31+
- { os: linux, arch: amd64, binary: newrelic-infra, format: tar+gzip }
32+
- { os: linux, arch: arm64, binary: newrelic-infra, format: tar+gzip }
33+
- { os: windows, arch: amd64, binary: newrelic-infra.exe, format: zip }
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 }
2437

2538
permissions:
2639
packages: write
@@ -38,23 +51,45 @@ jobs:
3851
with:
3952
go-version: '1.25.6'
4053

54+
- name: Download and Add nri-docker integration
55+
shell: bash
56+
run: |
57+
mkdir -p integrations
58+
59+
if [ "${{ matrix.os }}" = "windows" ]; then
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"
62+
curl -L -o nri-docker.zip "$URL"
63+
unzip -j nri-docker.zip '*/nri-docker.exe' -d integrations
64+
rm nri-docker.zip
65+
elif [ "${{ matrix.os }}" = "linux" ]; then
66+
URL="https://download.newrelic.com/infrastructure_agent/binaries/linux/${{ matrix.arch }}/nri-docker_linux_${{ env.NRI_DOCKER_VERSION }}_${{ matrix.arch }}.tar.gz"
67+
echo $URL
68+
curl -L -o nri-docker.tar.gz "$URL"
69+
tar -xzf nri-docker.tar.gz --strip-components=6 -C integrations
70+
rm nri-docker.tar.gz
71+
fi
72+
4173
- name: Compile Binary
4274
run: |
43-
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build \
44-
-o ${{ matrix.binary }} \
45-
./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
4681
4782
- name: Package Artifact
4883
id: package
4984
run: |
5085
if [ "${{ matrix.os }}" = "windows" ]; then
5186
FILENAME="newrelic-infra-${{ matrix.arch }}.zip"
52-
zip $FILENAME ${{ matrix.binary }}
53-
echo "mime=application/zip" >> $GITHUB_OUTPUT
87+
zip -r $FILENAME ${{ matrix.binary }} integrations/
88+
echo "mime=application/vnd.newrelic.agent.content.v1.tar+gzip" >> $GITHUB_OUTPUT
5489
else
5590
FILENAME="newrelic-infra-${{ matrix.os }}-${{ matrix.arch }}.tar.gz"
56-
tar -cvzf $FILENAME ${{ matrix.binary }}
57-
echo "mime=application/vnd.oci.image.layer.v1.tar+gzip" >> $GITHUB_OUTPUT
91+
tar -cvzf $FILENAME ${{ matrix.binary }} integrations/
92+
echo "mime=application/vnd.newrelic.agent.content.v1.zip" >> $GITHUB_OUTPUT
5893
fi
5994
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
6095
@@ -65,9 +100,29 @@ jobs:
65100
run: |
66101
echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
67102
68-
oras push ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.AGENT_VERSION }}-${{ matrix.os }}-${{ matrix.arch }} \
103+
cat <<EOF > layer_annotations.json
104+
{
105+
"${{ steps.package.outputs.filename }}": {
106+
"org.opencontainers.image.title": "${{ steps.package.outputs.filename }}",
107+
"org.opencontainers.image.version": "${{ env.AGENT_VERSION }}",
108+
"com.newrelic.artifact.type": "package"
109+
}
110+
}
111+
EOF
112+
113+
DIGEST=$(oras push ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} \
114+
--artifact-type application/vnd.newrelic.agent.v1 \
69115
--artifact-platform ${{ matrix.os }}/${{ matrix.arch }} \
70-
${{ steps.package.outputs.filename }}:${{ steps.package.outputs.mime }}
116+
--annotation-file layer_annotations.json \
117+
${{ steps.package.outputs.filename }}:application/vnd.newrelic.agent.v1.${{ matrix.format }} | grep "Digest:" | awk '{print $2}')
118+
119+
echo "$DIGEST" > digest-${{ matrix.os }}-${{ matrix.arch }}.txt
120+
121+
- name: Upload Digest Artifact
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: digest-${{ matrix.os }}-${{ matrix.arch }}
125+
path: digest-${{ matrix.os }}-${{ matrix.arch }}.txt
71126

72127
create-index:
73128
needs: build-and-push
@@ -78,15 +133,28 @@ jobs:
78133
- name: Install ORAS
79134
uses: oras-project/setup-oras@22ce207df3b08e061f537244349aac6ae1d214f6 # v1
80135

136+
- name: Download All Digests
137+
uses: actions/download-artifact@v4
138+
with:
139+
path: digests
140+
pattern: digest-*
141+
merge-multiple: true
142+
81143
- name: Create Multi-Platform Index
82144
run: |
83145
echo "${{ secrets.GITHUB_TOKEN }}" | oras login ghcr.io -u ${{ github.actor }} --password-stdin
84146
REPO="ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}"
85147
VERSION="${{ env.AGENT_VERSION }}"
148+
149+
# Combine all downloaded digests into a single string for the command
150+
# Each entry looks like REPO@sha256:xxxx
151+
DIGEST_LIST=""
152+
for f in digests/*.txt; do
153+
D=$(cat "$f")
154+
DIGEST_LIST="$DIGEST_LIST $REPO@$D"
155+
done
156+
157+
echo "Creating index for: $DIGEST_LIST"
86158
87-
oras manifest index create $REPO:v$VERSION \
88-
$REPO:$VERSION-linux-amd64 \
89-
$REPO:$VERSION-linux-arm64 \
90-
$REPO:$VERSION-windows-amd64 \
91-
$REPO:$VERSION-darwin-arm64 \
92-
$REPO:$VERSION-darwin-amd64
159+
# Create the single tagged index pointing to all anonymous platform manifests
160+
oras manifest index create $REPO:v$VERSION $DIGEST_LIST

0 commit comments

Comments
 (0)