Skip to content

Commit

Permalink
ci: fix dependabot script not bumping packages in changeset (#2640)
Browse files Browse the repository at this point in the history
Co-authored-by: Chad Nehemiah <chad.nehemiah94@gmail.com>
Co-authored-by: Anderson Arboleya <anderson@arboleya.me>
Co-authored-by: Peter Smith <peter@blueoceancomputing.co.uk>
  • Loading branch information
4 people authored Jun 29, 2024
1 parent e3d6b94 commit 78927e4
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions scripts/changeset/dependabot-changeset.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
#!/bin/bash

# Get the latest commit hash on the current branch
latest_commit=$(git rev-parse HEAD)
# Get the first dependabot commit which contains the changed files
first_commit=$(git log master..HEAD --oneline --reverse | xargs | awk '{print $1;}')
echo "First commit: $first_commit"

# Get the list of changed package directories
changed_packages=$(git diff-tree --no-commit-id --name-only -r "$latest_commit" | grep "packages/" | sed -E 's|packages/([^/]+)/.*|\1|')
changed_files=$(git diff-tree --no-commit-id --name-only -r "$first_commit")
echo "changed files: $changed_files"

# Get the list of relevant package.json changes
changed_packages=$(echo "$changed_files" | grep -E "packages/.+/package.json" | xargs jq -r '.name')
changed_templates=$(echo "$changed_files" | grep -E "templates/.+/package.json")

echo "changed packages: $changed_packages"
echo "changed templates: $changed_templates"

# Create the changeset content
changeset_content="---\n"

for package in $changed_packages; do
package_name=$(jq -r '.name' "packages/$package/package.json")
changeset_content+="\"$package_name\": patch\n"
changeset_content+="\"$package\": patch\n"
done

# Add create-fuels to changeset
# if a template changed and create-fuels isn't in the changeset already
if [[ -n "$changed_templates" && "${changed_packages}" != *"create-fuels"* ]]; then
changeset_content+="\"create-fuels\": patch\n"
fi

changeset_content+="---\n\n"

# Append the pull request title to the changeset content
Expand All @@ -26,4 +41,4 @@ changeset_file=$(git status --porcelain .changeset/*.md | sed -E 's/.*(\.changes
echo "$changeset_file"

# Write the changeset content to the file
echo -e "$changeset_content" > "$changeset_file"
echo -e "$changeset_content" >"$changeset_file"

0 comments on commit 78927e4

Please sign in to comment.