-
Notifications
You must be signed in to change notification settings - Fork 54
155 lines (132 loc) · 5.39 KB
/
update-sdk.yaml
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
name: "Build updated SDK container"
on:
workflow_dispatch:
inputs:
source_sdk_version:
type: string
required: false
description: |
Source SDK container to use. Defaults to version defined in version.txt.
custom_sdk_version:
type: string
required: false
description: |
Custom SDK container version to build. Defaults to source SDK w/ "-github-[DATE]" appended.
workflow_call:
outputs:
sdk_version:
description: "The version of the SDK container that was built"
value: ${{ jobs.update_sdk.outputs.sdk_version }}
inputs:
source_sdk_version:
type: string
required: false
description: |
Source SDK container to use. Defaults to version defined in version.txt.
custom_sdk_version:
type: string
required: false
description: |
Custom SDK container version to build. Defaults to source SDK w/ "-github-[DATE]" appended, or
'-github-pr-[PRNUM]-[DATE]' if the build was triggered from a PR.
permissions:
pull-requests: write
jobs:
update_sdk:
name: "Build an updated SDK container image"
runs-on:
- self-hosted
- debian
- build
- x64
strategy:
fail-fast: false
outputs:
sdk_version: ${{ steps.step4.outputs.sdk_version }}
defaults:
run:
working-directory: scripts
steps:
- name: Prepare machine
id: step1
shell: bash
working-directory: ${{ github.workspace }}
run: |
sudo rm /bin/sh
sudo ln -s /bin/bash /bin/sh
sudo apt-get install -y ca-certificates curl gnupg lsb-release qemu-user-static git jq openssh-client rsync zstd
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
- uses: actions/checkout@v4
id: step2
with:
path: scripts
fetch-depth: 0
- name: Set environment
id: step3
shell: bash
run: |
if [ -n "${{ github.event.inputs.source_sdk_version }}" ] ; then
echo "SOURCE_SDK_VERSION=${{ github.event.inputs.source_sdk_version }}" >> $GITHUB_ENV
fi
if [ -n "${{ github.event.inputs.custom_sdk_version }}" ] ; then
echo "CUSTOM_SDK_VERSION=${{ github.event.inputs.custom_sdk_version }}" >> $GITHUB_ENV
fi
- name: Build an updated SDK container
id: step4
shell: bash
run: |
exec 2>&1
set -x
set -euo pipefail
source ci-automation/ci_automation_common.sh
source sdk_container/.repo/manifests/version.txt
version="alpha-$FLATCAR_VERSION_ID"
sdk_version="${SOURCE_SDK_VERSION:-$FLATCAR_SDK_VERSION}"
sdk_name="flatcar-sdk-all"
docker_sdk_vernum="$(vernum_to_docker_image_version "${sdk_version}")"
docker_image_from_registry_or_buildcache "${sdk_name}" "${docker_sdk_vernum}"
sdk_image="$(docker_image_fullname "${sdk_name}" "${docker_sdk_vernum}")"
# Create version file
(
source sdk_lib/sdk_container_common.sh
create_versionfile "$sdk_version" "$version"
)
if [ -z "${CUSTOM_SDK_VERSION:-}" ] ; then
if [ -n "${{ github.event.issue.pull_request }}" ] ; then
target_version="${sdk_version}-github-PR-${{ github.event.issue.number }}-$(date '+%Y_%m_%d__%H_%M_%S')"
else
target_version="${sdk_version}-github-$(date '+%Y_%m_%d__%H_%M_%S')"
fi
else
target_version="${CUSTOM_SDK_VERSION}"
fi
echo "setting sdk_version=${target_version} as a github output"
echo "sdk_version=${target_version}" >> "$GITHUB_OUTPUT"
# This also updates sdk_container/.repo/manifests/version.txt with the new SDK version.
./update_sdk_container_image "${target_version}"
- name: Upload the SDK container and binary packages to bincache
id: step5
shell: bash
run: |
set -euo pipefail
source ci-automation/ci_automation_common.sh
mkdir -p ~/.ssh
trap 'rm -f ~/.ssh/bincache' EXIT
echo "${{ secrets.BINCACHESSH }}" > ~/.ssh/bincache
chmod 600 ~/.ssh/bincache
echo "Host ${BUILDCACHE_SERVER}" >> ~/.ssh/config
echo " User ${BUILDCACHE_USER}" >> ~/.ssh/config
echo " IdentityFile ~/.ssh/bincache" >> ~/.ssh/config
source sdk_container/.repo/manifests/version.txt
vernum="${FLATCAR_SDK_VERSION}"
docker_vernum="$(vernum_to_docker_image_version "${vernum}")"
docker_image_to_buildcache "${CONTAINER_REGISTRY}/flatcar-sdk-all" "${docker_vernum}"
docker_image_to_buildcache "${CONTAINER_REGISTRY}/flatcar-sdk-amd64" "${docker_vernum}"
docker_image_to_buildcache "${CONTAINER_REGISTRY}/flatcar-sdk-arm64" "${docker_vernum}"
rm -f ~/.ssh/bincache