From 6768aa3dd2f154cd8b2d7f50ce3a25f7fdd1e5c1 Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Tue, 8 Oct 2024 17:22:38 +0200 Subject: [PATCH 1/5] Initial version of bash script for creating changelog entries --- make_changelog.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 make_changelog.sh diff --git a/make_changelog.sh b/make_changelog.sh new file mode 100644 index 000000000..43a352329 --- /dev/null +++ b/make_changelog.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Check if two arguments are passed +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Assign arguments to variables +REPO=$1 +TAG=$2 + +# Capitalize the first letter of the tag +CAPITALIZED_TAG="$(echo "$TAG" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}')" + +# Fetch the releases and process them +gh -R "$REPO" release list --json tagName,publishedAt | jq -r '.[] | "\(.tagName) \(.publishedAt)"' | while read tag publishedAt; do + # Format the date to yyyy-mm-dd + date=$(echo $publishedAt | cut -d'T' -f1) + + # Create a file in changelog/{tag} directory with the name {tagName}.mdx + filename="changelog/${TAG}/${tag}.mdx" + + # Check if the file already exists + if [ ! -f "$filename" ]; then + # Fetch the body (release notes) for the current tag + body=$(gh -R "$REPO" release view "$tag" --json body -q '.body') + + # Write the content to the file + cat < "$filename" +--- +title: ${CAPITALIZED_TAG} ${tag} +date: ${date} +tags: [${TAG}] +--- + +${body} +EOF + + echo "Created file: $filename" + else + echo "File already exists: $filename" + fi +done From f1a20f62c0864b5bb1ebf707ca0606a02752670e Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Tue, 8 Oct 2024 17:31:25 +0200 Subject: [PATCH 2/5] Make the script beautiful using 'gum' --- make_changelog.sh | 66 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/make_changelog.sh b/make_changelog.sh index 43a352329..2be18dd13 100644 --- a/make_changelog.sh +++ b/make_changelog.sh @@ -1,14 +1,61 @@ #!/bin/bash -# Check if two arguments are passed -if [ "$#" -ne 2 ]; then - echo "Usage: $0 " - exit 1 +# Check if gum is installed +if ! command -v gum &> /dev/null +then + echo "Error: 'gum' command not found. Please install it using 'brew install gum'." + exit 1 fi -# Assign arguments to variables -REPO=$1 -TAG=$2 +# Prompt for repository if not supplied as an argument +if [ -z "$1" ]; then + REPO=$(gum choose \ + "nextflow-io/nextflow" \ + "MultiQC/MultiQC" \ + "seqeralabs/fusion" \ + "seqeralabs/wave" \ + "seqeralabs/platform" \ + "[ other ]") + + # Set the corresponding name (tag) and colour based on the repository selected + case "$REPO" in + "nextflow-io/nextflow") + TAG="nextflow" + COLOR="32" # Green + ;; + "MultiQC/MultiQC") + TAG="multiqc" + COLOR="214" # Orange + ;; + "seqeralabs/fusion") + TAG="fusion" + COLOR="196" # Red + ;; + "seqeralabs/wave") + TAG="wave" + COLOR="33" # Blue + ;; + "seqeralabs/platform") + TAG="seqera-cloud" + COLOR="93" # Purple + ;; + "[ other ]") + # If "other" is selected, prompt for both repository and tag name + REPO=$(gum input --placeholder "Enter repository name (e.g., org/repo)") + TAG=$(gum input --placeholder "Enter name for filenames and tags array (e.g., custom-name)") + COLOR="240" # Default grey + ;; + esac +else + REPO=$1 + if [ -z "$2" ]; then + TAG=$(gum input --placeholder "Enter name for filenames and tags array (e.g., fusion)") + COLOR="240" # Default grey + else + TAG=$2 + COLOR="240" # Default grey + fi +fi # Capitalize the first letter of the tag CAPITALIZED_TAG="$(echo "$TAG" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}')" @@ -37,8 +84,9 @@ tags: [${TAG}] ${body} EOF - echo "Created file: $filename" + # Output nice feedback with gum, using single-line style and colour coding + gum style --foreground "$COLOR" "Created file: $filename" else - echo "File already exists: $filename" + gum style --foreground "240" "File already exists: $filename" fi done From e7c53e03232fd8aac82caadfd542a6616384e844 Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Tue, 8 Oct 2024 17:42:45 +0200 Subject: [PATCH 3/5] Increase limit to avoid pagination --- make_changelog.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make_changelog.sh b/make_changelog.sh index 2be18dd13..9a7ac86be 100644 --- a/make_changelog.sh +++ b/make_changelog.sh @@ -61,7 +61,7 @@ fi CAPITALIZED_TAG="$(echo "$TAG" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}')" # Fetch the releases and process them -gh -R "$REPO" release list --json tagName,publishedAt | jq -r '.[] | "\(.tagName) \(.publishedAt)"' | while read tag publishedAt; do +gh -R "$REPO" release list --json tagName,publishedAt --limit 1000 | jq -r '.[] | "\(.tagName) \(.publishedAt)"' | while read tag publishedAt; do # Format the date to yyyy-mm-dd date=$(echo $publishedAt | cut -d'T' -f1) From 1e8ae2e4e0ac449b5f40c51ce6167387eecbdd88 Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Tue, 8 Oct 2024 18:00:44 +0200 Subject: [PATCH 4/5] Cleanup --- make_changelog.sh | 64 +++++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/make_changelog.sh b/make_changelog.sh index 9a7ac86be..fff7b93e9 100644 --- a/make_changelog.sh +++ b/make_changelog.sh @@ -17,68 +17,92 @@ if [ -z "$1" ]; then "seqeralabs/platform" \ "[ other ]") - # Set the corresponding name (tag) and colour based on the repository selected + # Set the corresponding product name and colour based on the repository selected case "$REPO" in "nextflow-io/nextflow") - TAG="nextflow" + product="nextflow" COLOR="32" # Green ;; "MultiQC/MultiQC") - TAG="multiqc" + product="multiqc" COLOR="214" # Orange ;; "seqeralabs/fusion") - TAG="fusion" + product="fusion" COLOR="196" # Red ;; "seqeralabs/wave") - TAG="wave" + product="wave" COLOR="33" # Blue ;; "seqeralabs/platform") - TAG="seqera-cloud" + # We will handle the conditional product in the loop for this case COLOR="93" # Purple ;; "[ other ]") - # If "other" is selected, prompt for both repository and tag name + # If "other" is selected, prompt for both repository and product name REPO=$(gum input --placeholder "Enter repository name (e.g., org/repo)") - TAG=$(gum input --placeholder "Enter name for filenames and tags array (e.g., custom-name)") + product=$(gum input --placeholder "Enter name for filenames and tags array (e.g., custom-name)") COLOR="240" # Default grey ;; esac else REPO=$1 if [ -z "$2" ]; then - TAG=$(gum input --placeholder "Enter name for filenames and tags array (e.g., fusion)") + product=$(gum input --placeholder "Enter name for filenames and tags array (e.g., fusion)") COLOR="240" # Default grey else - TAG=$2 + product=$2 COLOR="240" # Default grey fi fi -# Capitalize the first letter of the tag -CAPITALIZED_TAG="$(echo "$TAG" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}')" +# Prompt for whether to fetch all releases or stop at the first existing file +FETCH_ALL=$(gum choose "Just new until an existing entry found" "All releases") + +# Fetch the releases, sort them by publishedAt in descending order +gh -R "$REPO" release list --json tagName,publishedAt --limit 1000 | jq -r 'sort_by(.publishedAt) | reverse | .[] | "\(.tagName) \(.publishedAt)"' | while read tag publishedAt; do + # Skip any release with "nightly" in the tagName + if [[ "$tag" == *"nightly"* ]]; then + gum style --foreground "240" "Skipping nightly release: $tag" + continue + fi -# Fetch the releases and process them -gh -R "$REPO" release list --json tagName,publishedAt --limit 1000 | jq -r '.[] | "\(.tagName) \(.publishedAt)"' | while read tag publishedAt; do # Format the date to yyyy-mm-dd date=$(echo $publishedAt | cut -d'T' -f1) - # Create a file in changelog/{tag} directory with the name {tagName}.mdx - filename="changelog/${TAG}/${tag}.mdx" + # Set the appropriate product based on conditions + if [[ "$REPO" == "seqeralabs/platform" ]]; then + if [[ "$tag" == *"enterprise"* ]]; then + product="seqera-enterprise" + else + product="seqera-cloud" + fi + fi + + # Capitalize the first letter of the product + capitalized_product=$(echo "$product" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}') + + # Create a file in changelog/{product} directory with the name {tagName}.mdx + filename="changelog/${product}/${tag}.mdx" # Check if the file already exists - if [ ! -f "$filename" ]; then + if [ -f "$filename" ]; then + # If the option is to stop at the first existing file, break the loop + if [ "$FETCH_ALL" == "Just new until an existing entry found" ]; then + gum style --foreground "240" "Stopping: Found existing file: $filename" + break + fi + else # Fetch the body (release notes) for the current tag body=$(gh -R "$REPO" release view "$tag" --json body -q '.body') # Write the content to the file cat < "$filename" --- -title: ${CAPITALIZED_TAG} ${tag} +title: ${capitalized_product} ${tag} date: ${date} -tags: [${TAG}] +tags: [${product}] --- ${body} @@ -86,7 +110,5 @@ EOF # Output nice feedback with gum, using single-line style and colour coding gum style --foreground "$COLOR" "Created file: $filename" - else - gum style --foreground "240" "File already exists: $filename" fi done From a351ddfe558b1a00fe7317f8293d871dc44efd29 Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Tue, 8 Oct 2024 22:15:57 +0200 Subject: [PATCH 5/5] MD not MDX, MultiQC not Multiqc --- make_changelog.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/make_changelog.sh b/make_changelog.sh index fff7b93e9..fc50deff0 100644 --- a/make_changelog.sh +++ b/make_changelog.sh @@ -82,9 +82,12 @@ gh -R "$REPO" release list --json tagName,publishedAt --limit 1000 | jq -r 'sort # Capitalize the first letter of the product capitalized_product=$(echo "$product" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}') + if [[ "$capitalized_product" == "Multiqc" ]]; then + capitalized_product="MultiQC" + fi - # Create a file in changelog/{product} directory with the name {tagName}.mdx - filename="changelog/${product}/${tag}.mdx" + # Create a file in changelog/{product} directory with the name {tagName}.md + filename="changelog/${product}/${tag}.md" # Check if the file already exists if [ -f "$filename" ]; then