-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathupgrade.yaml
108 lines (87 loc) · 4.1 KB
/
upgrade.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
# Copyright 2024 Defense Unicorns
# SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial
includes:
- utils: ./utils.yaml
variables:
- name: FLAVOR
default: upstream
- name: BASE_REPO
tasks:
- name: create-latest-tag-bundle
description: Creates the test bundle at the latest tag in preparation for upgrade testing
inputs:
options:
description: For setting create time variables and flags
default: ""
bundle_path:
description: Path relative to the repositories root where the bundle needs to go
default: bundle
path:
description: Path relative to the repositories root where the package needs to go
default: .
team:
description: The team you want to pull the package from
default: uds
architecture:
description: The architecture of the package to create
default: ${UDS_ARCH}
dep_commands:
description: Additional commands to run inside the old repo to setup dependencies
default: ""
actions:
- task: utils:determine-repo
with:
team: ${{ .inputs.team }}
base_repo: ${{ .variables.BASE_REPO }}
- description: Remove copied repo
cmd: rm -rf upgrade-test
- description: Copy repo into the upgrade-test folder
shell:
linux: bash
darwin: bash
cmd: |
mkdir upgrade-test
shopt -s extglob dotglob
cp -r !(upgrade-test) upgrade-test
shopt -u dotglob
- description: Create test bundle of last tag
shell:
linux: bash
darwin: bash
dir: upgrade-test
cmd: |
git reset --hard HEAD
BUNDLE_VERSION=$(cat ../${{ .inputs.bundle_path }}/uds-bundle.yaml | ./uds zarf tools yq .metadata.version)
TAG="$(git describe --tags "$(git rev-list --tags --max-count=1)" 2>/dev/null || echo '')"
git checkout "$TAG"
# VARIABLES
PACKAGE_NAME=$(cat ${{ .inputs.path }}/zarf.yaml | ./uds zarf tools yq .metadata.name)
LOCAL_VERSION=$(cat ${{ .inputs.path }}/zarf.yaml | ./uds zarf tools yq .metadata.version)
LATEST_VERSION=$(./uds zarf tools registry ls "${TARGET_REPO}/${PACKAGE_NAME}" | grep "${FLAVOR}" | sort -V | tail -1)
BUNDLE_NAME=$(cat ${{ .inputs.bundle_path }}/uds-bundle.yaml | ./uds zarf tools yq .metadata.name)
PREVIOUS_BUNDLE_VERSION=$(cat ${{ .inputs.bundle_path }}/uds-bundle.yaml | ./uds zarf tools yq .metadata.version)
# Pulls latest published zarf package
./uds zarf package pull \
"oci://${TARGET_REPO}/${PACKAGE_NAME}:${LATEST_VERSION}" \
--no-progress \
-o ${{ .inputs.path }}
if [ ! -e "${{ .inputs.path }}/zarf-package-${PACKAGE_NAME}-${{ .inputs.architecture }}-${LOCAL_VERSION}.tar.zst" ]; then
mv "${{ .inputs.path }}/zarf-package-${PACKAGE_NAME}-${{ .inputs.architecture }}-${LATEST_VERSION%-"${FLAVOR}"}.tar.zst" "${{ .inputs.path }}/zarf-package-${PACKAGE_NAME}-${{ .inputs.architecture }}-${LOCAL_VERSION}.tar.zst"
fi
# Run any dependency commands (i.e. uds run dependencies:create)
sh -c "${{ .inputs.dep_commands }}"
# Checks if the zarf package is registry1 and ARM
if [ "${FLAVOR}" != "registry1" ] || [ "${{ .inputs.architecture }}" != "arm64" ]; then
# Creates and moves the bundle into the correct spot
./uds create ${{ .inputs.bundle_path }} \
--architecture=${{ .inputs.architecture }} \
--confirm \
--no-progress \
${{ .inputs.options }}
mv "${{ .inputs.bundle_path }}/uds-bundle-${BUNDLE_NAME}-${{ .inputs.architecture }}-${PREVIOUS_BUNDLE_VERSION}.tar.zst" "../${{ .inputs.bundle_path }}/uds-bundle-${BUNDLE_NAME}-${{ .inputs.architecture }}-${BUNDLE_VERSION}.tar.zst"
else
echo "::warning::⚠️ Registry1 bundles cannot be made for 'arm64'"
exit 1
fi
- description: Remove the upgrade-test folder
cmd: rm -rf upgrade-test