From f01644a565a160e0c55d2e3941c7520e651f35b3 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 9 Oct 2020 11:06:55 -0500 Subject: [PATCH] Fix the downstream build and release process (#259) * Issue #254: Fix 'unbound variable' error with empty array. * Issue #254: Make downstream-release work completely. * Make sed commands cross-platform. --- Makefile | 2 +- README.md | 8 ++++++-- utils/downstream.sh | 33 ++++++++++++++++++--------------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 0e07e105..0924e2cd 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Also needs to be updated in galaxy.yml -VERSION = 1.0.0 +VERSION = 1.1.0 TEST_ARGS ?= "" PYTHON_VERSION ?= `python -c 'import platform; print("{0}.{1}".format(platform.python_version_tuple()[0], platform.python_version_tuple()[1]))'` diff --git a/README.md b/README.md index bd1d5735..6292acb6 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,11 @@ There are also integration tests in the `molecule` directory which are meant to Releases are automatically built and pushed to Ansible Galaxy for any new tag. Before tagging a release, make sure to do the following: - 1. Update `galaxy.yml` and this README's `requirements.yml` example with the new `version` for the collection. + 1. Update the version in the following places: + a. The `version` in `galaxy.yml` + b. This README's `requirements.yml` example + c. The `DOWNSTREAM_VERSION` in `utils/downstream.sh` + d. The `VERSION` in `Makefile` 1. Update the CHANGELOG: 1. Make sure you have [`antsibull-changelog`](https://pypi.org/project/antsibull-changelog/) installed. 1. Make sure there are fragments for all known changes in `changelogs/fragments`. @@ -168,7 +172,7 @@ Until the contents of repository are moved into a new `kubernetes.core` reposito To publish the `kubernetes.core` collection on Ansible Galaxy, do the following: - 1. Run `make downstream-release`. + 1. Run `make downstream-release` (on macOS, add `LC_ALL=C` before the command). The process for uploading a supported release to Automation Hub is documented separately. diff --git a/utils/downstream.sh b/utils/downstream.sh index eac38ba4..6418001e 100755 --- a/utils/downstream.sh +++ b/utils/downstream.sh @@ -9,7 +9,7 @@ # - All functions are prefixed with f_ so it's obvious where they come # from when in use throughout the script -DOWNSTREAM_VERSION="1.0.0" +DOWNSTREAM_VERSION="1.1.0" KEEP_DOWNSTREAM_TMPDIR="${KEEP_DOWNSTREAM_TMPDIR:-''}" @@ -64,14 +64,15 @@ f_show_help() f_text_sub() { # Switch FQCN and dependent components - sed -i "s/community-kubernetes/kubernetes-core/" "${_build_dir}/Makefile" - sed -i "s/community\/kubernetes/kubernetes\/core/" "${_build_dir}/Makefile" - sed -i "s/^VERSION\:/VERSION: ${DOWNSTREAM_VERSION}/" "${_build_dir}/Makefile" - sed -i "s/community.kubernetes/kubernetes.core/" "${_build_dir}/galaxy.yml" - sed -i "s/name\:.*$/name: core/" "${_build_dir}/galaxy.yml" - sed -i "s/namespace\:.*$/namespace: kubernetes/" "${_build_dir}/galaxy.yml" - sed -i "s/^version\:.*$/version: ${DOWNSTREAM_VERSION}/" "${_build_dir}/galaxy.yml" - find "${_build_dir}" -type f -exec sed -i "s/community\.kubernetes/kubernetes\.core/g" {} \; + sed -i.bak "s/community-kubernetes/kubernetes-core/" "${_build_dir}/Makefile" + sed -i.bak "s/community\/kubernetes/kubernetes\/core/" "${_build_dir}/Makefile" + sed -i.bak "s/^VERSION\:/VERSION: ${DOWNSTREAM_VERSION}/" "${_build_dir}/Makefile" + sed -i.bak "s/community.kubernetes/kubernetes.core/" "${_build_dir}/galaxy.yml" + sed -i.bak "s/name\:.*$/name: core/" "${_build_dir}/galaxy.yml" + sed -i.bak "s/namespace\:.*$/namespace: kubernetes/" "${_build_dir}/galaxy.yml" + sed -i.bak "s/^version\:.*$/version: ${DOWNSTREAM_VERSION}/" "${_build_dir}/galaxy.yml" + find "${_build_dir}" -type f -exec sed -i.bak "s/community\.kubernetes/kubernetes\.core/g" {} \; + find "${_build_dir}" -type f -name "*.bak" -delete } f_cleanup() @@ -103,12 +104,14 @@ f_create_collection_dir_structure() do cp -r "./${d_name}" "${_build_dir}/${d_name}" done - for exclude_file in "${_file_exclude[@]}"; - do - if [[ -f "${_build_dir}/${exclude_file}" ]]; then - rm -f "${_build_dir}/${exclude_file}" - fi - done + if [ -n "${_file_exclude:-}" ]; then + for exclude_file in "${_file_exclude[@]}"; + do + if [[ -f "${_build_dir}/${exclude_file}" ]]; then + rm -f "${_build_dir}/${exclude_file}" + fi + done + fi } f_copy_collection_to_working_dir()