Skip to content

Commit

Permalink
ci: extract changelog for current version
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardosm committed Apr 19, 2024
1 parent 7d541d4 commit 23e4e00
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
report:
needs:
- lint-aux
- extract-changelog
- rustfmt
- clippy
- build-and-test
Expand All @@ -34,6 +35,17 @@ jobs:
- name: Run auxilary lints
run: ./ci/lint-aux.sh

extract-changelog:
- uses: actions/checkout@v4
- name: Extract changelog
run: ./ci/extract-changelog.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: version-changelog
path: version-changelog
if-no-files-found: error

rustfmt:
runs-on: ubuntu-20.04
steps:
Expand Down
24 changes: 24 additions & 0 deletions ci/extract_changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -euo pipefail

. ci/utils.sh

trim_empty_lines() {
awk 'NF { x = 1 } x' | tac | awk 'NF { x = 1 } x' | tac
}

version="$(crate_version rsjsonnet)"
version="${version%-pre}"

input_file="CHANGELOG.md"
output_file="version-changelog"

awk_script='/^##[^#]/ { if (x) { exit }; if ($2 == ver) { x = 1; next } } x'
awk -v ver="$version" "$awk_script" "$input_file" | trim_empty_lines > "$output_file"

if [ ! -s "$output_file" ]; then
echo "Changelog for version $version is empty"
exit 1
fi

echo "Extracted changelog for version $version"
1 change: 1 addition & 0 deletions version_changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Initial release

0 comments on commit 23e4e00

Please sign in to comment.