diff --git a/.github/cr.sh b/.github/cr.sh index 0c5a7b46..b500d8b3 100755 --- a/.github/cr.sh +++ b/.github/cr.sh @@ -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" @@ -93,4 +117,4 @@ create_pr() { --body "This PR updates the Helm chart index.yaml with the latest release $release_name." } -main "$@" \ No newline at end of file +main "$@" diff --git a/.github/workflows/buildAndDeploy.yml b/.github/workflows/buildAndDeploy.yml index 0ae29480..0c8182ea 100644 --- a/.github/workflows/buildAndDeploy.yml +++ b/.github/workflows/buildAndDeploy.yml @@ -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: - '*.*.*' @@ -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: @@ -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<> $GITHUB_ENV - name: Create GitHub Release uses: actions/create-release@v1 @@ -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 diff --git a/.github/workflows/buildAndTestHelm.yml b/.github/workflows/buildAndTestHelm.yml index 46060ba8..4d0cbc4b 100644 --- a/.github/workflows/buildAndTestHelm.yml +++ b/.github/workflows/buildAndTestHelm.yml @@ -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/** diff --git a/.github/workflows/releaseHelm.yml b/.github/workflows/releaseHelm.yml index f2a12a22..2f06df88 100644 --- a/.github/workflows/releaseHelm.yml +++ b/.github/workflows/releaseHelm.yml @@ -7,6 +7,9 @@ on: branches: - master - release/** + pull_request: + branches: + - master jobs: deploy_helm: runs-on: ubuntu-latest @@ -20,6 +23,7 @@ jobs: uses: actions/checkout@v4 with: submodules: true + fetch-depth: 0 - name: Set up Helm uses: azure/setup-helm@v3.5 diff --git a/deploy/helm/Chart.yaml b/deploy/helm/Chart.yaml index 97978fc5..a900f394 100644 --- a/deploy/helm/Chart.yaml +++ b/deploy/helm/Chart.yaml @@ -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: