π Get Release notes #66
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: π Get Release notes | |
on: [workflow_dispatch] | |
jobs: | |
release_notes: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get the list of allowed pull request labels | |
run: | | |
RED='\033[0;31m' | |
NC='\033[0m' | |
FILE_NAME=.pull-requests-allowed-labels-list | |
FILE_PATH=$PROJECT_ROOT/$FILE_NAME | |
if [[ ! -f "$FILE_PATH" ]]; then | |
echo -e "${RED}$FILE_NAME file doesn't exits in the root of the respository${NC}" | |
exit 1 | |
fi | |
echo "LABELS=$(cat $FILE_PATH)" >> $GITHUB_OUTPUT | |
id: get-allowed_labels | |
env: | |
PROJECT_ROOT: ${{ github.workspace }} | |
- name: Generate release notes | |
run: | | |
LATEST_TAG=$(git describe --tags --abbrev=0) | |
NUMBER_OF_COMMITS_SINCE_LAST_RELEASE=$(git log --oneline $LATEST_TAG..HEAD | wc -l | sed 's/^ *//g' | sed 's/ *$//g') | |
IFS=',' read -r -a ALLOWED_LABELS_ARRAY <<< "$ALLOWED_LABELS" | |
OUTPUT="" | |
for LABEL in "${ALLOWED_LABELS_ARRAY[@]}"; do | |
LABEL=$(echo "$LABEL" | sed 's/^ *//g' | sed 's/ *$//g') | |
GIT_LOG_CMD="git log -$NUMBER_OF_COMMITS_SINCE_LAST_RELEASE" | |
FIND_CMD="awk '/<$LABEL>/,/<\/$LABEL>/'" | |
LABEL_OUTPUT="$(eval "$GIT_LOG_CMD | $FIND_CMD")" | |
if [ ! -z "$LABEL_OUTPUT" ]; then | |
REMOVE_TAG_CMD="sed 's/<$LABEL>//g' | sed 's/<\/$LABEL>//g'" | |
OUTPUT=$(echo "$OUTPUT | |
# $LABEL: | |
$LABEL_OUTPUT" | eval $REMOVE_TAG_CMD) | |
fi | |
done | |
if [ ! -z "$OUTPUT" ]; then | |
IFS="" echo "$OUTPUT" | |
IFS="" echo "$OUTPUT" >> $GITHUB_STEP_SUMMARY | |
fi | |
env: | |
ALLOWED_LABELS: ${{ steps.get-allowed_labels.outputs.LABELS }} |