Skip to content

Commit

Permalink
Add changelog script. Add Generate changelog step
Browse files Browse the repository at this point in the history
  • Loading branch information
narin committed Nov 28, 2023
1 parent b671613 commit 4abc794
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .github/scripts/generate-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Check if 'packages', 'current_package' and 'token' are provided as command line arguments
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <current_package> <token>"
exit 1
fi

# Assign command line arguments to variables
packages=("components" "tokens")
current_package="$1"
token="$2"

# Filter out current package
filtered_array=()
for value in "${packages[@]}"
do
[[ $value != $current_package ]] && filtered_array+=($value)
done

# Add regex to each item in array
filtered_array=( "${filtered_array[@]/%/-.*}" )

# Join strings with pipe char
joined_string=$(IFS="|"; echo "${filtered_array[*]}")

# Build full regex string
regex="(.*-(alpha|beta).*|$joined_string)"
echo "Regex: $regex"

github_changelog_generator -u department-of-veterans-affairs -p va-mobile-library -t $token --exclude-tags-regex $regex --no-unreleased
8 changes: 5 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@ jobs:
echo "NEW_VERSION=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "GIT_TAG=${{ inputs.package }}-v$NEW_VERSION" >> "$GITHUB_OUTPUT"
- name: Generate changelog, commit changes and tag
- name: Generate changelog
run: |
chmod +x ../../.github/scripts/generate-changelog.sh
./../../.github/scripts/generate-changelog.sh ${{ inputs.package }} ${{ secrets.VA_MOBILE_ROBOT_GITHUB_PAT }}
- name: Commit changes and tag
run: |
git config --global user.name 'VA Automation Bot'
git config --global user.email '[email protected]'
git pull
git add package.json
cd ../../
bundle exec github_changelog_generator -u department-of-veterans-affairs -p va-mobile-library -t ${{ secrets.VA_MOBILE_ROBOT_GITHUB_PAT }} --exclude-tags-regex ".*-(alpha|beta).*"
git add CHANGELOG.md
git commit -m 'Version bump: ${{ steps.bump-version.outputs.GIT_TAG }}'
git push
Expand Down

0 comments on commit 4abc794

Please sign in to comment.