From 0069d3414c7e35304e48471b19ddd7eb33cc6cc2 Mon Sep 17 00:00:00 2001 From: Matthew Evans <7916000+ml-evs@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:33:54 +0100 Subject: [PATCH] Get the local datalab git version and pass it to the docker build (#37) * Get the local datalab git version and pass it to the API docker build * Get the local datalab git version and pass it to the API docker build * Also pass app version in build * Bump README versions * Fix ansible lint suggestions --- README.md | 3 ++- ansible/roles/datalab/tasks/main.yml | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ebf400..6d68a14 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ Attempts will be made to tabulate the supported versions of datalab with each re |---|---| | v0.1.x | v0.4.x | | v0.2.x | v0.4.x | -| v0.3.x | v0.5.x+ | +| v0.3.x | v0.5.0-rc.x | +| v0.4.x | v0.5.x | ## Overview diff --git a/ansible/roles/datalab/tasks/main.yml b/ansible/roles/datalab/tasks/main.yml index 43c2668..48bf48b 100644 --- a/ansible/roles/datalab/tasks/main.yml +++ b/ansible/roles/datalab/tasks/main.yml @@ -12,6 +12,24 @@ dest: "{{ ansible_user_home_dir }}/datalab/pydatalab/.env" mode: "0644" +- name: Get git tag version locally to use as fact # noqa: command-instead-of-module + delegate_to: localhost + ansible.builtin.shell: + cmd: set -o pipefail && git describe --tags --match 'v*' | sed 's/^v//' | sed 's/-rc/rc/' | sed 's/-/+/' + chdir: "{{ playbook_dir }}/../src/datalab" + register: git_tag + changed_when: false + +- name: Set fact for git tag version + ansible.builtin.set_fact: + git_tag: "{{ git_tag.stdout }}" + +- name: Write git version to a .env file to be loaded by build + ansible.builtin.copy: + content: "SETUPTOOLS_SCM_PRETEND_VERSION={{ git_tag }}\nVUE_APP_GIT_VERSION={{ git_tag }}" + dest: "{{ ansible_user_home_dir }}/datalab/.env_version" + mode: "0644" + - name: Copy encrypted API config file from vault ansible.builtin.copy: src: "{{ playbook_dir }}/vaults/datalab/prod_config.json" @@ -38,6 +56,7 @@ build: always env_files: - "{{ ansible_user_home_dir }}/datalab/pydatalab/.env" + - "{{ ansible_user_home_dir }}/datalab/.env_version" - name: Check whether ssh config exists ansible.builtin.stat: @@ -85,6 +104,7 @@ build: always env_files: - "{{ ansible_user_home_dir }}/datalab/webapp/.env" + - "{{ ansible_user_home_dir }}/datalab/.env_version" - name: Add daily backup task to crontab ansible.builtin.cron: