yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
1088e57b6
master
1#!/usr/bin/env bash 2# This script generates a release note. 3# It prints information about breaking-changes first and the rest. 4# The content is mostly based on `git log --oneline --since 202X-YY-ZZ`. 5 6# Usage: the script takes command-line arguments to specify the range of commits to include. 7# You can use either: 8# 1. Date-based range with --since: docs/scripts/release-note.sh --since 2025-08-06 9# 2. Hash-based range with --previous-hash: docs/scripts/release-note.sh --previous-hash abc123 10# 3. Legacy positional argument (deprecated): docs/scripts/release-note.sh 2024-07-01 11 12# This script is supposed to work on all Windows based shell systems including WSL and git-bash. 13# If you make any modifications, please test them, because CI doesn't test this script. 14 15verbose =true 16$ verbose && echo "Reminder: PLEASE make sure your local repo is up-to-date before running the script." >&2 17 18gh ="" 19for candidate in \ 20" $( which gh) " \ 21" $( which gh.exe) " \ 22"/mnt/c/Program Files/GitHub CLI/gh.exe" \ 23"/c/Program Files/GitHub CLI/gh.exe" \ 24"/cygdrive/c/Program Files/GitHub CLI/gh.exe" ;do 25if [ -x" $ candidate " ];then 26gh =" $ candidate " 27break 28fi 29done 30if [" $ gh " ="" ] || ! [ -x" $ gh " ];then 31echo "File not found: gh or gh.exe" 32echo "GitHub CLI can be downloaded from https://cli.github.com" 33exit 1 34fi 35$ verbose && echo "gh is found from: $ gh " >&2 36 37# Parse command-line arguments 38use_hash =false 39since ="" 40previous_hash ="" 41 42while [[$ # -gt 0 ]];do 43case $ 1 in 44 --since) 45since =" $ 2 " 46use_hash =false 47shift 2 48 ;; 49 --previous-hash) 50previous_hash =" $ 2 " 51use_hash =true 52shift 2 53 ;; 54 *) 55# Legacy positional argument support 56if [" $ since " ="" ]&& [" $ previous_hash " ="" ];then 57since =" $ 1 " 58use_hash =false 59else 60echo "Too many arguments or mixed argument styles" 61exit 1 62fi 63shift 64 ;; 65esac 66done 67 68# Validate arguments 69if [" $ since " ="" ]&& [" $ previous_hash " ="" ];then 70echo "This script requires either --since or --previous-hash option." 71echo "Usage: $ 0 [--since DATE | --previous-hash HASH]" 72echo " --since DATE Generate notes since the given date (e.g., 2025-08-06)" 73echo " --previous-hash HASH Generate notes since the given commit hash" 74echo "" 75echo "Legacy usage (deprecated): $ 0 DATE" 76exit 1 77fi 78 79# Get commits based on the specified range 80if [" $ use_hash " = true ];then 81commits =" $( git log --oneline " $ previous_hash " ..HEAD) " 82else 83commits =" $( git log --oneline --since " $ since " ) " 84fi 85commitsCount =" $( echo " $ commits " | wc -l ) " 86 87echo "=== Breaking changes ===" 88breakingChanges ="" 89for i in $( seq " $ commitsCount " ) ;do 90line =" $( echo " $ commits " | head -n " $ i " | tail -1 ) " 91 92# Get PR number from the git commit title 93pr =" $( echo " $ line " | grep '#[1-9][0-9][0-9][0-9][0-9]*' | sed 's|.* (\#\([1-9][0-9][0-9][0-9][0-9]*\))|\1|' ) " 94 [" $ pr " ="" ]&& continue 95 96# Check if the PR is marked as a breaking change 97if " $ gh " issue view" $ pr " --json labels| grep -q 'pr: breaking change' ;then 98breakingChanges +=" $ line " 99fi 100done 101if [" $ breakingChanges " ="" ];then 102echo "No breaking changes" 103else 104echo " $ breakingChanges " 105fi 106echo "" 107 108echo "=== All changes for this release ===" 109for i in $( seq " $ commitsCount " ) ;do 110line =" $( echo " $ commits " | head -n " $ i " | tail -1 ) " 111 112result =" $ line " 113# Get PR number from the git commit title 114pr =" $( echo " $ line " | grep '#[1-9][0-9][0-9][0-9][0-9]*' | sed 's|.* (\#\([1-9][0-9][0-9][0-9][0-9]*\))|\1|' ) " 115if [" $ pr " !="" ];then 116# Mark breaking changes with "[BREAKING]" 117if " $ gh " issue view" $ pr " --json labels| grep -q 'pr: breaking change' ;then 118result ="[BREAKING] $ line " 119fi 120fi 121echo " $ result " 122done