Skip to content

Commit

Permalink
Update staging workflow to include changelog in release notes and aut…
Browse files Browse the repository at this point in the history
…o-update version date in changelog (#673)

Signed-off-by: Ilona Shishov <[email protected]>
  • Loading branch information
IlonaShishov authored Jan 2, 2024
1 parent 11c2603 commit b0a086d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,45 @@ jobs:
run: |
echo "version=$(npm version ${{ vars.VERSION_BUMPING_TYPE }} --no-git-tag-version)" >> "$GITHUB_OUTPUT"
- name: Create release notes from changelog
id: release-notes
run: |
notes=$(sed -n "/## ${{ steps.bump.outputs.version }}/,/^##/p" ./CHANGELOG.md | grep -v '##')
if [ -z "$notes" ]; then
echo "Release notes are missing for version ${{ steps.bump.outputs.version }}."
exit 1
else
echo "notes=$notes" >> "$GITHUB_OUTPUT"
fi
- name: Update current version date in changelog
run: |
day_suffix=$(date +"%e" | sed 's/^[[:space:]]*//')
if [ "$day_suffix" = "1" ] || [ "$day_suffix" = "21" ] || [ "$day_suffix" = "31" ]; then
suffix="st"
elif [ "$day_suffix" = "2" ] || [ "$day_suffix" = "22" ]; then
suffix="nd"
elif [ "$day_suffix" = "3" ] || [ "$day_suffix" = "23" ]; then
suffix="rd"
else
suffix="th"
fi
today="$(date +"%b %-d")$suffix $(date +"%Y")"
version="${{ steps.bump.outputs.version }}"
if grep -qE "## $version \([^)]*\)" ./CHANGELOG.md; then
current_date=$(grep -oP "(?<=## $version \()[^\)]*" ./CHANGELOG.md)
if [ "$current_date" != "$today" ]; then
sed -E -i "s/## $version \([^)]*\)/## $version ($today)/" CHANGELOG.md
fi
else
sed -E -i "s/## $version/## $version ($today)/" CHANGELOG.md
fi
- name: Download vsix package artifact
uses: actions/download-artifact@v3
with:
Expand All @@ -84,6 +123,7 @@ jobs:

- name: Commit and push package modifications
run: |
git add CHANGELOG.md
git add package.json
git add package-lock.json
git commit -m "build: updated package with ${{ steps.bump.outputs.version }} [skip ci]"
Expand All @@ -104,6 +144,7 @@ jobs:
const response = await github.request('POST /repos/' + repo_name + '/releases', {
tag_name: '${{ steps.bump.outputs.version }}',
name: '${{ steps.bump.outputs.version }}',
body: ${{ steps.release-notes.outputs.notes }},
prerelease: false,
generate_release_notes: true
})
Expand Down

0 comments on commit b0a086d

Please sign in to comment.