-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
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,49 @@ | ||
name: Create Release | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
create_release: | ||
if: startsWith(github.event.head_commit.message, 'new version') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Extract version from commit message | ||
run: | | ||
# Get the version from the commit message using a regex | ||
if [[ "${{ github.event.head_commit.message }}" =~ new\ version\ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then | ||
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_ENV | ||
else | ||
echo "Commit message does not match 'new version *.*.*' format." | ||
exit 1 | ||
fi | ||
- name: Get previous tag | ||
run: | | ||
previous_tag=$(git describe --tags --abbrev=0 HEAD^) | ||
echo "previous_tag=$previous_tag" >> $GITHUB_ENV | ||
- name: Generate release notes with commit messages | ||
run: | | ||
commits=$(git log "${{ env.previous_tag }}..HEAD" --oneline) | ||
echo "release_body<<EOF" >> $GITHUB_ENV | ||
echo "### Changelog from version ${{ env.previous_tag }} to ${{ env.version }}:" >> $GITHUB_ENV | ||
echo "$commits" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- name: Create GitHub release | ||
uses: actions/create-release@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.LLAMA_ROS_GITHUB_TOKEN }} | ||
with: | ||
tag_name: "${{ env.version }}" | ||
release_name: "${{ env.version }}" | ||
body: "${{ env.release_body }}" | ||
draft: false | ||
prerelease: false |
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