Commit 5815d373 authored by Vladislav Shishko (EPAM)'s avatar Vladislav Shishko (EPAM)
Browse files

Merge branch 'fix-release2' into 'master'

(GONRG-4443) fix release

See merge request !308
parents 00a2a844 855459c0
Pipeline #99816 passed with stages
in 1 minute and 8 seconds
......@@ -15,5 +15,4 @@ containerize_osdu_bootstrap_entitlements:
rules:
- if: "$CI_COMMIT_BRANCH =~ /^master$/"
- if: "$CI_COMMIT_BRANCH =~ /.*bootstrap.*/"
- if: "$CI_COMMIT_BRANCH =~ /^release/"
- if: "$CI_COMMIT_TAG"
......@@ -34,11 +34,13 @@ class TagDumper:
}
def __init__(
self,
desired_tag: str,
self,
short_tag: str,
full_tag: str,
output_filename: str
) -> None:
self._desired_tag = desired_tag
self._short_tag = short_tag
self._full_tag = full_tag
self._output_filename = output_filename
def collect_repository_version_tags(self) -> None:
......@@ -49,40 +51,41 @@ class TagDumper:
f.write('locals {\n')
for k in self.SERVICE_REPOSITORIES:
tag = self._get_tag_by_service(k, self.SERVICE_REPOSITORIES[k], self._desired_tag)
tag = self._get_tag_by_service(k, self.SERVICE_REPOSITORIES[k], self._short_tag, self._full_tag)
f.write(' {0}_tag = "{1}"\n'.format(k, tag))
f.write('}\n')
f.close()
@staticmethod
def _get_tag_by_service( service, base_url: str, tag: str) -> str:
def _get_tag_by_service( service, base_url: str, short_tag: str, full_tag: str) -> str:
"""
Fetch tag for service
"""
# for infrastructure repository final tag is not exists on this step,
# so we assume it will be equals to *tag* variable
# so we assume it will be equals to *full_tag* script argument
if base_url == 'https://community.opengroup.org/api/v4/projects/163':
return tag
return 'v{0}'.format(full_tag)
r = requests.get(base_url + '/repository/tags?search=' + tag)
r = requests.get(base_url + '/repository/tags?search=' + short_tag)
data = r.json()
if not data:
raise Exception('There is no tag {0} in service {1}'.format(tag, service))
raise Exception('There is no tag {0} in service {1}'.format(short_tag, service))
return data[0]['name']
def main():
def main():
parser = argparse.ArgumentParser(description="Release Tags Collector")
parser.add_argument("-t", "--tag", type=str, required=True, help="Short tag to collect new versions from services (e.g. 0.13)")
parser.add_argument("-st", "--short-tag", type=str, required=True, help="Short tag to collect new versions from services (e.g. 0.13)")
parser.add_argument("-ft", "--full-tag", type=str, required=True, help="Short tag to collect new versions from services (e.g. 0.13.7)")
parser.add_argument("-f", "--file", type=str, default="./modules/osdu/artifact_versions.tf", help="Path to output file (artifact_versions.tf)")
args = parser.parse_args()
td = TagDumper(desired_tag=args.tag, output_filename=args.file)
td = TagDumper(short_tag=args.short_tag, full_tag=args.full_tag, output_filename=args.file)
td.collect_repository_version_tags()
if __name__ == '__main__':
......
......@@ -18,7 +18,7 @@ collect-versions:
script:
- *define_TAG
- pip install requests
- python release.py -t ${TAG%.*} -f ${OUTPUT_FILE}
- python release.py -st ${TAG%.*} -ft ${TAG} -f ${OUTPUT_FILE}
- terraform fmt ${OUTPUT_FILE}
artifacts:
paths:
......@@ -42,10 +42,11 @@ make-release-merge-request:
script:
- *define_TAG
- SHORT_TAG=${TAG%.*}
- git checkout -b release/$SHORT_TAG
- TIMESTAMP=$(date '+%Y-%m-%d-T%H-%M-%S')
- git checkout -b auto_release_${TIMESTAMP}
- git add -A
- git commit -m "auto-release for $TAG"
- git push -o ci.skip -o merge_request.create -o merge_request.target=release/$SHORT_TAG -o merge_request.title="Auto-release for $TAG" -o merge_request.label="GCP" -o merge_request.assign="@Oleksandr_Kosse" https://vladislav_shishko:${RELEASE_USER_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git HEAD:release/$SHORT_TAG
- git push -o merge_request.create -o merge_request.target=release/$SHORT_TAG -o merge_request.title="Auto-release for $TAG " -o merge_request.label="GCP" -o merge_request.assign="@Oleksandr_Kosse" https://vladislav_shishko:${RELEASE_USER_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git HEAD:auto_release_${TIMESTAMP}
# - git push -o ci-skip -o merge_request.create -o merge_request.target=release/$TAG -o merge_request.remove_source_branch https://vladislav_shishko:${RELEASE_USER_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git HEAD:auto_release_${TIMESTAMP}
rules:
- if: "$TAG"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment