Skip to content

Commit 6810324

Browse files
author
Marshall Cottrell
authoredJul 29, 2024··
feat: add task for determining target repo based on flavor (#188)
1 parent 91515ef commit 6810324

File tree

3 files changed

+66
-17
lines changed

3 files changed

+66
-17
lines changed
 

‎tasks/publish.yaml

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
includes:
2+
- utils: https://raw.githubusercontent.com/defenseunicorns/uds-common/7d5f445a50b19e97b9a8bed0d2445654ae05bab6/tasks/utils.yaml
3+
4+
variables:
5+
- name: FLAVOR
6+
default: upstream
7+
18
tasks:
29
- name: package
310
description: Publish package for the supplied architecture
@@ -11,13 +18,16 @@ tasks:
1118
architecture:
1219
description: The architecture of the package to publish
1320
default: ${UDS_ARCH}
14-
target_repo:
15-
description: The repository to publish into
16-
default: ghcr.io/defenseunicorns/packages/uds
21+
team:
22+
description: The team publishing the package
23+
default: uds
1724
actions:
25+
- task: utils:determine-repo
26+
with:
27+
team: ${{.inputs.team}}
1828
- description: Publish package for the supplied architecture
1929
cmd: |
20-
./uds zarf package publish ${{ .inputs.path }}/zarf-package-*-${{ .inputs.architecture }}-${{ .inputs.version }}.tar.zst oci://${{ .inputs.target_repo }}
30+
./uds zarf package publish ${{ .inputs.path }}/zarf-package-*-${{ .inputs.architecture }}-${{ .inputs.version }}.tar.zst oci://${TARGET_REPO}
2131
2232
- name: test-bundle
2333
description: Publish bundle for the supplied architecture
@@ -31,10 +41,8 @@ tasks:
3141
architecture:
3242
description: The architecture of the bundle to publish
3343
default: ${UDS_ARCH}
34-
target_repo:
35-
description: The repository to publish into
36-
default: ghcr.io/defenseunicorns/packages/uds/bundles
3744
actions:
45+
- task: utils:determine-repo
3846
- description: Publish bundle for the supplied architecture
3947
cmd: |
40-
./uds publish ${{ .inputs.path }}/uds-bundle-*-${{ .inputs.architecture }}-${{ .inputs.version }}.tar.zst oci://${{ .inputs.target_repo }} --no-progress
48+
./uds publish ${{ .inputs.path }}/uds-bundle-*-${{ .inputs.architecture }}-${{ .inputs.version }}.tar.zst oci://${TARGET_REPO}/bundles --no-progress

‎tasks/pull.yaml

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
includes:
2+
- utils: https://raw.githubusercontent.com/defenseunicorns/uds-common/7d5f445a50b19e97b9a8bed0d2445654ae05bab6/tasks/utils.yaml
3+
14
variables:
25
- name: FLAVOR
36
default: upstream
4-
- name: TARGET_REPO
5-
default: ghcr.io/defenseunicorns/packages/uds
67

78
tasks:
89
- name: latest-package-release
@@ -13,20 +14,23 @@ tasks:
1314
spoof_release:
1415
description: Whether to spoof the pulled package version to the current repo version
1516
default: "false"
16-
target_repo:
17-
description: The repository to pull from
18-
default: ghcr.io/defenseunicorns/packages/uds
17+
team:
18+
description: The team you want to pull the package from
19+
default: uds
1920
actions:
21+
- task: utils:determine-repo
22+
with:
23+
team: ${{.inputs.team}}
2024
- description: Get the current Zarf package name
2125
cmd: cat ${{ .inputs.path }}/zarf.yaml | yq .metadata.name
2226
setVariables:
2327
- name: PACKAGE_NAME
2428
- description: Get latest tag version from OCI
25-
cmd: ./uds zarf tools registry ls ${{ .inputs.target_repo }}/${PACKAGE_NAME} | grep ${FLAVOR} | sort -V | tail -1
29+
cmd: ./uds zarf tools registry ls ${TARGET_REPO}/${PACKAGE_NAME} | grep ${FLAVOR} | sort -V | tail -1
2630
setVariables:
2731
- name: LATEST_VERSION
2832
- description: Pull the latest package release
29-
cmd: ./uds zarf package pull oci://${{ .inputs.target_repo }}/${PACKAGE_NAME}:${LATEST_VERSION} --no-progress -o ${{ .inputs.path }}
33+
cmd: ./uds zarf package pull oci://${TARGET_REPO}/${PACKAGE_NAME}:${LATEST_VERSION} --no-progress -o ${{ .inputs.path }}
3034
# TODO (@WSTARR): This is currently needed to get around the chicken+egg condition when release please updates the version in GH
3135
- description: Spoof the latest release to the current version
3236
cmd: |
@@ -47,16 +51,17 @@ tasks:
4751
description: The repository to pull from
4852
default: ghcr.io/defenseunicorns/packages/uds/bundles
4953
actions:
54+
- task: utils:determine-repo
5055
- description: Get the current uds bundle name
5156
cmd: cat ${{ .inputs.path }}/uds-bundle.yaml | yq .metadata.name
5257
setVariables:
5358
- name: BUNDLE_NAME
5459
- description: Get latest tag version from OCI
55-
cmd: ./uds zarf tools registry ls ${{ .inputs.target_repo }}/${BUNDLE_NAME} | sort -V | tail -1
60+
cmd: ./uds zarf tools registry ls ${TARGET_REPO}/bundles/${BUNDLE_NAME} | sort -V | tail -1
5661
setVariables:
5762
- name: LATEST_VERSION
5863
- description: Pull the latest bundle release
59-
cmd: ./uds pull oci://${{ .inputs.target_repo }}/${BUNDLE_NAME}:${LATEST_VERSION} --no-progress -o ${{ .inputs.path }}
64+
cmd: ./uds pull oci://${TARGET_REPO}/bundles/${BUNDLE_NAME}:${LATEST_VERSION} --no-progress -o ${{ .inputs.path }}
6065
# TODO (@ZMILLER): This is currently needed to get around the chicken+egg condition when release please updates the version in GH
6166
- description: Spoof the latest release to the current version
6267
cmd: |

‎tasks/utils.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
variables:
2+
- name: FLAVOR
3+
default: upstream
4+
5+
tasks:
6+
- name: determine-repo
7+
inputs:
8+
base_repo:
9+
description: The base repository to publish into
10+
default: ghcr.io/defenseunicorns/packages
11+
team:
12+
description: The team publishing the package
13+
default: uds
14+
flavor:
15+
description: The flavor of the package to publish
16+
default: ${FLAVOR}
17+
snapshot:
18+
description: Whether this is a snapshot release
19+
default: "false"
20+
actions:
21+
- description: Determine repository for the given flavor/type of release
22+
cmd: |
23+
repo="${{.inputs.base_repo}}"
24+
# unicorn flavor = private repository
25+
if [ "${{.inputs.flavor}}" = "unicorn" ]; then
26+
repo="${repo}/private"
27+
fi
28+
repo="${repo}/${{.inputs.team}}"
29+
# snapshots = snapshot repository
30+
if [ "${{.inputs.snapshot}}" = "true" ]; then
31+
repo="${repo}/snapshots"
32+
fi
33+
echo "${repo}"
34+
mute: true
35+
setVariables:
36+
- name: TARGET_REPO

0 commit comments

Comments
 (0)
Please sign in to comment.