#!/bin/bash #------------------------------------------------------------------------------ set -u # This script generates consolidated release notes for P4D. From 1990's # up thru the 2016.2 release of P4D, a single release notes file was # maintained for the entire history. Starting with 2017.1, release notes # were maintained on a per-release basis. This makes sense, but sometimes # it is helpful to have the old-school single file release notes. # This script generates a single-file (consolidated) release notes file # for all releases up to the current release. # The "current" release is currently hard-coded to r19.2, the Helix Core # 2019.2 release. To Do: Determine the current release dynamically by # downloading and parsing P4D.json from updates.perforce.com. #------------------------------------------------------------------------------ # Functions function msg () { echo -e "$*"; } function errmsg () { msg "\\nError: ${1:-Unknown Error}\\n"; ErrorCount+=1; } function bail () { errmsg "Bailing at $BASH_LINENO: ${1:-Unknown Error}\\n"; exit "${2:-1}"; } #------------------------------------------------------------------------------ # Declarations declare -i ErrorCount=0 declare -a Release declare -a ReleaseNotesURL declare -a ReleaseNotesFile # If UseExistingFiles is 1, skip the 'curl' command to download content # if a file of the expected name already exists. If 0, always run the # curl command. declare -i UseExistingFiles=1 declare CurrentRelease=r19.2 declare FullRelNotesFile="P4ReleaseNotes.${CurrentRelease}.txt" declare CurlCmd= declare -i ReleaseCount declare -i HighIndex declare Version=1.1.3 # Static Data Load Release[0]=r16.2 Release[1]=r17.1 Release[2]=r17.2 Release[3]=r18.1 Release[4]=r18.2 Release[5]=r19.1 Release[6]=r19.2 ### TO DO: ### 1. Determine current release by parsing P4D.json ### See: https://updates.perforce.com/static/P4D/P4D.json ### For this first version we just hard-code to 2019.2. ### 2. Added command line flag to correspond to UseExistingFiles setting. ### 3. Maybe enhance the ouptut, e.g. make it HTML rather than .txt, ### and add a Table of Contents [TOC] at the top. msg "${0##*/} v$Version running on host ${HOSTNAME%%.*} at $(date).\\n" ReleaseCount=${#Release[@]} HighIndex=$((ReleaseCount - 1)) if [[ -r "$FullRelNotesFile" ]]; then msg "Removing existing file $FullRelNotesFile." rm -f "$FullRelNotesFile" ||\ bail "Failed to remove existing [$FullRelNotesFile]." fi touch "$FullRelNotesFile" || bail "Could not write $FullRelNotesFile." msg "Generating Full P4 Release Notes." # Generate release notes in reverse chronological order # (i.e. newest to oldest). for (( i=0; i < ${#Release[@]}; i++)); do r="${Release[$i]}" if [[ "$r" == "r16.2" ]]; then msg "Acquiring release notes from 1990's thru $r." else msg "Acquiring release notes for $r." fi ReleaseNotesURL[$i]="https://www.perforce.com/perforce/$r/user/relnotes.txt" ReleaseNotesFile[$i]="relnotes.${r}.txt" if [[ "$UseExistingFiles" -eq 0 || ! -r "${ReleaseNotesFile[$i]}" ]]; then CurlCmd="curl -s -k -O ${ReleaseNotesURL[$i]}" rm -f relnotes.txt || bail "Failed to remove relnotes.txt" $CurlCmd || bail "Failed to download ${r} release notes with: $CurlCmd" mv relnotes.txt "${ReleaseNotesFile[$i]}" ||\ bail "Failed to move downloaded relnotes.txt file aside." else msg "Using existing downloaded file ${ReleaseNotesFile[$i]}" fi done # Append in reverse order. echo -e " These are consolidated release notes for all versions of P4D. From the 1990's up thru the 2016.2 release of P4D, a single release notes file was maintained for the entire history. Starting with 2017.1, release notes were maintained on a per-release basis. This was a good change for various reasons. Howerver, sometimes it is helpful to have the old-school single file release notes for the entire history -- hence this file. The following is simply a concatenation of official release notes pulled from URLs such as https://www.perforce.com/perforce/${CurrentRelease}/user/relnotes.txt, from r16.2 (which includes all prior history) up thru the current release. Divider lines (a string of '=' characters) have between release notes files." \ >> "$FullRelNotesFile" ||\ bail "Failed to write to $FullRelNotesFile." for i in $(seq $HighIndex -1 0); do echo -e "==============================================================================\\n" >> "$FullRelNotesFile" ||\ bail "Failed to write to $FullRelNotesFile." cat "${ReleaseNotesFile[$i]}" >> "$FullRelNotesFile" ||\ bail "Failed to append ${ReleaseNotesFile[$i]} to $FullRelNotesFile." done msg "Done. Generated $FullRelNotesFile."
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 26232 | C. Thomas Tyler | More output refinements. | ||
#4 | 26231 | C. Thomas Tyler | Output refinements. | ||
#3 | 26230 | C. Thomas Tyler | Removed excess divider line. | ||
#2 | 26229 | C. Thomas Tyler | Added pre-amble. | ||
#1 | 26228 | C. Thomas Tyler |
Added utility for generating consolidated p4d release notes for all versions, along with output files. |