| # Copyright lowRISC contributors. |
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| # SPDX-License-Identifier: Apache-2.0 |
| |
| # Azure template for archiving pipeline step outputs and uploading them. |
| # |
| # This template will archive all of $BIN_DIR, and upload it for use by |
| # downstream jobs using download-artifacts-template.yml. |
| # |
| # This template expects that a variable $BUILD_ROOT is set. See |
| # util/build_consts.sh for more information. |
| |
| |
| parameters: |
| # Rsync-style file patterns to include in the partial BIN_DIR output. If a |
| # file is captured by these patterns, but it was previously downloaded via |
| # ci/download-artifacts-template.yml, it will not be uploaded again. |
| - name: includePatterns |
| type: object |
| default: [] |
| # Rsync-style file patterns to unconditionally include in the partial BIN_DIR |
| # output. If a file is captured by these patterns, it will be uploaded even if |
| # it came from ci/download-artifacts-template.yml. |
| - name: unconditionalIncludePatterns |
| type: object |
| default: [] |
| |
| steps: |
| - bash: | |
| set -e |
| test -n "$BUILD_ROOT" |
| . util/build_consts.sh |
| |
| # Write all sets of include patterns to files used by rsync. |
| echo -e "${{ join('\n', parameters.includePatterns) }}" > "$BUILD_ROOT/include_patterns.txt" |
| echo -e "${{ join('\n', parameters.unconditionalIncludePatterns) }}" > "$BUILD_ROOT/unconditional_include_patterns.txt" |
| |
| echo |
| echo Files matching these patterns will be included in the binary build |
| echo artifact for this job unless they were downloaded from an upstream job: |
| echo vvvvvvvvvvvvvvvvvv |
| cat "$BUILD_ROOT/include_patterns.txt" |
| echo ^^^^^^^^^^^^^^^^^^ |
| |
| echo |
| echo Files matching these patterns will always be included in the binary |
| echo build artifact for this job: |
| echo vvvvvvvvvvvvvvvvvv |
| cat "$BUILD_ROOT/unconditional_include_patterns.txt" |
| echo ^^^^^^^^^^^^^^^^^^ |
| |
| # The file upstream_bin_dir_contents.txt lists all files which were part |
| # of an "upstream" BIN_DIR which got downloaded at the beginning of this |
| # job. Ensure that this file exists, even if no upstream BIN_DIR was |
| # downloaded. |
| touch "$BUILD_ROOT/upstream_bin_dir_contents.txt" |
| |
| BIN_DIR_FULL="${BIN_DIR}.full" |
| mv "$BIN_DIR" "$BIN_DIR_FULL" |
| mkdir -p "$BIN_DIR" |
| |
| echo |
| echo Copying files into the output archive: |
| rsync \ |
| --archive \ |
| --verbose \ |
| --remove-source-files \ |
| --prune-empty-dirs \ |
| --include-from="$BUILD_ROOT/unconditional_include_patterns.txt" \ |
| --exclude-from="$BUILD_ROOT/upstream_bin_dir_contents.txt" \ |
| --include="*/" \ |
| --include-from="$BUILD_ROOT/include_patterns.txt" \ |
| --exclude="*" \ |
| "${BIN_DIR_FULL}/" "${BIN_DIR}/" |
| |
| echo |
| echo 'Files in $BIN_DIR not considered outputs of this job:' |
| echo vvvvvvvvvvvvvvvvvv |
| find "$BIN_DIR_FULL" |
| echo ^^^^^^^^^^^^^^^^^^ |
| |
| tar -C "$BUILD_ROOT" \ |
| -cvf "$BUILD_ROOT/build-bin.tar" \ |
| "${BIN_DIR#"$BUILD_ROOT/"}" |
| displayName: Archive step outputs |
| - publish: "$(Build.ArtifactStagingDirectory)/build-bin.tar" |
| # The PhaseName is the string after the "job" key in the build description, |
| # e.g. "job: my_phase_name". |
| artifact: partial-build-bin-$(System.PhaseName) |
| displayName: Upload step outputs |