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

Create AWX Operator version file #24

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# This Makefile is created with the clone-awx-operator.py script.
include Makefile.awx-operator

AWX_VERSION := $(shell cat awx-operator-version.txt)

# GNU vs BSD in-place sed
ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu)
SED_I := sed -i
Expand Down Expand Up @@ -124,7 +126,7 @@ helm-chart-generate: kustomize helm kubectl-slice yq charts
# create new chart metadata in Chart.yaml
cd charts && \
$(HELM) create $(CHART_NAME) --starter $(shell pwd)/.helm/starter ;\
$(YQ) -i '.version = "$(VERSION)"' $(CHART_NAME)/Chart.yaml ;\
$(YQ) -i '.version = "$(AWX_VERSION)"' $(CHART_NAME)/Chart.yaml ;\
$(YQ) -i '.appVersion = "$(VERSION)" | .appVersion style="double"' $(CHART_NAME)/Chart.yaml ;\
$(YQ) -i '.description = "$(CHART_DESCRIPTION)"' $(CHART_NAME)/Chart.yaml ;\

Expand Down Expand Up @@ -176,7 +178,7 @@ helm-chart-generate: kustomize helm kubectl-slice yq charts
# create and populate NOTES.txt
@echo "AWX Operator installed with Helm Chart version $(VERSION)" > charts/$(CHART_NAME)/templates/NOTES.txt

@echo "Helm chart successfully configured for $(CHART_NAME) version $(VERSION)"
@echo "Helm chart successfully configured for $(CHART_NAME) version $(AWX_VERSION)"


.PHONY: helm-package
Expand Down
1 change: 1 addition & 0 deletions awx-operator-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.19.1
24 changes: 21 additions & 3 deletions clone-awx-operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@
import sys
import tempfile

DEFAULT_BRANCH = "devel"

def read_version_from_file(file_path):
try:
with open(file_path, "r") as file:
version = file.read().strip()
return version
except FileNotFoundError:
print(f"Error: '{file_path}' not found.")


awx_version = read_version_from_file(file_path="awx-operator-version.txt")

DEFAULT_BRANCH = awx_version
DEFAULT_AWX_OPERATOR_REPO = "https://github.com/ansible/awx-operator"


Expand Down Expand Up @@ -65,7 +77,13 @@ def main(args: Args) -> None:
]

with tempfile.TemporaryDirectory() as temp_dir:
cmd: list[str] = ["git", "clone", args.repo, "--depth=1"]
cmd: list[str] = [
"git",
"clone",
args.repo,
"--depth=1",
"-c advice.detachedHead=false",
]
if args.branch is not None:
cmd.append(f"--branch={args.branch}")
cmd.append(temp_dir)
Expand All @@ -86,7 +104,7 @@ def main(args: Args) -> None:

for keep_file in keep_files:
src = pathlib.Path(temp_dir, keep_file)
if keep_file == 'Makefile':
if keep_file == "Makefile":
dst = pathlib.Path.cwd() / "Makefile.awx-operator"
else:
dst = pathlib.Path.cwd() / keep_file
Expand Down