| 1 | JENKINS_SITE='https://jenkins.open-scap.org' |
| 2 | GITHUB_ROOT='https://github.com/OpenSCAP/openscap' |
| 3 | |
| 4 | testscip-shell system . . test. -f .env && . .envscip-shell source . . `.env`. |
| 5 | |
| 6 | SCRIPT_DIR="$(cd "$(dirnamescip-shell system . . dirname. "${BASH_SOURCE[0]}")" && pwdscip-shell system . . pwd.)" |
| 7 | OSCAP_REPO_ROOT="$(cd "$SCRIPT_DIR" && cd .. && pwdscip-shell system . . pwd.)" |
| 8 | LIBRARY_STASH="/tmp/library-stashscip-shell filesystem . . `/tmp/library-stash`." |
| 9 | BUILDDIR="$OSCAP_REPO_ROOT/build" |
| 10 | |
| 11 | FILE_WITH_VERSIONS="$SCRIPT_DIR/versions.sh" |
| 12 | |
| 13 | . "$FILE_WITH_VERSIONS" |
| 14 | |
| 15 | |
| 16 | diescip-shell shell shell-project 0.0.0 die().() |
| 17 | { |
| 18 | echoscip-shell system . . echo. "$1" |
| 19 | exit 1 |
| 20 | } |
| 21 | |
| 22 | |
| 23 | clean_repositoryscip-shell shell shell-project 0.0.0 clean_repository().() |
| 24 | { |
| 25 | makescip-shell system . . make. distclean |
| 26 | gitscip-shell system . . git. clean -f |
| 27 | } |
| 28 | |
| 29 | |
| 30 | clean_repository_aggressivelyscip-shell shell shell-project 0.0.0 clean_repository_aggressively().() |
| 31 | { |
| 32 | gitscip-shell system . . git. reset --hard |
| 33 | gitscip-shell system . . git. clean -x -f -d |
| 34 | } |
| 35 | |
| 36 | |
| 37 | # Args: |
| 38 | # $1: Python version |
| 39 | check_python_bindingscip-shell shell shell-project 0.0.0 check_python_binding().() |
| 40 | { |
| 41 | local _python_major |
| 42 | _python_major="${1%%.*}" |
| 43 | ( |
| 44 | cd "$BUILDDIR" |
| 45 | if LD_PRELOAD="/usr/lib64/libpython$1.so" lddscip-shell system . . ldd. -r "$BUILDDIR/swig/python$_python_major/_openscap_py.so" | grepscip-shell system . . grep. -q '^undefined' ; then |
| 46 | diescip-shell shell shell-project 0.0.0 die(). "Python $1 bindings seem to have undefined symbols" |
| 47 | fi |
| 48 | ) |
| 49 | } |
| 50 | |
| 51 | |
| 52 | trigger_testsscip-shell shell shell-project 0.0.0 trigger_tests().() |
| 53 | { |
| 54 | xdg-open "$JENKINS_SITE/job/openscap-parametrized/build" |
| 55 | } |
| 56 | |
| 57 | |
| 58 | trigger_docbuildscip-shell shell shell-project 0.0.0 trigger_docbuild().() |
| 59 | { |
| 60 | xdg-open "$JENKINS_SITE/job/static_openscap_docs/build" |
| 61 | } |
| 62 | |
| 63 | |
| 64 | build_allscip-shell shell shell-project 0.0.0 build_all().() |
| 65 | { |
| 66 | (mkdirscip-shell system . . mkdir. -p "$BUILDDIR" && cd "$BUILDDIR" && cmakescip-shell system . . cmake. -DENABLE_SCE=TRUE .. && makescip-shell system . . make.) || diescip-shell shell shell-project 0.0.0 die(). "Error building pristine OpenSCAP" |
| 67 | } |
| 68 | |
| 69 | |
| 70 | execute_local_testsscip-shell shell shell-project 0.0.0 execute_local_tests().() |
| 71 | { |
| 72 | build_allscip-shell shell shell-project 0.0.0 build_all(). |
| 73 | (cd "$BUILDDIR" && ctestscip-shell system . . ctest. || diescip-shell shell shell-project 0.0.0 die(). "Error during test run") |
| 74 | check_python_bindingscip-shell shell shell-project 0.0.0 check_python_binding(). 3 |
| 75 | } |
| 76 | |
| 77 | |
| 78 | make_distscip-shell shell shell-project 0.0.0 make_dist().() |
| 79 | { |
| 80 | ( |
| 81 | cd "$BUILDDIR" |
| 82 | makescip-shell system . . make. package_source |
| 83 | sha1sumscip-shell system . . sha1sum. openscap-$version.tar.gz > openscap-$version.tar.gz.sha1sum |
| 84 | sha512sumscip-shell system . . sha512sum. openscap-$version.tar.gz > openscap-$version.tar.gz.sha512sum |
| 85 | ) |
| 86 | } |
| 87 | |
| 88 | |
| 89 | check_abiscip-shell shell shell-project 0.0.0 check_abi().() |
| 90 | { |
| 91 | rpm -q abi-compliance-checker || sudoscip-shell system . . sudo. dnf install abi-compliance-checker |
| 92 | testscip-shell system . . test. -d openscap-abi-check || gitscip-shell system . . git. clone --recurse-submodules [email protected]:OpenSCAP/openscap-abi-check.git |
| 93 | openscap_git_branch=$(gitscip-shell system . . git. branch | grepscip-shell system . . grep. '^\* ' | cutscip-shell system . . cut. -f2 -d' ') |
| 94 | ( |
| 95 | cd openscap-abi-check |
| 96 | perlscip-shell system . . perl. run_check.pl "$previous_version" "$openscap_git_branch" |
| 97 | echoscip-shell system . . echo. 'Read the report, if there is an ABI issue (some symbols were changed / removed), fix it before proceeding further!' |
| 98 | printfscip-shell system . . printf. "%s\n" "Then, Change directory to '$(pwd)' and add the reports. Then, commit with the appropriate message:" "" "cd $(pwdscip-shell system . . pwd.)" "git add reports/${previous_version}_${openscap_git_branch}.html'" "git commit -m 'Report before $version release'" |
| 99 | ) |
| 100 | } |
| 101 | |
| 102 | |
| 103 | parse_variable_assignment_from_filescip-shell shell shell-project 0.0.0 parse_variable_assignment_from_file().() |
| 104 | { |
| 105 | local _variable="$1" _fname="$2" |
| 106 | testscip-shell system . . test. "$(grepscip-shell system . . grep. "set(\s*$_variable\s\+[0-9]\+\s*)" "$_fname" | wcscip-shell system . . wc. -l)" = 1 || diescip-shell shell shell-project 0.0.0 die(). "More than one occurence of numerical assignment to '$_variable'" |
| 107 | echoscip-shell system . . echo. $(grepscip-shell system . . grep. "set(\s*$_variable\s\+[0-9]\+\s*)" "$_fname" | sedscip-shell system . . sed. -e "s/set(\s*$_variable\s\+\([0-9]\+\)\s*)/\1/") |
| 108 | } |
| 109 | |
| 110 | |
| 111 | substitute_variable_assignment_value_in_filescip-shell shell shell-project 0.0.0 substitute_variable_assignment_value_in_file().() |
| 112 | { |
| 113 | local _variable="$1" _old_value="$2" _new_value="$3" _fname="$4" |
| 114 | sedscip-shell system . . sed. -i "s/set(\s*$_variable\s\+$_old_value\s*)/set($_variable $_new_value)/" "$_fname" |
| 115 | } |
| 116 | |
| 117 | # $1 ... File to probe |
| 118 | get_lt_triplet_from_filescip-shell shell shell-project 0.0.0 get_lt_triplet_from_file().() |
| 119 | { |
| 120 | local _varname _fname="$1" |
| 121 | for _varname in LT_CURRENT LT_REVISION LT_AGE |
| 122 | do |
| 123 | printfscip-shell system . . printf. "%s " "$(parse_variable_assignment_from_filescip-shell shell shell-project 0.0.0 parse_variable_assignment_from_file(). "$_varname" "$_fname")" |
| 124 | done |
| 125 | echoscip-shell system . . echo. |
| 126 | } |
| 127 | |
| 128 | increment_on_backwards_compatiblescip-shell shell shell-project 0.0.0 increment_on_backwards_compatible().() |
| 129 | { |
| 130 | local triplet |
| 131 | triplet=( $1 ) |
| 132 | (( triplet[0]++ )) |
| 133 | (( triplet[2]++ )) |
| 134 | printfscip-shell system . . printf. "%s %s %s \n" "${triplet[@]}" |
| 135 | } |
| 136 | |
| 137 | |
| 138 | increment_on_bugfixscip-shell shell shell-project 0.0.0 increment_on_bugfix().() |
| 139 | { |
| 140 | local triplet |
| 141 | triplet=( $1 ) |
| 142 | (( triplet[1]++ )) |
| 143 | printfscip-shell system . . printf. "%s %s %s \n" "${triplet[@]}" |
| 144 | } |
| 145 | |
| 146 | |
| 147 | increment_on_breaking_changescip-shell shell shell-project 0.0.0 increment_on_breaking_change().() |
| 148 | { |
| 149 | local triplet |
| 150 | triplet=( $1 ) |
| 151 | (( triplet[0]++ )) |
| 152 | triplet[2]=0 |
| 153 | printfscip-shell system . . printf. "%s %s %s \n" "${triplet[@]}" |
| 154 | } |
| 155 | |
| 156 | # Args: |
| 157 | # $1: Triplet to be replaced |
| 158 | # $2: The replacement |
| 159 | # $3: The concerned file |
| 160 | apply_triplets_to_filescip-shell shell shell-project 0.0.0 apply_triplets_to_file().() |
| 161 | { |
| 162 | local _previous=( $1 ) _replacement=( $2 ) _file="$3" _varnames=(LT_CURRENT LT_REVISION LT_AGE) |
| 163 | for i in 0 1 2 |
| 164 | do |
| 165 | substitute_variable_assignment_value_in_filescip-shell shell shell-project 0.0.0 substitute_variable_assignment_value_in_file(). "${_varnames[$i]}" "${_previous[$i]}" "${_replacement[$i]}" "$_file" |
| 166 | done |
| 167 | } |
| 168 | |
| 169 | |
| 170 | # |
| 171 | # $1: Strategy (backwards_compatible, bugfix, breaking_change) |
| 172 | increment_ltversionsscip-shell shell shell-project 0.0.0 increment_ltversions().() |
| 173 | { |
| 174 | local _cmake_file="$OSCAP_REPO_ROOT/CMakeLists.txt" _old_versions _new_versions _new_soname _old_soname |
| 175 | # check_for_clean_repo |
| 176 | _old_versions="$(get_lt_triplet_from_filescip-shell shell shell-project 0.0.0 get_lt_triplet_from_file(). "$_cmake_file")" || diescip-shell shell shell-project 0.0.0 die(). "Unable to get current LT versions" |
| 177 | _new_versions="$(increment_on_$1 "$_old_versions")" || diescip-shell shell shell-project 0.0.0 die(). "Unable to get calculate refreshed LT version with strategy '$1'" |
| 178 | _old_soname="$(get_soname_from_triplet "$_old_versions")" |
| 179 | _new_soname="$(get_soname_from_triplet "$_new_versions")" |
| 180 | |
| 181 | testscip-shell system . . test. "$_old_soname" = "$_new_soname" && diescip-shell shell shell-project 0.0.0 die(). "The new and old sonames are the same '$_new_soname', which doesn't make sense." |
| 182 | |
| 183 | check_for_clean_reposcip-shell shell shell-project 0.0.0 check_for_clean_repo(). |
| 184 | clean_library_stashscip-shell shell shell-project 0.0.0 clean_library_stash(). |
| 185 | |
| 186 | echoscip-shell system . . echo. "Building with the old soname" |
| 187 | build_allscip-shell shell shell-project 0.0.0 build_all(). 2> /dev/nullscip-shell filesystem . . `/dev/null`. > /dev/nullscip-shell filesystem . . `/dev/null`. || diescip-shell shell shell-project 0.0.0 die(). "Build with the old soname failed" |
| 188 | stash_libraryscip-shell shell shell-project 0.0.0 stash_library(). |
| 189 | check_stash_for_sonamescip-shell shell shell-project 0.0.0 check_stash_for_soname(). "$_old_soname" || diescip-shell shell shell-project 0.0.0 die(). "Couldn't find the expected (old) soname $_old_soname, did it compile?" |
| 190 | check_stash_for_sonamescip-shell shell shell-project 0.0.0 check_stash_for_soname(). "$_new_soname" && diescip-shell shell shell-project 0.0.0 die(). "Unexpectedly found new soname $_new_soname where only the old soname $_old_soname is supposed to be." |
| 191 | |
| 192 | apply_triplets_to_filescip-shell shell shell-project 0.0.0 apply_triplets_to_file(). "$_old_versions" "$_new_versions" "$_cmake_file" |
| 193 | |
| 194 | echoscip-shell system . . echo. "Building with the new soname" |
| 195 | build_allscip-shell shell shell-project 0.0.0 build_all(). 2> /dev/nullscip-shell filesystem . . `/dev/null`. > /dev/nullscip-shell filesystem . . `/dev/null`. || diescip-shell shell shell-project 0.0.0 die(). "Build with the new soname failed" |
| 196 | stash_libraryscip-shell shell shell-project 0.0.0 stash_library(). |
| 197 | check_stash_for_sonamescip-shell shell shell-project 0.0.0 check_stash_for_soname(). "$_new_soname" || diescip-shell shell shell-project 0.0.0 die(). "Couldn't find the expected (old) soname $_old_soname, did it compile?" |
| 198 | echoscip-shell system . . echo. "Build went as expected, showing git diff." |
| 199 | |
| 200 | gitscip-shell system . . git. diff |
| 201 | printfscip-shell system . . printf. "%s\n" "If you are satisfied with the diff, you can commit. Execute " "git add $_cmake_file" "" "Then 'git commit' with message" "" "Bump soname from $_old_soname to $_new_soname" "" "<X> new symbols were added, <Y> were removed." |
| 202 | } |
| 203 | |
| 204 | |
| 205 | # Args: |
| 206 | # $1: The string in form of "LT_CURRENT LT_REVISION LT_AGE" |
| 207 | get_soname_from_tripletscip-shell shell shell-project 0.0.0 get_soname_from_triplet().() |
| 208 | { |
| 209 | local _triplet=( $1 ) |
| 210 | printfscip-shell system . . printf. "%s.%s.%s" $((_triplet[0] - _triplet[2])) ${_triplet[2]} ${_triplet[1]} |
| 211 | } |
| 212 | |
| 213 | |
| 214 | # Args: |
| 215 | # $1: Filename that contains possible duplications. |
| 216 | resolve_name_duplicationscip-shell shell shell-project 0.0.0 resolve_name_duplication().() |
| 217 | { |
| 218 | . "$SCRIPT_DIR/naming.sh" |
| 219 | local _tempfile=/tmp/names-dedupscip-shell filesystem . . `/tmp/names-dedup`. |
| 220 | cpscip-shell system . . cp. "$1" "$_tempfile" |
| 221 | for bad_name in "${!name_mapping[@]}" |
| 222 | do |
| 223 | sedscip-shell system . . sed. -i "s/$bad_name/${name_mapping[$bad_name]}/" "$_tempfile" |
| 224 | done |
| 225 | catscip-shell system . . cat. "$_tempfile" | sortscip-shell system . . sort. | uniqscip-shell system . . uniq. > "$1" |
| 226 | rmscip-shell system . . rm. -- "$_tempfile" |
| 227 | } |
| 228 | |
| 229 | |
| 230 | get_new_authorsscip-shell shell shell-project 0.0.0 get_new_authors().() |
| 231 | { |
| 232 | local _all_time_authors="/tmp/all_time_authorsscip-shell filesystem . . `/tmp/all_time_authors`." _recent_authors="$1" _new_authors="$2" |
| 233 | gitscip-shell system . . git. log | grepscip-shell system . . grep. '^Author' | cutscip-shell system . . cut. -f 1 --complement -d ' ' | sortscip-shell system . . sort. | uniqscip-shell system . . uniq. > "$_all_time_authors" |
| 234 | resolve_name_duplicationscip-shell shell shell-project 0.0.0 resolve_name_duplication(). "$_all_time_authors" |
| 235 | gitscip-shell system . . git. log "$previous_version".. | grepscip-shell system . . grep. '^Author' | sortscip-shell system . . sort. | cutscip-shell system . . cut. -f 1 --complement -d ' ' | uniqscip-shell system . . uniq. > "$_recent_authors" |
| 236 | resolve_name_duplicationscip-shell shell shell-project 0.0.0 resolve_name_duplication(). "$_recent_authors" |
| 237 | diffscip-shell system . . diff. -U 0 "$_all_time_authors" "$_recent_authors" | grepscip-shell system . . grep. -e '^+Author' | sortscip-shell system . . sort. > "$_new_authors" |
| 238 | rmscip-shell system . . rm. "$_all_time_authors" |
| 239 | } |
| 240 | |
| 241 | |
| 242 | clean_library_stashscip-shell shell shell-project 0.0.0 clean_library_stash().() |
| 243 | { |
| 244 | rmscip-shell system . . rm. -rf "$LIBRARY_STASH" |
| 245 | } |
| 246 | |
| 247 | |
| 248 | stash_libraryscip-shell shell shell-project 0.0.0 stash_library().() |
| 249 | { |
| 250 | mkdirscip-shell system . . mkdir. -p "$LIBRARY_STASH" |
| 251 | cpscip-shell system . . cp. "$BUILDDIR/src/"libopenscap.so.* "$LIBRARY_STASH/" |
| 252 | } |
| 253 | |
| 254 | # Args: |
| 255 | # $1: The soname to check for (e.g. 1.2.3) |
| 256 | check_stash_for_sonamescip-shell shell shell-project 0.0.0 check_stash_for_soname().() |
| 257 | { |
| 258 | local _regex |
| 259 | _regex="\.so\.$(echoscip-shell system . . echo. "$1" | sedscip-shell system . . sed. -e 's/\./\\./g')$" |
| 260 | lsscip-shell system . . ls. "$LIBRARY_STASH" | grepscip-shell system . . grep. -q "$_regex" |
| 261 | } |
| 262 | |
| 263 | |
| 264 | check_for_clean_reposcip-shell shell shell-project 0.0.0 check_for_clean_repo().() |
| 265 | { |
| 266 | # check that there is nothing to report by 'status' except untracked files. |
| 267 | gitscip-shell system . . git. status --porcelain=v2 | grepscip-shell system . . grep. -q --invert-match '^?' && diescip-shell shell shell-project 0.0.0 die(). "The repository is not clean, stash your changes to proceed." |
| 268 | } |
| 269 | |
| 270 | |
| 271 | check_that_bump_is_appropriatescip-shell shell shell-project 0.0.0 check_that_bump_is_appropriate().() |
| 272 | { |
| 273 | check_for_clean_reposcip-shell shell shell-project 0.0.0 check_for_clean_repo(). |
| 274 | # check that there is the tag |
| 275 | gitscip-shell system . . git. tag | grepscip-shell system . . grep. -q "$version" || diescip-shell shell shell-project 0.0.0 die(). "The version '$version' doesn't have a tag, so I refuse to bump version that would make it the 'old' version." |
| 276 | # check that tarball with current version is already on GitHub. |
| 277 | curlscip-shell system . . curl. --output /dev/nullscip-shell filesystem . . `/dev/null`. --silent --head --fail "$GITHUB_ROOT/releases/download/$version/openscap-$version.tar.gz" || diescip-shell shell shell-project 0.0.0 die(). "There is not the tarball with '$version' available for download from GitHub." |
| 278 | } |
| 279 | |
| 280 | |
| 281 | release_to_gitscip-shell shell shell-project 0.0.0 release_to_git().() |
| 282 | { |
| 283 | gitscip-shell system . . git. tag | grepscip-shell system . . grep. -q "$version" && diescip-shell shell shell-project 0.0.0 die(). "Something is wrong - there already is a tag $version" |
| 284 | gitscip-shell system . . git. tag "$version" |
| 285 | gitscip-shell system . . git. push |
| 286 | gitscip-shell system . . git. push --tags |
| 287 | } |
| 288 | |
| 289 | |
| 290 | # Args: |
| 291 | # $1: The filename |
| 292 | # $2: The next version |
| 293 | bump_release_in_release_scriptscip-shell shell shell-project 0.0.0 bump_release_in_release_script().() |
| 294 | { |
| 295 | sedscip-shell system . . sed. -i "s/\(^previous_version=\).*/\1$version/" "$1" |
| 296 | sedscip-shell system . . sed. -i "s/\(^version=\).*/\1$2/" "$1" |
| 297 | } |
| 298 | |
| 299 | |
| 300 | # Args: |
| 301 | # $1: The filename |
| 302 | # $2: The next version |
| 303 | bump_release_in_cmakescip-shell shell shell-project 0.0.0 bump_release_in_cmake().() |
| 304 | { |
| 305 | local _version_triplet=($(echoscip-shell system . . echo. "$version" | trscip-shell system . . tr. "." "\n")) |
| 306 | local _version_names=(OPENSCAP_VERSION_MAJOR OPENSCAP_VERSION_MINOR OPENSCAP_VERSION_PATCH) |
| 307 | local _cmake="$OSCAP_REPO_ROOT/CMakeLists.txt" |
| 308 | for i in 0 1 2 |
| 309 | do |
| 310 | sedscip-shell system . . sed. -i "s/set(\s*${_version_names[$i]}\s\+\"[0-9]\+\"\s*)/set(${_version_names[$i]} \"${_version_triplet[$i]}\")/" $_cmake |
| 311 | done |
| 312 | } |
| 313 | |
| 314 | |
| 315 | # Args: |
| 316 | # $1: The next version |
| 317 | bump_releasescip-shell shell shell-project 0.0.0 bump_release().() |
| 318 | { |
| 319 | testscip-shell system . . test. $# -lt 2 || diescip-shell shell shell-project 0.0.0 die(). "Provide the version number as an argument" |
| 320 | check_that_bump_is_appropriatescip-shell shell shell-project 0.0.0 check_that_bump_is_appropriate(). |
| 321 | bump_release_in_cmakescip-shell shell shell-project 0.0.0 bump_release_in_cmake(). "$1" |
| 322 | bump_release_in_release_scriptscip-shell shell shell-project 0.0.0 bump_release_in_release_script(). "$FILE_WITH_VERSIONS" "$1" |
| 323 | gitscip-shell system . . git. diff |
| 324 | gitscip-shell system . . git. add "$OSCAP_REPO_ROOT/CMakeLists.txt" "$FILE_WITH_VERSIONS" |
| 325 | printfscip-shell system . . printf. "Commit with this message:\n%s\n\n%s\n" "Version bump after release." "Next release from the maint-${1%.*} branch will be $1" |
| 326 | } |
| 327 | |
| 328 | # Args: |
| 329 | # $1: Username |
| 330 | # $2: Repository owner |
| 331 | upload_to_gitscip-shell shell shell-project 0.0.0 upload_to_git().() |
| 332 | { |
| 333 | local _username="$1" _repo_owner="$2" |
| 334 | make_distscip-shell shell shell-project 0.0.0 make_dist(). > /dev/nullscip-shell filesystem . . `/dev/null`. 2> /dev/nullscip-shell filesystem . . `/dev/null`. |
| 335 | curlscip-shell system . . curl. -u ":$GITHUB_TOKEN" --data '{"tag_name":"'$version'"}' "https://api.github.com/repos/$_repo_owner/openscap/releases" |
| 336 | |
| 337 | xdg-open "$GITHUB_ROOT/$_repo_owner/openscap/releases/$version" |
| 338 | } |
| 339 | |
| 340 | # Args: |
| 341 | # $1: Token |
| 342 | # $2: Repository owner |
| 343 | # $3: The new version |
| 344 | flip_milestonesscip-shell shell shell-project 0.0.0 flip_milestones().() |
| 345 | { |
| 346 | "$SCRIPT_DIR/move-milestones.py" --owner "$2" --auth-token "$1" "$version" "$3" |
| 347 | } |
| 348 | |
| 349 | |
| 350 | make_news_templatescip-shell shell shell-project 0.0.0 make_news_template().() |
| 351 | { |
| 352 | local _right_boundary=75 _oscap_version_string _oscap_version_length _news_template=NEWS.template _recent_authors="/tmp/recent_authorsscip-shell filesystem . . `/tmp/recent_authors`." _new_authors="/tmp/new_authorsscip-shell filesystem . . `/tmp/new_authors`." |
| 353 | |
| 354 | get_new_authorsscip-shell shell shell-project 0.0.0 get_new_authors(). "$_recent_authors" "$_new_authors" |
| 355 | |
| 356 | _oscap_version_string="openscap-$version" |
| 357 | _oscap_version_length="$(echoscip-shell system . . echo. "$_oscap_version_string" | wcscip-shell system . . wc. -m)" |
| 358 | printfscip-shell system . . printf. "%s%$((_right_boundary - _oscap_version_length))s\n" "$_oscap_version_string" "$(datescip-shell system . . date. +%d-%m-%Y)" > "$_news_template" |
| 359 | |
| 360 | printfscip-shell system . . printf. " - %s\n" "Stats@STATS@" "New features" "Maintenance" >> "$_news_template" |
| 361 | stats= |
| 362 | stats="$stats\n - $(gitscip-shell system . . git. log "$previous_version".. | grepscip-shell system . . grep. '^Author' | wcscip-shell system . . wc. -l) commits from $(catscip-shell system . . cat. "$_recent_authors" | wcscip-shell system . . wc. -l) distinct persons." |
| 363 | stats="$stats\n - $(catscip-shell system . . cat. "$_new_authors" | wcscip-shell system . . wc. -l) new contributors." |
| 364 | stats="$stats\n - $("$SCRIPT_DIR/query-milestones.py" --auth-token "$GITHUB_TOKEN" "$version" issues-closed | wcscip-shell system . . wc. -l) issues closed, $("$SCRIPT_DIR/query-milestones.py" --auth-token "$GITHUB_TOKEN" "$version" prs-merged | wcscip-shell system . . wc. -l) PRs merged." |
| 365 | sedscip-shell system . . sed. -i "s/@STATS@/$stats/" "$_news_template" |
| 366 | |
| 367 | echoscip-shell system . . echo. >> "$_news_template" |
| 368 | echoscip-shell system . . echo. >> "$_news_template" |
| 369 | echoscip-shell system . . echo. "####################### Summaries #######################" >> "$_news_template" |
| 370 | echoscip-shell system . . echo. >> "$_news_template" |
| 371 | |
| 372 | echoscip-shell system . . echo. "Closed issues:" >> "$_news_template" |
| 373 | "$SCRIPT_DIR/query-milestones.py" --auth-token "$GITHUB_TOKEN" "$version" issues-closed | sedscip-shell system . . sed. -e 's/^/ - /' >> "$_news_template" |
| 374 | |
| 375 | echoscip-shell system . . echo. "Merged PRs:" >> "$_news_template" |
| 376 | "$SCRIPT_DIR/query-milestones.py" --auth-token "$GITHUB_TOKEN" "$version" prs-merged | sedscip-shell system . . sed. -e 's/^/ - /' >> "$_news_template" |
| 377 | |
| 378 | echoscip-shell system . . echo. "New authors:" >> "$_news_template" |
| 379 | sedscip-shell system . . sed. -e 's/^/ - /' "$_new_authors" >> "$_news_template" |
| 380 | |
| 381 | echoscip-shell system . . echo. "Recent authors:" >> "$_news_template" |
| 382 | sedscip-shell system . . sed. -e 's/^/ - /' "$_recent_authors" >> "$_news_template" |
| 383 | |
| 384 | rmscip-shell system . . rm. -- "$_recent_authors" "$_new_authors" |
| 385 | } |
| 386 | |
| 387 | |
| 388 | check_release_is_okscip-shell shell shell-project 0.0.0 check_release_is_ok().() |
| 389 | { |
| 390 | grepscip-shell system . . grep. -q "^openscap-$version" "$OSCAP_REPO_ROOT/NEWS" || diescip-shell shell shell-project 0.0.0 die(). "The version '$version' isn't mentioned in the NEWS file." |
| 391 | gitscip-shell system . . git. log -1 | grepscip-shell system . . grep. -q "^\s*openscap-$version$" || diescip-shell shell shell-project 0.0.0 die(). "The openscap release commit is not the previous commit." |
| 392 | } |
| 393 | |
| 394 | |
| 395 | # Args: |
| 396 | # $1: The future version number |
| 397 | release_to_git_and_bump_releasescip-shell shell shell-project 0.0.0 release_to_git_and_bump_release().() |
| 398 | { |
| 399 | local _new_version="$1" |
| 400 | testscip-shell system . . test. -n "$GITHUB_TOKEN" || diescip-shell shell shell-project 0.0.0 die(). "We don't know your GitHub token, so we can't proceed. Get one on https://github.com/settings/tokens and put it in the .env file, so it contains the line GITHUB_TOKEN='<your token here>'" |
| 401 | testscip-shell system . . test. "$1" = "$version" && diescip-shell shell shell-project 0.0.0 die(). "The new version is the same as current version, I am not doing anything." |
| 402 | check_release_is_okscip-shell shell shell-project 0.0.0 check_release_is_ok(). |
| 403 | # release_to_git # GH now add tags to the release automatically |
| 404 | # upload_to_git # to be done when https://github.com/PyGithub/PyGithub/pull/525 is merged. |
| 405 | flip_milestonesscip-shell shell shell-project 0.0.0 flip_milestones(). "$GITHUB_TOKEN" openscap "$_new_version" |
| 406 | bump_releasescip-shell shell shell-project 0.0.0 bump_release(). "$_new_version" |
| 407 | } |