Skip to content

Commit

Permalink
ci: add changelog gen
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrishajev committed Dec 4, 2024
1 parent 27740d1 commit 2bab4a9
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Draft Api Release
name: Create Console Api GitHub Release

on:
push:
Expand All @@ -13,7 +13,7 @@ permissions:
jobs:
release:
name: Create Release Draft
uses: ./.github/workflows/release-app.yml
uses: ./.github/workflows/create-github-release.yml
secrets: inherit
with:
app: api
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Draft Api Release
name: Create Console Web GitHub Release

on:
push:
Expand All @@ -13,7 +13,7 @@ permissions:
jobs:
release:
name: Create Release Draft
uses: ./.github/workflows/release-app.yml
uses: ./.github/workflows/create-github-release.yml
secrets: inherit
with:
app: deploy-web
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release App
name: Create GitHub Release

on:
workflow_call:
Expand All @@ -16,7 +16,8 @@ permissions:
contents: write

jobs:
build:
release:
name: Create GitHub Release
runs-on: ubuntu-latest

steps:
Expand All @@ -25,7 +26,7 @@ jobs:
with:
fetch-depth: 0

- name: Get Diffs
- name: Get Version and Changelog Updates
id: bumps
run: |
package_file="apps/${{ inputs.app }}/package.json"
Expand All @@ -36,20 +37,31 @@ jobs:
fi
current_version=$(jq -r '.version' "$package_file")
git_tag=$current_version
if [ "${{ inputs.app }}" = "deploy-web" ]; then
current_version="console-web/v$current_version"
git_tag="console-web/v$git_tag"
elif [ "${{ inputs.app }}" = "api" ]; then
current_version="console-api/v$current_version"
git_tag="console-api/v$git_tag"
else
echo "Error: Unsupported app type '${{ inputs.app }}'."
exit 1
fi
has_tag=$(git rev-parse "$current_version" >/dev/null 2>&1 && echo "true" || echo "false")
has_tag=$(git rev-parse "$git_tag" >/dev/null 2>&1 && echo "true" || echo "false")
if [ "$has_tag" = "false" ]; then
echo "version=$current_version" >> $GITHUB_OUTPUT
echo "version=$git_tag" >> $GITHUB_OUTPUT
echo "version=$git_tag"
changelog=$(script/extract-changelog.sh "$current_version" "apps/${{ inputs.app }}/CHANGELOG.md")
if [ -n "$changelog" ]; then
echo "changelog=$changelog"
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$changelog" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
fi
- name: Create Release
Expand Down
2 changes: 1 addition & 1 deletion apps/api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


## [2.37.1](https://github.com/akash-network/console/compare/console-api/v2.37.0...console-api/v2.37.1) (2024-12-04)
## [2.37.2](https://github.com/akash-network/console/compare/console-api/v2.37.0...console-api/v2.37.1) (2024-12-04)


### Bug Fixes
Expand Down
25 changes: 25 additions & 0 deletions script/extract-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 <tag> <changelog_file>"
exit 1
fi

tag=$1
changelog_file=$2

if [ ! -f "$changelog_file" ]; then
echo "Error: Changelog file $changelog_file does not exist."
exit 1
fi

entry=$(awk -v tag="$tag" '
BEGIN { found = 0 }
$0 ~ "^## \\[" tag "\\]" { found = 1; print; next }
found && $0 ~ "^## \\[" { found = 0 }
found { print }
' "$changelog_file")

if [ -n "$entry" ]; then
echo "$entry"
fi

0 comments on commit 2bab4a9

Please sign in to comment.