2 #===-- tag.sh - Tag the LLVM release candidates ----------------------------===#
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 #===------------------------------------------------------------------------===#
10 # Create branches and release candidates for the LLVM release.
12 #===------------------------------------------------------------------------===#
16 projects
="llvm bolt clang cmake compiler-rt libcxx libcxxabi libclc clang-tools-extra polly lldb lld openmp libunwind mlir flang runtimes third-party"
20 yyyymmdd
=$
(date +'%Y%m%d')
22 template
='${PROJECT}-${RELEASE}${RC}.src.tar.xz'
26 Export the Git sources and build tarballs from them.
28 Usage: $(basename $0) [-release|--release <major>.<minor>.<patch>]
31 [-git-ref|--git-ref <git-ref>]
32 [-template|--template <template>]
36 -release | --release <major>.<minor>.<patch> The version number of the release
37 -rc | --rc <num> The release candidate number
38 -final | --final When provided, this option will disable the rc flag
39 -git-ref | --git-ref <git-ref> (optional) Use <git-ref> to determine the release and don't export the test-suite files
40 -template | --template <template> (optional) Possible placeholders: \$PROJECT \$YYYYMMDD \$GIT_REF \$RELEASE \$RC.
41 Defaults to '${template}'.
43 The following list shows the filenames (with <placeholders>) for the artifacts
44 that are being generated (given that you don't touch --template).
46 $(echo "$projects "| sed 's/\([a-z-]\+\) / * \1-<RELEASE><RC>.src.tar.xz \n/g')
48 Additional files being generated:
50 * llvm-project-<RELEASE><RC>.src.tar.xz (the complete LLVM source project)
51 * test-suite-<RELEASE><RC>.src.tar.xz (only when not using --git-ref)
53 To ease the creation of snapshot builds, we also provide these files
55 * llvm-release-<YYYYMMDD>.txt (contains the <RELEASE> as a text)
56 * llvm-rc-<YYYYMMDD>.txt (contains the rc version passed to the invocation of $(basename $0))
57 * llvm-git-revision-<YYYYMMDD>.txt (contains the current git revision sha1)
59 Example values for the placeholders:
62 * <YYYYMMDD> -> 20210414 (the date when executing this script)
63 * <RC> -> rc4 (will be empty when using --git-ref)
65 In order to generate snapshots of the upstream main branch you could do this for example:
67 $(basename $0) --git-ref upstream/main --template '\${PROJECT}-\${YYYYMMDD}.src.tar.xz'
73 export PROJECT
=$1 YYYYMMDD
=$yyyymmdd RC
=$rc RELEASE
=$release GIT_REF
=$git_rev
74 basename $
(echo $template | envsubst
'$PROJECT $RELEASE $RC $YYYYMMDD $GIT_REF')
75 unset PROJECT YYYYMMDD RC RELEASE GIT_REF
79 local tag
="llvmorg-$release"
81 llvm_src_dir
=$
(readlink
-f $
(dirname "$(readlink -f "$0")")/..
/..
/..
)
82 [ -d $llvm_src_dir/.git
] ||
( echo "No git repository at $llvm_src_dir" ; exit 1 )
84 # Determine the release by fetching the version from LLVM's CMakeLists.txt
85 # in the specified git ref.
86 if [ -n "$snapshot" ]; then
87 release
=$
(git
-C $llvm_src_dir show
$snapshot:cmake
/Modules
/LLVMVersion.cmake |
grep -ioP 'set\(\s*LLVM_VERSION_(MAJOR|MINOR|PATCH)\s\K[0-9]+' |
paste -sd '.')
90 tag
="llvmorg-$release"
92 if [ "$rc" = "final" ]; then
100 echo "Creating tarball for llvm-project ..."
103 [ -n "$snapshot" ] && tree_id
="$snapshot"
104 echo "Tree ID to archive: $tree_id"
106 # This might be a surprise but a package like clang or compiler-rt don't
107 # know about the LLVM version itself. That's why we also export a the
108 # llvm-version*-<YYYYMMDD> and llvm-git*-<YYYYMMDD> files.
109 git_rev
=$
(git rev-parse
$tree_id)
110 echo "git revision: $git_rev"
111 echo "$release" > $target_dir/llvm-release-
$yyyymmdd.txt
112 echo "$rc" > $target_dir/llvm-rc-
$yyyymmdd.txt
113 echo "$git_rev" > $target_dir/llvm-git-revision-
$yyyymmdd.txt
115 git archive
--prefix=llvm-project-
$release$rc.src
/ $tree_id . | xz
-T0 >$target_dir/$
(template_file llvm-project
)
118 if [ -z "$snapshot" ]; then
119 if [ ! -d test-suite-
$release$rc.src
]; then
120 echo "Fetching LLVM test-suite source ..."
121 mkdir
-p test-suite-
$release$rc.src
122 curl
-L https
://github.com
/llvm
/test-suite
/archive
/$tag.
tar.gz | \
123 tar -C test-suite-
$release$rc.src
--strip-components=1 -xzf -
125 echo "Creating tarball for test-suite ..."
126 tar --sort=name
--owner=0 --group=0 \
127 --pax-option=exthdr.name
=%d
/PaxHeaders
/%f
,delete
=atime
,delete
=ctime \
128 -cJf test-suite-
$release$rc.src.
tar.xz test-suite-
$release$rc.src
131 for proj
in $projects; do
132 echo "Creating tarball for $proj ..."
133 pushd $llvm_src_dir/$proj
134 git archive
--prefix=$proj-$release$rc.src
/ $tree_id . | xz
-T0 >$target_dir/$
(template_file
$proj)
139 while [ $# -gt 0 ]; do
141 -release |
--release )
152 -git-ref |
--git-ref )
156 -template |
--template )
160 -h |
-help |
--help )
165 echo "unknown option: $1"
173 if [ -n "$snapshot" ]; then
174 if [[ "$rc" != "" ||
"$release" != "" ]]; then
175 echo "error: must not specify -rc or -release when creating a snapshot"
178 elif [ -z "$release" ]; then
179 echo "error: need to specify a release version"
183 # Make sure umask is not overly restrictive.