Skip to content

Commit

Permalink
Merge pull request #9 from niwaniwa/feature/release-github-actions
Browse files Browse the repository at this point in the history
feature: automatic release creation
  • Loading branch information
niwaniwa authored Jul 17, 2023
2 parents dc32f82 + 437015b commit d3972ca
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,30 @@ jobs:

- name: Extract tag name
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
run: echo "RELEASE_VERSION=${GITHUB_REF##*/v}" >> $GITHUB_ENV

- name: Extract release notes
id: release_notes
run: |
RELEASE_NOTES=""
RELEASE_NOTES="## Version ""$RELEASE_VERSION"$'\n'
CURRENT_LINE=0
while IFS= read -r line; do
if [[ "$CURRENT_LINE" == 1 ]]; then
RELEASE_NOTES="$RELEASE_NOTES"$'\n'"$line"
fi
if [[ "$line" == "## [$RELEASE_VERSION] - "* ]]; then
CURRENT_LINE=1
elif [[ "$CURRENT_LINE" == 1 && "$line" == "## ["* ]]; then
CURRENT_LINE=0
fi
if [[ "$CURRENT_LINE" == 1 ]]; then
RELEASE_NOTES="$RELEASE_NOTES"$'\n'"$line"
fi
done < "CHANGELOG.md"
RELEASE_NOTES="${RELEASE_NOTES:2}"
echo "::set-output name=body::$RELEASE_NOTES"
echo "$RELEASE_NOTES"
echo "$RELEASE_NOTES" > release_notes_diff.txt
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
release_name: v${{ env.RELEASE_VERSION }}
body: ${{ steps.release_notes.outputs.body }}
tag_name: v${{ env.RELEASE_VERSION }}
name: v${{ env.RELEASE_VERSION }}
body_path: ${{ github.workspace }}/release_notes_diff.txt

0 comments on commit d3972ca

Please sign in to comment.