-
Notifications
You must be signed in to change notification settings - Fork 12
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
🌱 adding release flag #96
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7733f68
adding release flag
savitharaghunathan d349341
removing unused create release workflow
savitharaghunathan 5406e54
adding changelog workflow
savitharaghunathan 9c45b99
fix lint errors
savitharaghunathan dbc3efa
integrate changelog into rel action
savitharaghunathan 79a2ba6
extract secret
savitharaghunathan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
name: Generate Changelog | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
version: | ||
description: 'Semantic version of the release (e.g., v1.2.3)' | ||
required: true | ||
type: string | ||
prev_version: | ||
description: 'Previous release version (e.g., v1.2.2)' | ||
required: false | ||
default: '' | ||
type: string | ||
repository: | ||
description: 'Repository name' | ||
required: false | ||
default: ${{ github.repository }} | ||
type: string | ||
ref: | ||
description: 'Branch or SHA for the release' | ||
required: false | ||
default: ${{ github.ref }} | ||
type: string | ||
github_token: | ||
description: 'GitHub token' | ||
required: false | ||
type: string | ||
secrets: | ||
token: | ||
description: 'GitHub token' | ||
required: false | ||
|
||
|
||
jobs: | ||
changelog: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set GITHUB_TOKEN environment variable | ||
run: | | ||
if [ -n "${{ inputs.github_token }}" ]; then | ||
echo "GITHUB_TOKEN=${{ inputs.github_token }}" >> $GITHUB_ENV | ||
else | ||
echo "GITHUB_TOKEN=${{ secrets.token }}" >> $GITHUB_ENV | ||
fi | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: "${{ env.GITHUB_TOKEN }}" | ||
repository: "${{ inputs.repository }}" | ||
ref: "${{ inputs.ref }}" | ||
|
||
- name: Generate Changelog | ||
id: changelog | ||
env: | ||
GITHUB_TOKEN: "${{ env.GITHUB_TOKEN }}" | ||
run: | | ||
set -x | ||
|
||
REPOSITORY="${{ inputs.repository }}" | ||
SHA="$(git rev-parse HEAD)" | ||
echo "sha=${SHA}" >> "$GITHUB_OUTPUT" | ||
|
||
# Get the previous tag | ||
if [ -n "${{ inputs.prev_version }}" ] && git rev-list "${{ inputs.prev_version }}" 2> /dev/null; then | ||
PREV_TAG="${{ inputs.prev_version }}" | ||
else | ||
PREV_TAG=$(gh api -H "Accept: application/vnd.github+json" "/repos/${{ inputs.repository }}/releases/latest" | jq -r '.tag_name // empty') | ||
fi | ||
|
||
# Generate release notes | ||
NOTES=$(gh api --method POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
"/repos/${{ inputs.repository }}/releases/generate-notes" \ | ||
-f tag_name="${{ inputs.version }}" \ | ||
-f target_commitish="${SHA}" \ | ||
-f previous_tag_name="${PREV_TAG}" | jq -r '.body') | ||
|
||
RELEASE_DOC="${PWD}/release.md" | ||
echo "**Full Changelog**: https://github.com/${REPOSITORY}/commits/${{ inputs.version }}" > "${RELEASE_DOC}" | ||
|
||
filterfunc() { echo "${NOTES}" | grep "^*\s*:$1:" | sed "s/.*:$1:\s*/* /"; } | ||
|
||
BREAKING_CHANGES="$(filterfunc warning)" | ||
if [ -n "${BREAKING_CHANGES}" ]; then | ||
echo "## :warning: Breaking Changes" >> "${RELEASE_DOC}" | ||
echo "${BREAKING_CHANGES}" >> "${RELEASE_DOC}" | ||
echo "" >> "${RELEASE_DOC}" | ||
fi | ||
|
||
FEATURE_CHANGES="$(filterfunc sparkles)" | ||
if [ -n "${FEATURE_CHANGES}" ]; then | ||
echo "## :sparkles: Features" >> "${RELEASE_DOC}" | ||
echo "${FEATURE_CHANGES}" >> "${RELEASE_DOC}" | ||
echo "" >> "${RELEASE_DOC}" | ||
fi | ||
|
||
BUG_FIXES="$(filterfunc bug)" | ||
if [ -n "${BUG_FIXES}" ]; then | ||
echo "## :bug: Bug Fixes" >> "${RELEASE_DOC}" | ||
echo "${BUG_FIXES}" >> "${RELEASE_DOC}" | ||
echo "" >> "${RELEASE_DOC}" | ||
fi | ||
|
||
NEW_CONTRIB=$(echo "${NOTES}" | sed -n "/Contributors/,\$p") | ||
if [ -n "${NEW_CONTRIB}" ]; then | ||
echo "${NEW_CONTRIB}" >> "${RELEASE_DOC}" | ||
else | ||
echo "${NOTES}" | sed -n "/Changelog/,\$p" >> "${RELEASE_DOC}" | ||
fi | ||
|
||
- name: Upload Changelog Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: changelog-artifact | ||
path: release.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't be afraid to replace the existing changelog stuff in here with the new action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
integrated the workflow. ptal. I had to accommodate two different ways of specifying secrets.