Skip to content

Commit

Permalink
simplify script and check changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
artyom-jaksov-tl committed Oct 28, 2024
1 parent ad865a3 commit d589d2d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/check-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,24 @@ jobs:
run: |
[[ $OLD_VERSION != $NEW_VERSION ]]
- name: Test that version string mathches pattern
run: |
[[ $NEW_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]$ ]]
- name: Sort versions
run: |
echo "GREATER_VERSION=$(echo -e ${OLD_VERSION}\\n${NEW_VERSION} | sort --version-sort | tail -n1)" >> $GITHUB_ENV
if [[ $OLD_VERSION =~ ^[0-9]+(\.[0-9]+)+\.[0-9]$ ]]; then
echo "GREATER_VERSION=$(echo -e ${OLD_VERSION}\\n${NEW_VERSION} | sort --version-sort | tail -n1)" >> $GITHUB_ENV
else
echo "GREATER_VERSION=$NEW_VERSION" >> $GITHUB_ENV
fi
- name: Make sure new version is greater
run: |
[[ $GREATER_VERSION == $NEW_VERSION ]]
- name: Ensure changelog is not empty for the new version
run: |
CHANGELOG=$(sed -n "/^## \[v$NEW_VERSION\]/,/^## \[v/p" CHANGELOG.md | sed -e "s/^## \[v.*\$//" | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba')
[[ -n $CHANGELOG ]]
[[ $CHANGELOG == *"### Added"* || $CHANGELOG == *"### Changed"* || $CHANGELOG == *"### Fixed"* ]]
22 changes: 21 additions & 1 deletion .github/workflows/create-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ jobs:
echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_OUTPUT
- name: Test that version string mathches pattern
run: |
[[ $NEW_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]$ ]]
- name: Test for tag collision
run: |
TAG_EXISTS=0
for EXISTING_TAG in `git tag -l`; do
if [[ $EXISTING_TAG == $NEW_TAG || v$EXISTING_TAG == $NEW_TAG ]]; then
TAG_EXISTS=1
break
fi
done
[[ $TAG_EXISTS == 0 ]]
- name: Ensure changelog is not empty for the new tag
run: |
CHANGELOG=$(sed -n "/^## \[$NEW_TAG\]/,/^## \[v/p" CHANGELOG.md | sed -e "s/^## \[v.*\$//" | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba')
[[ -n $CHANGELOG ]]
[[ $CHANGELOG == *"### Added"* || $CHANGELOG == *"### Changed"* || $CHANGELOG == *"### Fixed"* ]]
- name: Push Git Tag
run: |
git config user.name "GitHub Actions"
Expand All @@ -31,7 +51,7 @@ jobs:
- name: Create changelog diff
run: |
sed -n "/^## \[$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=0 --max-count=1))\]/,/^## \[$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))\]/p" CHANGELOG.md | sed -e "s/^## \[$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=0 --max-count=1))\].*\$//" -e "s/^## \[$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))\].*\$//" | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba' > release_notes.md
sed -n "/^## \[$NEW_TAG\]/,/^## \[v/p" CHANGELOG.md | sed -e "s/^## \[v.*\$//" | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba' > release_notes.md
- name: Create release
id: create_release
Expand Down

0 comments on commit d589d2d

Please sign in to comment.