From 2bab4a968bc790a6205bb7a1fcd96c748c53486e Mon Sep 17 00:00:00 2001 From: Yaroslav Grishajev Date: Wed, 4 Dec 2024 12:31:10 +0100 Subject: [PATCH] ci: add changelog gen --- ... => create-console-api-github-release.yml} | 4 +-- ... => create-console-web-github-release.yml} | 4 +-- ...ease-app.yml => create-github-release.yml} | 26 ++++++++++++++----- apps/api/CHANGELOG.md | 2 +- script/extract-changelog.sh | 25 ++++++++++++++++++ 5 files changed, 49 insertions(+), 12 deletions(-) rename .github/workflows/{release-api.yml => create-console-api-github-release.yml} (68%) rename .github/workflows/{release-console-web.yml => create-console-web-github-release.yml} (69%) rename .github/workflows/{release-app.yml => create-github-release.yml} (64%) create mode 100755 script/extract-changelog.sh diff --git a/.github/workflows/release-api.yml b/.github/workflows/create-console-api-github-release.yml similarity index 68% rename from .github/workflows/release-api.yml rename to .github/workflows/create-console-api-github-release.yml index 10d0b0bc..ef8c4189 100644 --- a/.github/workflows/release-api.yml +++ b/.github/workflows/create-console-api-github-release.yml @@ -1,4 +1,4 @@ -name: Draft Api Release +name: Create Console Api GitHub Release on: push: @@ -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 \ No newline at end of file diff --git a/.github/workflows/release-console-web.yml b/.github/workflows/create-console-web-github-release.yml similarity index 69% rename from .github/workflows/release-console-web.yml rename to .github/workflows/create-console-web-github-release.yml index ee5d7c57..7bad5c62 100644 --- a/.github/workflows/release-console-web.yml +++ b/.github/workflows/create-console-web-github-release.yml @@ -1,4 +1,4 @@ -name: Draft Api Release +name: Create Console Web GitHub Release on: push: @@ -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 \ No newline at end of file diff --git a/.github/workflows/release-app.yml b/.github/workflows/create-github-release.yml similarity index 64% rename from .github/workflows/release-app.yml rename to .github/workflows/create-github-release.yml index e795d2ed..b7be9f8d 100644 --- a/.github/workflows/release-app.yml +++ b/.github/workflows/create-github-release.yml @@ -1,4 +1,4 @@ -name: Release App +name: Create GitHub Release on: workflow_call: @@ -16,7 +16,8 @@ permissions: contents: write jobs: - build: + release: + name: Create GitHub Release runs-on: ubuntu-latest steps: @@ -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" @@ -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<> $GITHUB_OUTPUT + echo "$changelog" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + fi fi - name: Create Release diff --git a/apps/api/CHANGELOG.md b/apps/api/CHANGELOG.md index 22af6b80..cd25eb61 100644 --- a/apps/api/CHANGELOG.md +++ b/apps/api/CHANGELOG.md @@ -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 diff --git a/script/extract-changelog.sh b/script/extract-changelog.sh new file mode 100755 index 00000000..1a5cfa95 --- /dev/null +++ b/script/extract-changelog.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: $0 " + 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 \ No newline at end of file