3939 SKIP_TEST : true
4040
4141jobs :
42- # Only development images are compiled here. A release must not be rebuilt: its
43- # image has to contain the exact agent package that was signed, uploaded to
44- # dist/dev and voted on, so build-docker downloads that tarball instead.
45- build-tar :
46- if : github.repository == 'apache/skywalking-java' && github.event_name != 'release'
47- name : Build Agent
42+ # One agent package feeds every image. The variants differ only in the JRE they
43+ # sit on: the Dockerfile takes BASE_IMAGE and ADDs the same DIST directory, and
44+ # the agent itself is Java 8 bytecode that runs on all of them. So this is built
45+ # (or downloaded) exactly once and handed to the matrix below as an artifact,
46+ # rather than each variant fetching its own copy.
47+ agent-package :
48+ if : github.repository == 'apache/skywalking-java'
49+ name : Prepare Agent Package
4850 runs-on : ubuntu-latest
4951 timeout-minutes : 30
5052 steps :
5153 - uses : actions/checkout@v2
5254 with :
5355 submodules : true
56+
57+ # Development images are compiled from the branch.
5458 - name : Cache local Maven repository
59+ if : github.event_name != 'release'
5560 uses : actions/cache@v4
5661 with :
5762 path : ~/.m2/repository
5863 key : ${{ runner.os }}-maven-publish-docker-${{ hashFiles('**/pom.xml') }}
5964 restore-keys : ${{ runner.os }}-maven-publish-docker-
6065 - uses : actions/setup-java@v2
66+ if : github.event_name != 'release'
6167 with :
6268 distribution : temurin
6369 java-version : 17
6470 - name : Build Agent
71+ if : github.event_name != 'release'
6572 run : make build
73+
74+ # A release is never rebuilt. The published image has to carry the artifact
75+ # the PMC voted on, so take it from the Apache distribution area and prove
76+ # it is that one: the sha512 rules out a truncated download, and verifying
77+ # the detached signature against the project KEYS file rules out anything
78+ # the release manager did not sign. `release.sh promote` does the svn mv
79+ # from dist/dev to dist/release immediately before the GitHub Release that
80+ # triggers this workflow, so the file is in place by the time this runs.
81+ - name : Download the released agent package
82+ if : github.event_name == 'release'
83+ run : |
84+ set -euo pipefail
85+ TAG=${{ github.event.release.tag_name }}
86+ VERSION=${TAG#v}
87+ BASE="https://dist.apache.org/repos/dist/release/skywalking/java-agent/${VERSION}"
88+ TARBALL="apache-skywalking-java-agent-${VERSION}.tgz"
89+
90+ curl -fsSL --retry 5 --retry-delay 10 -O "${BASE}/${TARBALL}"
91+ curl -fsSL --retry 5 --retry-delay 10 -O "${BASE}/${TARBALL}.asc"
92+ curl -fsSL --retry 5 --retry-delay 10 -O "${BASE}/${TARBALL}.sha512"
93+
94+ sha512sum -c "${TARBALL}.sha512"
95+
96+ curl -fsSL --retry 5 --retry-delay 10 https://downloads.apache.org/skywalking/KEYS | gpg --import
97+ gpg --verify "${TARBALL}.asc" "${TARBALL}"
98+
99+ tar -xzf "${TARBALL}"
100+ # The Makefile passes this directory to the Dockerfile as ARG DIST.
101+ test -d skywalking-agent
102+
66103 - uses : actions/upload-artifact@v4
67104 name : Upload Agent
68105 with :
69106 name : skywalking-agent
70107 path : skywalking-agent
71108
72109 build-docker :
73- # build-tar is skipped on releases, and a skipped dependency would otherwise
74- # skip this job too.
75- if : |
76- always() && github.repository == 'apache/skywalking-java' &&
77- (needs.build-tar.result == 'success' || needs.build-tar.result == 'skipped')
78- needs : [ build-tar ]
110+ if : github.repository == 'apache/skywalking-java'
111+ needs : [ agent-package ]
79112 name : Build and Push Docker
80113 runs-on : ubuntu-latest
81114 permissions :
@@ -92,40 +125,10 @@ jobs:
92125 - uses : actions/checkout@v2
93126 with :
94127 submodules : true
95- - name : Download development agent package
96- if : github.event_name != 'release'
97- uses : actions/download-artifact@v4
128+ - uses : actions/download-artifact@v4
98129 with :
99130 name : skywalking-agent
100131 path : skywalking-agent
101- # The published image must carry the artifact the PMC voted on, not a
102- # rebuild of it. Take the tarball straight from the Apache distribution
103- # area and prove it is that one: the sha512 rules out a truncated download,
104- # and verifying the detached signature against the project KEYS file rules
105- # out anything the release manager did not sign. `svn mv` from dist/dev to
106- # dist/release runs in `release.sh promote`, immediately before the GitHub
107- # Release that triggers this workflow, so the file is already in place.
108- - name : Download the released agent package
109- if : github.event_name == 'release'
110- run : |
111- set -euo pipefail
112- TAG=${{ github.event.release.tag_name }}
113- VERSION=${TAG#v}
114- BASE="https://dist.apache.org/repos/dist/release/skywalking/java-agent/${VERSION}"
115- TARBALL="apache-skywalking-java-agent-${VERSION}.tgz"
116-
117- curl -fsSL --retry 5 --retry-delay 10 -O "${BASE}/${TARBALL}"
118- curl -fsSL --retry 5 --retry-delay 10 -O "${BASE}/${TARBALL}.asc"
119- curl -fsSL --retry 5 --retry-delay 10 -O "${BASE}/${TARBALL}.sha512"
120-
121- sha512sum -c "${TARBALL}.sha512"
122-
123- curl -fsSL --retry 5 --retry-delay 10 https://downloads.apache.org/skywalking/KEYS | gpg --import
124- gpg --verify "${TARBALL}.asc" "${TARBALL}"
125-
126- tar -xzf "${TARBALL}"
127- # The Makefile feeds this directory to the Dockerfile as ARG DIST.
128- test -d skywalking-agent
129132 - name : Set environment variables
130133 run : |
131134 if [[ "${{ github.event_name }}" == "release" ]]; then
0 commit comments