Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add latest-bundle-release task #97

Merged
merged 5 commits into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions tasks/pull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,54 @@ tasks:
spoof_release:
description: Whether to spoof the pulled package version to the current repo version
default: "false"
target_repo:
description: The repository to pull from
default: ghcr.io/defenseunicorns/packages/uds
actions:
- description: Get the current Zarf package name
cmd: cat zarf.yaml | yq .metadata.name
cmd: cat ${{ .inputs.path }}/zarf.yaml | yq .metadata.name
setVariables:
- name: PACKAGE_NAME
- description: Get latest tag version from OCI
cmd: ./uds zarf tools registry ls ${TARGET_REPO}/${PACKAGE_NAME} | grep ${FLAVOR} | sort -V | tail -1
cmd: ./uds zarf tools registry ls ${{ .inputs.target_repo }}/${PACKAGE_NAME} | grep ${FLAVOR} | sort -V | tail -1
setVariables:
- name: LATEST_VERSION
- description: Pull the latest package release
cmd: ./uds zarf package pull oci://${TARGET_REPO}/${PACKAGE_NAME}:${LATEST_VERSION} --no-progress -o ${{ .inputs.path }}
cmd: ./uds zarf package pull oci://${{ .inputs.target_repo }}/${PACKAGE_NAME}:${LATEST_VERSION} --no-progress -o ${{ .inputs.path }}
# TODO (@WSTARR): This is currently needed to get around the chicken+egg condition when release please updates the version in GH
- description: Spoof the latest release to the current version
cmd: |
if [ ${{ .inputs.spoof_release }} != "false" ]; then
CURRENT_VERSION=$(cat zarf.yaml | yq .metadata.version)
CURRENT_PKG_NAME=$(cat zarf.yaml | yq .metadata.name)
test -f zarf-package-${CURRENT_PKG_NAME}-${UDS_ARCH}-${CURRENT_VERSION}.tar.zst || mv zarf-package-${CURRENT_PKG_NAME}-${UDS_ARCH}-*.tar.zst zarf-package-${CURRENT_PKG_NAME}-${UDS_ARCH}-${CURRENT_VERSION}.tar.zst
CURRENT_VERSION=$(cat ${{ .inputs.path }}/zarf.yaml | yq .metadata.version)
test -f ${{ .inputs.path }}/zarf-package-${PACKAGE_NAME}-${UDS_ARCH}-${CURRENT_VERSION}.tar.zst || mv ${{ .inputs.path }}/zarf-package-${PACKAGE_NAME}-${UDS_ARCH}-*.tar.zst ${{ .inputs.path }}/zarf-package-${PACKAGE_NAME}-${UDS_ARCH}-${CURRENT_VERSION}.tar.zst
fi

- name: latest-bundle-release
inputs:
path:
description: Path relative to the repositories root where the bundle things happen
default: .
spoof_release:
description: Whether to spoof the pulled bundle version to the current repo version
default: "false"
target_repo:
description: The repository to pull from
default: ghcr.io/defenseunicorns/packages/uds/bundles
actions:
- description: Get the current uds bundle name
cmd: cat ${{ .inputs.path }}/uds-bundle.yaml | yq .metadata.name
setVariables:
- name: BUNDLE_NAME
- description: Get latest tag version from OCI
cmd: ./uds zarf tools registry ls ${{ .inputs.target_repo }}/${BUNDLE_NAME} | sort -V | tail -1
setVariables:
- name: LATEST_VERSION
- description: Pull the latest bundle release
cmd: ./uds pull oci://${{ .inputs.target_repo }}/${BUNDLE_NAME}:${LATEST_VERSION} --no-progress -o ${{ .inputs.path }}
# TODO (@ZMILLER): This is currently needed to get around the chicken+egg condition when release please updates the version in GH
- description: Spoof the latest release to the current version
cmd: |
if [ ${{ .inputs.spoof_release }} != "false" ]; then
CURRENT_VERSION=$(cat ${{ .inputs.path }}/uds-bundle.yaml | yq .metadata.version)
test -f ${{ .inputs.path }}/uds-bundle-${BUNDLE_NAME}-${UDS_ARCH}-${CURRENT_VERSION}.tar.zst || mv ${{ .inputs.path }}/uds-bundle-${BUNDLE_NAME}-${UDS_ARCH}-*.tar.zst ${{ .inputs.path }}/uds-bundle-${BUNDLE_NAME}-${UDS_ARCH}-${CURRENT_VERSION}.tar.zst
fi