blob: 986675b54505f0e0d1f8f3d0c9ae3ab755bdb756 [file] [log] [blame]
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -06001# Copyright lowRISC contributors.
2# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3# SPDX-License-Identifier: Apache-2.0
4
5# Azure template for archiving pipeline step outputs and uploading them.
6#
7# This template will archive all of $BIN_DIR, and upload it for use by
Philipp Wagner5aa7ed32021-02-02 18:53:36 +00008# downstream jobs using download-artifacts-template.yml.
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -06009#
10# This template expects that a variable $BUILD_ROOT is set. See
11# util/build_consts.sh for more information.
12
Philipp Wagner5aa7ed32021-02-02 18:53:36 +000013
14parameters:
15 # Rsync-style file patterns to include in the partial BIN_DIR output.
16 - name: includePatterns
17 type: object
18 default: []
19
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -060020steps:
21 - bash: |
22 set -e
23 test -n "$BUILD_ROOT"
24 . util/build_consts.sh
25
Philipp Wagner5aa7ed32021-02-02 18:53:36 +000026 # Write all include patterns to a file used by rsync.
27 echo "${{ join('\n', parameters.includePatterns) }}" > "$BUILD_ROOT/include_patterns.txt"
28
29 echo
30 echo Files matching these patterns will be included in the binary build artifact for this job:
31 echo vvvvvvvvvvvvvvvvvv
32 cat "$BUILD_ROOT/include_patterns.txt"
33 echo ^^^^^^^^^^^^^^^^^^
34
35 # The file upstream_bin_dir_contents.txt lists all files which were part
36 # of an "upstream" BIN_DIR which got downloaded at the beginning of this
37 # job. Ensure that this file exists, even if no upstream BIN_DIR was
38 # downloaded.
39 touch "$BUILD_ROOT/upstream_bin_dir_contents.txt"
40
41 BIN_DIR_FULL="${BIN_DIR}.full"
42 mv "$BIN_DIR" "$BIN_DIR_FULL"
43 mkdir -p "$BIN_DIR"
44
45 echo
46 echo Copying files into the output archive:
47 rsync \
48 --archive \
49 --verbose \
50 --remove-source-files \
51 --prune-empty-dirs \
52 --exclude-from="$BUILD_ROOT/upstream_bin_dir_contents.txt" \
53 --include="*/" \
54 --include-from="$BUILD_ROOT/include_patterns.txt" \
55 --exclude="*" \
56 "${BIN_DIR_FULL}/" "${BIN_DIR}/"
57
58 echo
59 echo 'Files in $BIN_DIR not considered outputs of this job:'
60 echo vvvvvvvvvvvvvvvvvv
61 find "$BIN_DIR_FULL"
62 echo ^^^^^^^^^^^^^^^^^^
63
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -060064 tar -C "$BUILD_ROOT" \
65 -cvf "$BUILD_ROOT/build-bin.tar" \
66 "${BIN_DIR#"$BUILD_ROOT/"}"
Philipp Wagner5aa7ed32021-02-02 18:53:36 +000067 displayName: Archive step outputs
Miguel Young de la Sotab4df8602019-11-21 12:44:11 -060068 - publish: "$(Build.ArtifactStagingDirectory)/build-bin.tar"
Philipp Wagner5aa7ed32021-02-02 18:53:36 +000069 # The PhaseName is the string after the "job" key in the build description,
70 # e.g. "job: my_phase_name".
71 artifact: partial-build-bin-$(System.PhaseName)
72 displayName: Upload step outputs