Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #215: Update changelog script to fix content presented #216

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create Release

Check warning on line 1 in .github/workflows/publish-package.yml

View workflow job for this annotation

GitHub Actions / workflow-yaml-check / yaml-lint-check

1:1 [document-start] missing document start "---"

Check warning on line 1 in .github/workflows/publish-package.yml

View workflow job for this annotation

GitHub Actions / workflow-yaml-check / yaml-lint-check

1:1 [document-start] missing document start "---"

on:
workflow_dispatch:
Expand Down Expand Up @@ -58,42 +58,41 @@
git tag -a v${{ env.version }}-${{ inputs.package-name }}-datastore -m "Release ${{ env.version }}"
git push origin v${{ env.version }}-${{ inputs.package-name }}-datastore

- name: Generate changelog from PRs
- name: Generate changelog from PRs since last tag
id: generate_changelog
run: |
pr_list=$(gh pr list --repo $GITHUB_REPOSITORY --state merged --json number,title,url --jq '.[] | .number')
# Fetch the latest tag as a reference. We are comparing changelogs from latest tag to current one.
latest_tag=$(git describe --tags --abbrev=0)

# Format date for jq comparison
latest_tag_date=$(git log -1 --format=%ai "$latest_tag" | sed 's/.*/"&"/')

datastore_changelog=""
nachet_changelog=""
fertiscan_changelog=""

# Fetch merged PRs since the latest tag
pr_list=$(gh pr list --repo $GITHUB_REPOSITORY --state merged --json number,title,url,mergedAt --jq ".[] | select(.mergedAt > $latest_tag_date) | .number")

for pr in $pr_list; do
files=$(gh pr view "$pr" --repo $GITHUB_REPOSITORY --json files --jq '.files[].path')

# Check for changes in the datastore folder
if echo "$files" | grep -q "^datastore/"; then
pr_info=$(gh pr view "$pr" --repo $GITHUB_REPOSITORY --json title,url | jq -r '"- \(.title) (\(.url))"')
datastore_changelog="$datastore_changelog\n$pr_info"
fi

# Check for changes in the nachet folder
if [ "${{ inputs.package-name }}" = "nachet" ]; then
if echo "$files" | grep -q "^nachet/"; then
pr_info=$(gh pr view "$pr" --repo $GITHUB_REPOSITORY --json title,url | jq -r '"- \(.title) (\(.url))"')
nachet_changelog="$nachet_changelog\n$pr_info"
fi
if echo "$files" | grep -q "^nachet/" && [ "${{ inputs.package-name }}" = "nachet" ]; then
pr_info=$(gh pr view "$pr" --repo $GITHUB_REPOSITORY --json title,url | jq -r '"- \(.title) (\(.url))"')
nachet_changelog="$nachet_changelog\n$pr_info"
fi

# Check for changes in the fertiscan folder
if [ "${{ inputs.package-name }}" = "fertiscan" ]; then
if echo "$files" | grep -q "^fertiscan/"; then
pr_info=$(gh pr view "$pr" --repo $GITHUB_REPOSITORY --json title,url | jq -r '"- \(.title) (\(.url))"')
fertiscan_changelog="$fertiscan_changelog\n$pr_info"
fi
if echo "$files" | grep -q "^fertiscan/" && [ "${{ inputs.package-name }}" = "fertiscan" ]; then
pr_info=$(gh pr view "$pr" --repo $GITHUB_REPOSITORY --json title,url | jq -r '"- \(.title) (\(.url))"')
fertiscan_changelog="$fertiscan_changelog\n$pr_info"
fi
done

# Generate final changelog
changelog="Changelog:\n"

if [ -n "$datastore_changelog" ]; then
Expand Down
Loading