Skip to content

Commit d9c93d2

Browse files
authored
feat(ci): decouple cpc build tools (#671)
* feat(ci): decouple with cpc_build_tools * chore(deps): bump skopeo version to 1.20.0 * chore: bump skopeo runner to 24.04
1 parent 6dd1513 commit d9c93d2

9 files changed

Lines changed: 75 additions & 46 deletions

File tree

.github/actions/upload-rock/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ runs:
4848
run: |
4949
docker run --rm \
5050
-v $PWD:/workdir -w /workdir \
51-
"quay.io/skopeo/stable:v1.15.1" \
51+
"quay.io/skopeo/stable:v1.20.0" \
5252
inspect oci-archive:${{ inputs.artifact_name }} > metadata.json
5353
5454
digest="$(cat metadata.json | jq -r .Digest)"
@@ -60,7 +60,7 @@ runs:
6060
for tag in ${{ inputs.tags }}; do
6161
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
6262
-v $PWD:/workdir -w /workdir \
63-
"quay.io/skopeo/stable:v1.15.1" \
63+
"quay.io/skopeo/stable:v1.20.0" \
6464
copy \
6565
--dest-username "${{ inputs.username }}" \
6666
--dest-password "${{ inputs.password }}" \

.github/workflows/Image.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ jobs:
194194
secrets: inherit
195195

196196
prepare-upload:
197-
runs-on: ubuntu-22.04
197+
runs-on: ubuntu-24.04
198198
needs: [prepare-build, build-rock, test-rock]
199199
name: Prepare upload
200200
if: ${{ inputs.upload || (github.ref_name == 'main' && github.event_name == 'push') }}
@@ -276,7 +276,7 @@ jobs:
276276
key: ${{ steps.prepare-matrix.outputs.revision-data-cache-key }}
277277

278278
upload:
279-
runs-on: ubuntu-22.04
279+
runs-on: ubuntu-24.04
280280
needs: [prepare-build, prepare-upload]
281281
name: Upload
282282
strategy:
@@ -301,7 +301,7 @@ jobs:
301301
ROCKS_DEV_LP_USERNAME: ${{ secrets.ROCKS_DEV_LP_USERNAME }}
302302
CPC_BUILD_TOOLS_REPO: git.launchpad.net/~cloudware/cloudware/+git/cpc_build_tools
303303
# CPC_BUILD_TOOLS_REPO_REF: 9b716ed8a8ba728d036b54b1bb17a8f49dbda434
304-
SKOPEO_BRANCH: "v1.9.1"
304+
SKOPEO_BRANCH: "v1.20.0"
305305
SKOPEO_URL: "https://github.com/containers/skopeo"
306306
run: |
307307
./src/image/requirements.sh

.github/workflows/Release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
7575
7676
do-releases:
77-
runs-on: ubuntu-22.04
77+
runs-on: ubuntu-24.04
7878
name: Release
7979
needs: [validate-push-release-request]
8080
outputs:
@@ -109,7 +109,7 @@ jobs:
109109
ROCKS_DEV_LP_USERNAME: ${{ secrets.ROCKS_DEV_LP_USERNAME }}
110110
CPC_BUILD_TOOLS_REPO: git.launchpad.net/~cloudware/cloudware/+git/cpc_build_tools
111111
# CPC_BUILD_TOOLS_REPO_REF: 9b716ed8a8ba728d036b54b1bb17a8f49dbda434
112-
SKOPEO_BRANCH: 'v1.9.1'
112+
SKOPEO_BRANCH: 'v1.20.0'
113113
SKOPEO_URL: 'https://github.com/containers/skopeo'
114114
run: |
115115
./src/image/requirements.sh

.github/workflows/Test-Rock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ env:
5959
VULNERABILITY_REPORT_SUFFIX: ".vulnerability-report.json" # TODO: inherit string from caller
6060
TEST_IMAGE_NAME: "test-img"
6161
TEST_IMAGE_TAG: "test"
62-
SKOPEO_IMAGE: "quay.io/skopeo/stable:v1.15.1"
62+
SKOPEO_IMAGE: "quay.io/skopeo/stable:v1.20.0"
6363
UMOCI_VERSION: "v0.4.7"
6464
UMOCI_BINARY: "umoci.amd64"
6565
DIVE_IMAGE: "wagoodman/dive:v0.12"

.github/workflows/Vulnerability-Scan.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ on:
2929

3030
env:
3131
VULNERABILITY_REPORT_SUFFIX: '.vulnerability-report.json' # TODO: inherit string from caller
32-
SKOPEO_IMAGE: 'quay.io/skopeo/stable:v1.15.1'
32+
SKOPEO_IMAGE: 'quay.io/skopeo/stable:v1.20.0'
3333

3434
jobs:
3535
configure-scan:

src/image/requirements.sh

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,13 @@
11
#!/bin/bash -e
22

3-
# LP configurations
4-
mkdir -p $HOME/.ssh
5-
chmod 700 $HOME/.ssh
6-
7-
ssh-keyscan -H git.launchpad.net | tee $HOME/.ssh/known_hosts
8-
9-
echo "${ROCKS_DEV_LP_SSH_PRIVATE}" >$HOME/.ssh/id_rsa
10-
11-
if [[ "$RUNNER_DEBUG" == "1" ]]; then
12-
set -x
13-
fi
14-
chmod 600 $HOME/.ssh/id_rsa
15-
16-
## To avoid installing Snaps, just take the needed Python script
17-
## for later tagging and publishing rocks
18-
git init /tmp/cpc-build-tools
19-
pushd /tmp/cpc-build-tools
20-
git remote add origin git+ssh://${ROCKS_DEV_LP_USERNAME}@${CPC_BUILD_TOOLS_REPO}
21-
# using main instead of ${CPC_BUILD_TOOLS_REPO_REF} because of an unexpected
22-
# new issue with Launchpad:
23-
# error: Server does not allow request for unadvertised object 9b716ed8a8ba728d036b54b1bb17a8f49dbda434
24-
git fetch --depth 1 origin devel # ${CPC_BUILD_TOOLS_REPO_REF}
25-
git checkout FETCH_HEAD
26-
27-
sudo mv /tmp/cpc-build-tools/* /usr/local/bin/
28-
sudo chmod +x /usr/local/bin/oci_registry_upload.py
29-
ln -s oci_registry_upload.py /usr/local/bin/cpc-build-tools.oci-registry-upload
30-
popd
31-
##
32-
333
## Install Skopeo
344
git clone -b ${SKOPEO_BRANCH} --depth 1 ${SKOPEO_URL} /tmp/skopeo
355
pushd /tmp/skopeo
366

377
docker run -v $PWD:/src -w /src -e DISABLE_DOCS=1 \
38-
golang:1.18 sh -c 'apt update; apt install -y libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config; make'
8+
golang:1.25 sh -c \
9+
'apt update; apt install -y libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config; \
10+
git config --global --add safe.directory /src; make'
3911

4012
sudo mv bin/skopeo /usr/local/bin/
4113
sudo chmod +x /usr/local/bin/skopeo

src/image/tag_and_publish.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -ex
22

3-
source $(dirname $0)/../shared/logs.sh
3+
source "$(dirname "$0")/../shared/logs.sh"
44

55
# SUITE="{{ suite }}"
66
# RELEASE="{{ release }}"
@@ -21,14 +21,14 @@ source_img="${1}"
2121
image_name="${2}"
2222
shift 2
2323
# The tag names are handled by the CI
24-
tag_names=($@)
24+
tag_names=("$@")
2525

2626
publish_with_auth_token()
2727
{
2828
local token=$1 name=$2
2929
shift 2
3030
log_info "Publishing to Docker registry repository $name ..."
31-
REGISTRY_AUTH=$token cpc-build-tools.oci-registry-upload \
31+
REGISTRY_AUTH=$token "$(dirname "$0")/../uploads/oci_registry_upload.py" \
3232
"${source_img}" "$name" "$@"
3333
log_info "Publishing to Docker registry repository $name finished"
3434
}
@@ -95,7 +95,7 @@ acr_repo_name="${ACR_NAMESPACE}/${image_name}"
9595
ecr_repo_name="${ECR_NAMESPACE}/${image_name}"
9696
# ecr_lts_repo_name="${ECR_LTS_NAMESPACE}/${image_name}"
9797

98-
log_info "Publishing ${image_name} to registries with tags: ${tag_names[@]}"
98+
log_info "Publishing ${image_name} to registries with tags: ${tag_names[*]}"
9999

100100
trace_suspend
101101
if [ ! -z $GHCR_REPO ]; then

src/tests/get_released_revisions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
form and return a list of image names in their canonical format, i.e.:
66
ghcr.io/canonical/oci-factory/<img-name>:<canonical-track>_<revision>
77
...
8-
8+
99
TODO: this script could eventually be adjusted and converted to a Temporal
1010
Activity that runs from within a scheduled workflow.
1111
"""
@@ -20,7 +20,7 @@
2020

2121
from ..shared.logs import get_logger
2222

23-
SKOPEO_IMAGE = os.getenv("SKOPEO_IMAGE", "quay.io/skopeo/stable:v1.15.1")
23+
SKOPEO_IMAGE = os.getenv("SKOPEO_IMAGE", "quay.io/skopeo/stable:v1.20.0")
2424
REGISTRY = "ghcr.io/canonical/oci-factory"
2525

2626
logger = get_logger(stream=sys.stdout, level="INFO")

src/uploads/oci_registry_upload.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import json
5+
import os
6+
import os.path
7+
import sys
8+
import tempfile
9+
from pathlib import Path
10+
from subprocess import check_call
11+
12+
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
13+
14+
from shared.logs import get_logger
15+
16+
logger = get_logger()
17+
18+
19+
def parse_args():
20+
argp = argparse.ArgumentParser(description=__doc__)
21+
argp.add_argument("source_uri")
22+
argp.add_argument("target_name")
23+
argp.add_argument("target_tags", nargs="+")
24+
argp.add_argument("--registry-auth")
25+
args = argp.parse_args()
26+
if not args.registry_auth:
27+
args.registry_auth = os.getenv("REGISTRY_AUTH")
28+
return args
29+
30+
31+
def main():
32+
args = parse_args()
33+
base_cmd = ["skopeo", "copy", "--preserve-digests", args.source_uri]
34+
35+
with tempfile.TemporaryDirectory() as tmp_dir:
36+
if args.registry_auth:
37+
auth_config = {"auths": {args.target_name: {"auth": args.registry_auth}}}
38+
auth_file = os.path.join(tmp_dir, "auth.json")
39+
with open(auth_file, "w") as f:
40+
os.fchmod(f.fileno(), 0o600)
41+
json.dump(auth_config, f)
42+
base_cmd += ["--authfile", auth_file]
43+
44+
target_uri = "docker://" + args.target_name + ":" + args.target_tags[0]
45+
cmd = base_cmd + ["--multi-arch", "all", target_uri]
46+
logger.info(" ".join(cmd))
47+
check_call(cmd)
48+
49+
for tag in args.target_tags[1:]:
50+
target_uri = "docker://" + args.target_name + ":" + tag
51+
cmd = base_cmd + ["--multi-arch", "index-only", target_uri]
52+
logger.info(" ".join(cmd))
53+
check_call(cmd)
54+
55+
56+
if __name__ == "__main__":
57+
main()

0 commit comments

Comments
 (0)