Skip to content

Commit

Permalink
Merge pull request #98 from brack-lang/chore/#77-whats_changed_for_main
Browse files Browse the repository at this point in the history
Add: what's changed script for main branch
  • Loading branch information
momeemt authored Oct 19, 2024
2 parents 584cae2 + 2548f72 commit 1268e47
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ jobs:
id: version
run: |
echo "version=$(cat ./VERSION)" >> $GITHUB_OUTPUT
- name: Generate release note
id: release-note
run: |
bash scripts/release-note.sh v${{ steps.version.outputs.version }} 2>/dev/null | tee release_notes.md
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.version.outputs.version }}
release_name: v${{ steps.version.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: false

2 changes: 1 addition & 1 deletion scripts/prerelease-note.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fi

echo "Comparing PRs merged between $PREV_VERSION and $CURRENT_VERSION..." >&2

PR_LIST=$(gh pr list --state merged --base develop --search "merged:>$PREV_DATE" --json number,title,mergedAt,author --jq 'sort_by(.number)[] | "* \(.title) by @\(.author.login) in https://github.com/brack-lang/brack/pull/\(.number) (merged \(.mergedAt))"')
PR_LIST=$(gh pr list --state merged --base develop --search "merged:>$PREV_DATE" --json number,title,mergedAt,author --jq 'sort_by(.number)[] | "* \(.title) by @\(.author.login) in https://github.com/brack-lang/brack/pull/\(.number)"')

if [ -z "$PR_LIST" ]; then
echo "No PRs were merged between $PREV_VERSION and $CURRENT_VERSION." >&2
Expand Down
35 changes: 35 additions & 0 deletions scripts/release-note.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

if [ $# -ne 1 ]; then
echo "Usage: $0 <release_branch>"
exit 1
fi

CURRENT_VERSION=$1
RELEASE_BRANCH="release/$CURRENT_VERSION"

PREV_VERSION=$(gh release list | grep -v "rc" | awk '{print $1}' | sort -V | tail -n 1)

if [ -z "$PREV_VERSION" ]; then
echo "No previous stable release found." >&2
exit 1
fi

PREV_DATE=$(gh release view "$PREV_VERSION" --json publishedAt --jq '.publishedAt' 2>/dev/null)

if [ -z "$PREV_DATE" ]; then
echo "Previous version $PREV_VERSION not found." >&2
exit 1
fi

echo "Comparing PRs merged between $PREV_VERSION and the new release branch $RELEASE_BRANCH..." >&2

PR_LIST=$(gh pr list --state merged --base develop --search "merged:>$PREV_DATE" --json number,title,mergedAt,author --jq 'sort_by(.number)[] | "* \(.title) by @\(.author.login) in https://github.com/brack-lang/brack/pull/\(.number)"')

if [ -z "$PR_LIST" ]; then
echo "No PRs were merged between $PREV_VERSION and the release branch $RELEASE_BRANCH." >&2
else
echo "PRs merged between $PREV_VERSION and the release branch $RELEASE_BRANCH:" >&2
echo "## What's Changed\n$PR_LIST"
fi

0 comments on commit 1268e47

Please sign in to comment.