Skip to content

Commit

Permalink
Generate changelog to release
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslav-fedor-swi committed Sep 18, 2024
1 parent 5300a3b commit 43a8e27
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 15 deletions.
40 changes: 32 additions & 8 deletions .github/cr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,47 @@ main() {

rm -rf .cr-index
mkdir -p .cr-index
RELEASE_NAME=$(yq -e '.name + "-" + .version' deploy/helm/Chart.yaml)

# Generate release notes
if [[ "$RELEASE_NAME" == *"alpha"* ]]; then
echo "Handling alpha release: $RELEASE_NAME"
PREVIOUS_TAG=$(git tag --sort=version:refname | grep alpha | grep -B1 "^swo-k8s-collector" | tail -n 1)

else
echo "Handling standard release: $RELEASE_NAME"
PREVIOUS_TAG=$(git tag --sort=version:refname | grep -v alpha | grep -B1 "^swo-k8s-collector" | tail -n 1)

fi

GIT_PATH="deploy"
echo "# Changed:" > deploy/helm/release-notes.md
git log "$PREVIOUS_TAG"..HEAD --pretty=format:"%s" -- $GIT_PATH | grep -v Merge | awk '{print "* " $0}' >> deploy/helm/release-notes.md

echo "Release notes:"
cat deploy/helm/release-notes.md


echo "Packaging chart ..."
cr package "deploy/helm"

# Find the .tgz file and extract the release name
RELEASE_FILE=$(find .cr-release-packages -name '*.tgz')


echo "Release file: $RELEASE_FILE"



echo 'Releasing chart...'
cr upload -c "$(git rev-parse HEAD)"
cr upload -c "$(git rev-parse HEAD)" --release-notes-file=release-notes.md


echo 'Updating chart repo index...'
cr index

# Find the .tgz file and extract the release name
RELEASE_FILE=$(find .cr-release-packages -name '*.tgz')
RELEASE_NAME=$(basename "$RELEASE_FILE" .tgz)

echo "Release file: $RELEASE_FILE"
echo "Release name: $RELEASE_NAME"

exit 0
echo 'Pushing update...'
push_files "$RELEASE_NAME"

Expand Down Expand Up @@ -93,4 +117,4 @@ create_pr() {
--body "This PR updates the Helm chart index.yaml with the latest release $release_name."
}

main "$@"
main "$@"
17 changes: 13 additions & 4 deletions .github/workflows/buildAndDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Build and Deploy Images
on:
push:
paths-ignore:
- docs/**
- README.md
- deploy/helm/*.md
- "docs/**"
- "*.md"
- "deploy/helm/*.md"
tags:
- '*.*.*'

Expand Down Expand Up @@ -56,6 +56,7 @@ jobs:

build_and_test_windows:
runs-on: windows-2022
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'swo-k8s-collector')
outputs:
image_tag: ${{ steps.generate-tag.outputs.value }}
steps:
Expand Down Expand Up @@ -193,11 +194,16 @@ jobs:
run: |
CURRENT_TAG=${GITHUB_REF#refs/tags/}
PREVIOUS_TAG=$(git tag --sort=version:refname | grep -B1 "^${CURRENT_TAG}$" | head -n 1)
GIT_PATH="build src"
CHANGE_LOG=$(git log "$PREVIOUS_TAG".."$CURRENT_TAG" --pretty=format:"%s" -- "$GIT_PATH" | grep -v Merge | awk '{print "* " $0}')
echo "Current tag: $CURRENT_TAG"
echo "Previous tag: $PREVIOUS_TAG"
echo "Change log:"
echo $CHANGE_LOG
echo "CURRENT_TAG=$CURRENT_TAG" >> $GITHUB_ENV
echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> $GITHUB_ENV
printf "NOTES<<EOF\n%s\nEOF\n" "$CHANGE_LOG" >> $GITHUB_ENV
- name: Create GitHub Release
uses: actions/create-release@v1
Expand All @@ -207,6 +213,9 @@ jobs:
tag_name: ${{ github.ref }} # Use the tag that triggered the workflow
release_name: ${{ github.ref }}
body: |
**Full Changelog**: https://github.com/solarwinds/swi-k8s-opentelemetry-collector/compare/${{ env.PREVIOUS_TAG }}...${{ env.CURRENT_TAG}}
## Changed
${{ env.NOTES }}
**Full Changelog**: https://github.com/solarwinds/swi-k8s-opentelemetry-collector/compare/${{ env.PREVIOUS_TAG }}...${{ env.CURRENT_TAG}}
draft: false
prerelease: false
3 changes: 1 addition & 2 deletions .github/workflows/buildAndTestHelm.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name: Build and Test Helm

on:
push:
pull_request:
paths-ignore:
- docs/**
- README.md
- deploy/helm/*.md
- build/**
- src/**
pull_request:
branches:
- master
- release/**
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/releaseHelm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches:
- master
- release/**
pull_request:
branches:
- master
jobs:
deploy_helm:
runs-on: ubuntu-latest
Expand All @@ -20,6 +23,7 @@ jobs:
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- name: Set up Helm
uses: azure/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: swo-k8s-collector
version: 4.1.0-alpha.3
version: 4.1.0-alpha.5
appVersion: 0.11.5
description: SolarWinds Kubernetes Integration
keywords:
Expand Down

0 comments on commit 43a8e27

Please sign in to comment.