diff --git a/playbooks/openstack-doc-build/post.yaml b/playbooks/openstack-doc-build/post.yaml index 61a111e9..9dfb9fc6 100644 --- a/playbooks/openstack-doc-build/post.yaml +++ b/playbooks/openstack-doc-build/post.yaml @@ -1,3 +1,3 @@ - hosts: all roles: - - prepare-docs-for-afs + - prepare-infra-docs-for-afs diff --git a/roles/prepare-docs-for-afs/tasks/main.yaml b/roles/prepare-docs-for-afs/tasks/main.yaml deleted file mode 100644 index e18c33be..00000000 --- a/roles/prepare-docs-for-afs/tasks/main.yaml +++ /dev/null @@ -1,62 +0,0 @@ -- name: Process built docs to prepare for AFS publication - args: - chdir: "{{ zuul_work_dir }}" - executable: /bin/bash - shell: | - set -ex - tags_handling=${2:both} - MARKER_TEXT="Project: $ZUUL_PROJECT Ref: $ZUUL_REFNAME Build: $ZUUL_UUID Revision: $ZUUL_NEWREV" - echo $MARKER_TEXT > doc/build/html/.root-marker - - if [ -z "$ZUUL_REFNAME" ] || [ "$ZUUL_REFNAME" == "master" ] ; then - : # Leave the docs where they are. - elif echo $ZUUL_REFNAME | grep refs/tags/ >/dev/null ; then - # Put tagged releases in proper location. All tagged builds get copied to - # BUILD_DIR/tagname. If this is the latest tagged release the copy of files - # at BUILD_DIR remains. When Jenkins copies this file the root developer - # docs are always the latest release with older tags available under the - # root in the tagname dir. - TAG=$(echo $ZUUL_REFNAME | sed 's/refs.tags.//') - if [ ! -z $TAG ] ; then - # This is a hack to ignore the year.release tags in projects since - # now all projects use semver based versions instead of date based - # versions. The date versions will sort higher even though they - # should not so we just special case it here. - LATEST=$(git tag | sed -n -e '/^20[0-9]\{2\}\..*$/d' -e '/^[0-9]\+\(\.[0-9]\+\)*$/p' | sort -V | tail -1) - # Now publish to / and /$TAG if this is the latest version for projects - # and we are only publishing from the release pipeline, - # or just /$TAG otherwise. - if [ "$tags_handling" = "tags-only" -a "$TAG" = "$LATEST" ] ; then - # Copy the docs into a subdir if this is a tagged build - mkdir doc/build/$TAG - cp -R doc/build/html/. doc/build/$TAG - mv doc/build/$TAG doc/build/html/$TAG - else - # Move the docs into a subdir if this is a tagged build - mv doc/build/html doc/build/tmp - mkdir doc/build/html - mv doc/build/tmp doc/build/html/$TAG - fi - fi - elif echo $ZUUL_REFNAME | grep stable/ >/dev/null ; then - # Put stable release changes in dir named after stable release under the - # build dir. When Jenkins copies these files they will be accessible under - # the developer docs root using the stable release name. - BRANCH=$(echo $ZUUL_REFNAME | sed 's/stable.//') - if [ ! -z $BRANCH ] ; then - # Move the docs into a subdir if this is a stable branch build - mv doc/build/html doc/build/tmp - mkdir doc/build/html - mv doc/build/tmp doc/build/html/$BRANCH - fi - else - # Put other branch changes in dir named after branch under the - # build dir. When Jenkins copies these files they will be - # accessible under the developer docs root using the branch name. - # EG: feature/foo or milestone-proposed - BRANCH=$ZUUL_REFNAME - TOP=`dirname $BRANCH` - mv doc/build/html doc/build/tmp - mkdir -p doc/build/html/$TOP - mv doc/build/tmp doc/build/html/$BRANCH - fi diff --git a/roles/prepare-infra-docs-for-afs/README.rst b/roles/prepare-infra-docs-for-afs/README.rst new file mode 100644 index 00000000..e68f1ab0 --- /dev/null +++ b/roles/prepare-infra-docs-for-afs/README.rst @@ -0,0 +1 @@ +Prepare built openstack-infra docs to be published to the OpenStack AFS cell. diff --git a/roles/prepare-docs-for-afs/defaults/main.yaml b/roles/prepare-infra-docs-for-afs/defaults/main.yaml similarity index 93% rename from roles/prepare-docs-for-afs/defaults/main.yaml rename to roles/prepare-infra-docs-for-afs/defaults/main.yaml index a0afa22c..189d518f 100644 --- a/roles/prepare-docs-for-afs/defaults/main.yaml +++ b/roles/prepare-infra-docs-for-afs/defaults/main.yaml @@ -1,2 +1 @@ ---- zuul_work_dir: "src/{{ zuul.project.canonical_name }}" diff --git a/roles/prepare-infra-docs-for-afs/tasks/branch.yaml b/roles/prepare-infra-docs-for-afs/tasks/branch.yaml new file mode 100644 index 00000000..ff2acc58 --- /dev/null +++ b/roles/prepare-infra-docs-for-afs/tasks/branch.yaml @@ -0,0 +1,12 @@ +- name: Process other branch changes + args: + chdir: "{{ zuul_work_dir }}" + # Put other branch changes in dir named after branch under the + # build dir. When Zuul copies these files they will be + # accessible under the developer docs root using the branch name. + # EG: feature/foo or milestone-proposed + shell: | + mv doc/build/html doc/build/tmp + mkdir -p doc/build/html/{{ zuul.branch | dirname }} + mv doc/build/tmp doc/build/html/{{ zuul.branch | basename }} + tags: skip_ansible_lint diff --git a/roles/prepare-infra-docs-for-afs/tasks/main.yaml b/roles/prepare-infra-docs-for-afs/tasks/main.yaml new file mode 100644 index 00000000..6521505f --- /dev/null +++ b/roles/prepare-infra-docs-for-afs/tasks/main.yaml @@ -0,0 +1,16 @@ +- name: Write marker text + copy: + dest: "{{ zuul_work_dir }}/doc/build/html/.root-marker" + content: "Project: {{ zuul.project.name }} Branch: {{ zuul.branch }} Build: {{ zuul.build }} Revision: {{ zuul.ref }}" + +- name: Process tagged build + include: tagged.yaml + when: "zuul.branch != 'master' and zuul.tag is defined" + +- name: Process stable branch build + include: stable.yaml + when: "'stable' in zuul.branch and zuul.tag is not defined" + +- name: Process branch build + include: branch.yaml + when: "zuul.branch != 'master' and 'stable' not in zuul.branch and zuul.tag is not defined" diff --git a/roles/prepare-infra-docs-for-afs/tasks/stable.yaml b/roles/prepare-infra-docs-for-afs/tasks/stable.yaml new file mode 100644 index 00000000..ee3bdc3d --- /dev/null +++ b/roles/prepare-infra-docs-for-afs/tasks/stable.yaml @@ -0,0 +1,12 @@ +- name: Process stable branch changes + args: + chdir: "{{ zuul_work_dir }}" + # Put stable release changes in dir named after stable release under the + # build dir. When Zuul copies these files they will be accessible under + # the developer docs root using the stable release name. + shell: | + # Move the docs into a subdir if this is a stable branch build + mv doc/build/html doc/build/tmp + mkdir doc/build/html + mv doc/build/tmp doc/build/html/{{ zuul.branch | replace('stable/', '') }} + tags: skip_ansible_lint diff --git a/roles/prepare-infra-docs-for-afs/tasks/tagged.yaml b/roles/prepare-infra-docs-for-afs/tasks/tagged.yaml new file mode 100644 index 00000000..c9cfdb6e --- /dev/null +++ b/roles/prepare-infra-docs-for-afs/tasks/tagged.yaml @@ -0,0 +1,31 @@ +- name: Get latest tag for project + args: + chdir: "{{ zuul_work_dir }}" + executable: /bin/bash + # This is a hack to ignore the year.release tags in projects since + # now all projects use semver based versions instead of date based + # versions. The date versions will sort higher even though they + # should not so we just special case it here. + shell: | + git tag | sed -n -e '/^20[0-9]\{2\}\..*$/d' -e '/^[0-9]\+\(\.[0-9]\+\)*$/p' | sort -V | tail -1 + register: latest + tags: skip_ansible_lint + +# Put tagged releases in proper location. All tagged builds get copied to +# BUILD_DIR/tagname. If this is the latest tagged release the copy of files +# at BUILD_DIR remains. When Zuul copies this file the root developer +# docs are always the latest release with older tags available under the +# root in the tagname dir. + +- name: Process tags only builds when the tag is the latest tag + args: + chdir: "{{ zuul_work_dir }}" + # Now publish to / and /$TAG if this is the latest version for projects + # and we are only publishing from the release pipeline, + # or just /$TAG otherwise. + shell: | + # Copy the docs into a subdir if this is a tagged build + mkdir doc/build/{{ zuul.tag }} + cp -R doc/build/html/. doc/build/{{ zuul.tag }} + mv doc/build/{{ zuul.tag }} doc/build/html/{{ zuul.tag }} + tags: skip_ansible_lint