#!/bin/bash #------------------------------------------------------------------------------ set -u declare Version=1.1.3 # For usage info, see ReleaseProcessOverview.md # Micro functions. function dbg () { [[ $DEBUG -eq 1 ]] && echo -e "DEBUG: $*" >&2; } function msg () { echo -e $*; } function bail () { msg "\nError: ${1:-Unknown Error}\n"; exit ${2:-1}; } function cmd () { msg "Executing: $*"; $*; return $?; } # $Product can be mixed case, $product is the lowercase form. declare Product=SDP declare product=$(echo $Product | tr '[:upper:]' '[:lower:]') declare OldCL= declare NewCL= declare UpdateCL= declare NewEpochTime= declare DateString= declare Description= declare Type= declare TypeTag= declare DefaultMajorVersion= declare MajorVersion= declare VersionString= declare Input= declare DEBUG=0 # Folder name is assumed to be Product name, normalized to lowercase. declare DevBranch="//guest/perforce_software/$product/dev" declare MainBranch="//guest/perforce_software/$product/main" declare VersionDepotFile=$DevBranch/Version declare VersionFile= declare RelNotesDepotFile=$DevBranch/doc/ReleaseNotes.txt declare RelNotesFile= declare NewReleaseTag= declare OS= declare TmpDir=/tmp/tmp.${0##*/}.$RANDOM.$$ declare NewVersionFile=$TmpDir/Version declare NewRelNotesFile=$TmpDir/ReleaseNotes.txt declare TmpFile=$TmpDir/temp msg "Start ${0##*/} v$Version at $(date)." mkdir $TmpDir || bail "Could not create temp dir $TmpDir" VersionFile=$(p4 -ztag -F %path% where $VersionDepotFile) RelNotesFile=$(p4 -ztag -F %path% where $RelNotesDepotFile) if [[ -n "$(p4 -s opened $DevBranch/... 2>/dev/null | grep 'not opened on this client')" ]]; then msg "Verified: Nothing is checked out in the $Product dev branch." else bail "Failed to verify that no files are checked out in the $Product dev branch. The 'p4 opened' check shows:\n$(p4 -s opened $DevBranch/...)\nAborting." fi if [[ -n "$(p4 status $DevBranch/... | grep 'no file(s) to reconcile.')" ]]; then msg "Verified: No excesss files are in the dev branch in your workspace." else bail "The 'p4 status' check failed for $DevBranch. The 'p4 status' check shows:\n$(p4 status $DevBranch/...)\nAborting." fi if [[ -n "$(p4 -s opened $MainBranch/... 2>/dev/null | grep 'not opened on this client')" ]]; then msg "Verified: Nothing is checked out in the $Product main branch." else bail "Failed to verify that no files are checked out in the $Product main branch. The 'p4 opened' check shows:\n$(p4 -s opened $MainBranch/...)\nAborting." fi if [[ -n "$(p4 status $MainBranch/... | grep 'no file(s) to reconcile.')" ]]; then msg "Verified: No excesss files are in the main branch in your workspace." else bail "The 'p4 status' check failed for $MainBranch. The 'p4 status' check shows:\n$(p4 status $MainBranch/...)\nAborting." fi msg Syncing $Product dev and main Branches. cmd p4 -s sync $DevBranch/... $MainBranch/... || bail "Failed to sync $Product dev and main branches. Aborting." DefaultMajorVersion=$(cat $VersionFile|cut -d '/' -f 3|cut -d ' ' -f 1) DefaultMajorVersion=$(echo $DefaultMajorVersion) echo -e -n "\n\nEnter $Product Major Version for this release [$DefaultMajorVersion]: " read -e Input Input=$(echo $Input) MajorVersion=${Input:-$DefaultMajorVersion} NewCL=$(p4 -ztag -F %change% changes -s submitted -m 1 $DevBranch/...) [[ -n "$NewCL" ]] ||\ bail "Could not get latest changelist in dev branch [$DevBranch]. Aborting." NewEpochTime=$(p4 -ztag -F %time% describe -s $NewCL) [[ -n "$NewEpochTime" ]] ||\ bail "Could not get epoch time for change [$NewCL]. Aborting." if [[ $(uname -s) == Darwin ]]; then # At least as of Mac OSX 10.11.6 El Capitan, the 'time' command is different # on Linux. DateString=$(date -j -r $NewEpochTime +'%Y/%m/%d') else DateString=$(date -d @$NewEpochTime +'%Y/%m/%d') fi [[ -n "$DateString" ]] ||\ bail "Could not get date string from epoch time [$NewEpochTime]." VersionString=${MajorVersion}.${NewCL} OldCL=$(cat $VersionFile|cut -d '/' -f 4) OldCL=${OldCL%% *} echo "Rev. SDP/MultiArch/$MajorVersion/$NewCL ($DateString)." > $NewVersionFile NewReleaseTag=$(head -1 $NewVersionFile) NewReleaseTag=${NewReleaseTag%\.} if [[ "$OldCL" == "$NewCL" ]]; then bail "There appear to have been no changes to the dev branch since the last release. Aborting." fi declare -i i= firstNLines= lastNLines= i=0; while read line; do [[ $line == "CHANGE HISTORY:" ]] && break i=$((i+1)) done < $RelNotesFile dbg i=$i firstNLines=$((i+2)) dbg FNL=$firstNLines lines=$(cat $RelNotesFile | wc -l) lines=$(echo $lines) dbg Total Lines=$lines lastNLines=$((lines-$firstNLines+1)) dbg LNL=$lastNLines dbg head -$firstNLines $RelNotesFile head -$firstNLines $RelNotesFile > $NewRelNotesFile echo -e "Released: $NewReleaseTag\n\nJobs Fixed since change $OldCL up to $NewCL (F=Feature, B=Bug):\n" >> $NewRelNotesFile # Increment $OldCL by 1 after the message above, to exclude # jobs associated with the last CL of the prior release. OldCL=$((OldCL+1)) for j in $(p4 -ztag -F %Job% jobs $DevBranch/...@${OldCL},@${NewCL}); do Description=$(p4 -ztag -F %Description% job -o $j|head -1) Type=$(p4 -ztag -F %Type% job -o $j) # Use a one-letter shorthand for job types. case $Type in (Feature) TypeTag=F;; (Bug) TypeTag=B;; (*) TypeTag=$Type;; # For unrecognized types, use the given name. esac echo -e "$j ($TypeTag): $Description" >> $NewRelNotesFile done dbg tail -$lastNLines $RelNotesFile tail -$lastNLines $RelNotesFile >> $NewRelNotesFile cmd p4 -s edit $VersionFile $RelNotesFile ||\ bail "Failed to checkout Version and Release Notes files [$VersionFile and $RelNotesFile]." cmd mv -f $NewRelNotesFile $RelNotesFile ||\ bail "Failed to move new Release Notes file in place." cmd mv -f $NewVersionFile $VersionFile ||\ bail "Failed to move new Version file in place." msg "\nVersion file from/to:" cmd p4 diff $VersionFile msg "\nUpdates to releease notes:" cmd p4 diff $RelNotesFile echo -e "Change: new\n\nDescription:\n\tUpdated Version to release $Product $VersionString.\n\nFiles:\n\t$RelNotesDepotFile\n\t$VersionDepotFile" > $TmpFile msg "Creating new pending changelist for Version and Release Notes files." p4 -s change -i < $TmpFile ||\ bail "Failed to create changelist with Version and Release Notes files." UpdateCL=$(p4 -ztag -F %change% opened -m 1 $DevBranch/...) [[ -n "$UpdateCL" ]] ||\ bail "Could not newly changelist. Aborting." msg "\nMassage the release notes and changelist description as needed.\nThen do:\n\tp4 -s submit -c $UpdateCL" /bin/rm -rf "$TmpDir"
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#24 | 29835 | C. Thomas Tyler |
Updated Release Process to account for migration to JIRA. Removed scripts made obsolete by this change to avoid confusion. |
||
#23 | 29020 | C. Thomas Tyler | Added support for new 'Doc' type in jobspec. | ||
#22 | 28991 | C. Thomas Tyler | Enhanced to change ':revdate:' field in ReleaseNotes.adoc. | ||
#21 | 28258 | C. Thomas Tyler | Enhanced to apply new post-2020.1 versions. | ||
#20 | 27538 | C. Thomas Tyler | Added explicit BASH version check. | ||
#19 | 27523 | C. Thomas Tyler | Added release header. | ||
#18 | 27461 | C. Thomas Tyler | Refined AsciiDoc generated doc update part of release process. | ||
#17 | 27365 | C. Thomas Tyler |
rel_notes.sh v1.4.1: * Fixed bug in genererated per-job adoc refs. |
||
#16 | 27329 | C. Thomas Tyler |
Updated user instructions in release notes script, to include generation of adoc-based release notes. |
||
#15 | 27119 | C. Thomas Tyler | Further adoc adaptation. | ||
#14 | 27117 | C. Thomas Tyler | Corrected file extension. | ||
#13 | 27115 | C. Thomas Tyler |
Updated SDP release process doc, adding info on how to ensure generated script docs are incorporated in AsciiDoc files. Adjusted generated release notes file from .txt to .adoc format. Updated rel_notes.sh to add bulleted list items with links to each fixed job. Updated old release notes content to use new format (using disposable link conversion scripts). |
||
#12 | 26884 | C. Thomas Tyler | Fixed issue with errors going to stderr not being caught in grep expressions. | ||
#11 | 25503 | C. Thomas Tyler | rel_notes.sh: Shellcheck compliance only. | ||
#10 | 25244 | C. Thomas Tyler | Enhanced to support patch release versions. | ||
#9 | 21719 | C. Thomas Tyler |
Added '-n' flag to preview release notes. Added internal comments. |
||
#8 | 21336 | C. Thomas Tyler |
Added check to fisrt a merge down preview, and bail if one is required. This prevents generating incorrect release notes that don't account for changes made directly in main. Also enhanced temp file handling. |
||
#7 | 21237 | C. Thomas Tyler | Typo. | ||
#6 | 20765 | C. Thomas Tyler | Tweaked. | ||
#5 | 20756 | C. Thomas Tyler | Fixed bug showing correct new version in release notes. | ||
#4 | 20516 | C. Thomas Tyler | Cosmetic tweak and enhancement to end-user instructions. | ||
#3 | 20479 | C. Thomas Tyler |
Added release process overview script. Overhauled release notes helper script. Fixed bug that listed a job in the release notes for the current release that was associated with the last changelist of the prior release. Updated more of the manual steps in the SDP release process. |
||
#2 | 19693 | C. Thomas Tyler |
Minor enhancements to release notes script: * Added job type (Bug/Feature) for each job. * Generates more of the text needed to copy/paste into release notes file. |
||
#1 | 17316 | C. Thomas Tyler | Added script to help generate release notes for SDP. |