From d36b309c9c18e8c2e31cf31f9ca9d7007d10322d Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 6 Jun 2026 18:42:13 +0330 Subject: [PATCH] feat: update --- .github/workflows/release.yaml | 115 +++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..9cf510d --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,115 @@ +name: Release + +on: + push: + tags: + - "v*" + - "kloud-csi-*" + +permissions: + contents: write + packages: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Resolve release version + id: version + run: | + tag="${{ github.ref_name }}" + if [[ "$tag" == v* ]]; then + echo "app_version=${tag#v}" >> "$GITHUB_OUTPUT" + echo "is_app_release=true" >> "$GITHUB_OUTPUT" + else + echo "is_app_release=false" >> "$GITHUB_OUTPUT" + fi + + - name: Install Helm + if: steps.version.outputs.is_app_release == 'true' + uses: azure/setup-helm@v4 + + - name: Package Helm chart + if: steps.version.outputs.is_app_release == 'true' + run: | + version="${{ steps.version.outputs.app_version }}" + chart_dir="charts/kloud-csi" + + sed -i "s/^version:.*/version: ${version}/" "${chart_dir}/Chart.yaml" + sed -i "s/^appVersion:.*/appVersion: \"${version}\"/" "${chart_dir}/Chart.yaml" + + helm lint "${chart_dir}" + mkdir -p dist + helm package "${chart_dir}" --destination dist + echo "CHART_PACKAGE=dist/kloud-csi-${version}.tgz" >> "$GITHUB_ENV" + + - name: Build changelog + id: changelog + uses: mikepenz/release-changelog-builder-action@v5 + with: + configurationJson: | + { + "template": "#{{CHANGELOG}}\n\n**Full Changelog**: #{{RELEASE_DIFF}}", + "categories": [ + { + "title": "## Features", + "commits": ["^feat", "^feature"] + }, + { + "title": "## Bug Fixes", + "commits": ["^fix", "^Fix"] + }, + { + "title": "## Other Changes", + "commits": [".*"] + } + ] + } + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create or update GitHub release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ github.ref_name }} + CHANGELOG: ${{ steps.changelog.outputs.changelog }} + run: | + if gh release view "$TAG" >/dev/null 2>&1; then + gh release edit "$TAG" --notes "$CHANGELOG" + else + gh release create "$TAG" --title "$TAG" --notes "$CHANGELOG" + fi + + - name: Upload Helm chart to release + if: steps.version.outputs.is_app_release == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ github.ref_name }} + run: gh release upload "$TAG" "$CHART_PACKAGE" --clobber + + - name: Log in to GHCR + if: steps.version.outputs.is_app_release == 'true' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push chart to OCI registry + if: steps.version.outputs.is_app_release == 'true' + run: | + owner=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]') + helm push "$CHART_PACKAGE" "oci://ghcr.io/${owner}/charts" + + - name: Make OCI chart public + if: steps.version.outputs.is_app_release == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + owner=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]') + gh api --method PATCH "/orgs/${owner}/packages/container/charts%2Fkloud-csi/visibility" -f visibility=public || true