-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: configure automated changelog generation
- Loading branch information
1 parent
86ed930
commit 31c45e3
Showing
4 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
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,3 @@ | ||
{ | ||
".": "1.0.0" | ||
} |
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,71 @@ | ||
name: Create Changelog | ||
|
||
on: | ||
push: | ||
branches: | ||
- release/* | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
id-token: write | ||
|
||
jobs: | ||
check-skip: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
should_skip: ${{ steps.check.outputs.should_skip }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
# Check if the commit is a release PR and skip the job | ||
- name: Check if the commit is a release PR | ||
id: check | ||
run: | | ||
COMMIT_MSG=$(git log -1 --pretty=%B) | ||
if [[ $COMMIT_MSG == *"Merge pull request"* && $COMMIT_MSG == *"release-please--branches"* ]]; then | ||
echo "should_skip=true" >> "$GITHUB_OUTPUT" | ||
fi | ||
create-changelog: | ||
runs-on: ubuntu-latest | ||
needs: check-skip | ||
if: needs.check-skip.outputs.should_skip != 'true' | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# Get the version from version.json file and store it in the output file | ||
- name: Get version from version.json | ||
id: retrieve_version | ||
run: | | ||
new_version=$(jq -r '.version' version.json) | ||
if [ -z "$new_version" ]; then | ||
echo "Error: version field is empty or not found in version.json!" | ||
exit 1 | ||
fi | ||
echo "new_version=$new_version" >> "$GITHUB_OUTPUT" | ||
# Set release version for changelog | ||
- name: Set release version for changelog | ||
run: | | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "github-actions[bot]" | ||
git commit --allow-empty -m "chore: release ${{ steps.retrieve_version.outputs.new_version }}" -m "Release-As: ${{ steps.retrieve_version.outputs.new_version }}" | ||
git push | ||
# Create release changelog | ||
- name: Create release changelog | ||
id: release | ||
uses: googleapis/release-please-action@v4 | ||
with: | ||
token: ${{ secrets.RELEASE_PLEASE_TOKEN }} | ||
target-branch: ${{ github.ref_name }} | ||
config-file: .github/workflows/release-please-config.json | ||
manifest-file: .github/workflows/.release-please-manifest-rc.json |
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,57 @@ | ||
{ | ||
"plugins": ["node-workspace", "sentence-case"], | ||
"always-update": true, | ||
"skip-github-release": true, | ||
"pull-request-header": "🤖: I have generated a release changelog", | ||
"pull-request-footer": "This PR was automatically generated by 🤖.", | ||
"include-component-in-tag": false, | ||
"packages": { | ||
".": { | ||
"release-type": "simple", | ||
"changelog-sections": [ | ||
{ | ||
"type": "feat", | ||
"section": "Features", | ||
"hidden": false, | ||
"type-plural": "Features" | ||
}, | ||
{ | ||
"type": "fix", | ||
"section": "Bug Fixes", | ||
"hidden": false, | ||
"type-plural": "Bug Fixes" | ||
}, | ||
{ | ||
"type": "refactor", | ||
"section": "Code Refactoring", | ||
"hidden": false, | ||
"type-plural": "Code Refactoring" | ||
}, | ||
{ | ||
"type": "test", | ||
"section": "Tests", | ||
"hidden": false, | ||
"type-plural": "Tests" | ||
}, | ||
{ | ||
"type": "changed", | ||
"section": "Changed", | ||
"hidden": false, | ||
"type-plural": "Changes" | ||
}, | ||
{ | ||
"type": "docs", | ||
"section": "Documentation", | ||
"hidden": false, | ||
"type-plural": "Documentation" | ||
}, | ||
{ | ||
"type": "chore", | ||
"section": "Miscellaneous", | ||
"hidden": false, | ||
"type-plural": "Chores" | ||
} | ||
] | ||
} | ||
} | ||
} |
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,59 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new_version: ${{ steps.retrieve_version.outputs.new_version }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
# Get the version from version.json file and store it in the output file | ||
- name: Get version from version.json | ||
id: retrieve_version | ||
run: | | ||
new_version=$(jq -r '.version' version.json) | ||
if [ -z "$new_version" ]; then | ||
echo "Error: version field is empty or not found in version.json!" | ||
exit 1 | ||
fi | ||
echo "new_version=$new_version" >> "$GITHUB_OUTPUT" | ||
# Create tag to the repository by using the version from the output file | ||
- name: Create tag | ||
id: create-tag | ||
run: | | ||
new_version=${{ steps.retrieve_version.outputs.new_version }} | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "github-actions[bot]" | ||
git tag -a "$new_version" -m "Release version $new_version" | ||
git push origin "$new_version" | ||
echo "new_tag=$new_version" >> "$GITHUB_OUTPUT" | ||
# Create GitHub release | ||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
new_version=${{ steps.retrieve_version.outputs.new_version }} | ||
new_tag=${{ steps.create-tag.outputs.new_tag }} | ||
sed -n "/## \[$new_version\]/,/## \[/p" CHANGELOG.md | sed '$d' > release_notes.md | ||
gh release create "$new_tag" \ | ||
--title "Release ${{ steps.retrieve_version.outputs.new_version }}" \ | ||
--notes-file release_notes.md \ | ||
--target ${{ github.ref_name }} |