-
Notifications
You must be signed in to change notification settings - Fork 162
feat: Helm chart release synchronization #5187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -20,16 +20,60 @@ jobs: | |||||||
release_created: ${{ steps.release-please.outputs.release_created }} | ||||||||
tag_name: ${{ steps.release-please.outputs.tag_name }} | ||||||||
version: ${{ steps.release-please.outputs.version }} | ||||||||
major: ${{ steps.release-please.outputs.major }} | ||||||||
minor: ${{ steps.release-please.outputs.minor }} | ||||||||
patch: ${{ steps.release-please.outputs.patch }} | ||||||||
steps: | ||||||||
- name: Release Please | ||||||||
id: release-please | ||||||||
uses: googleapis/release-please-action@a02a34c4d625f9be7cb89156071d8567266a2445 # v4.2.0 | ||||||||
with: | ||||||||
token: ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }} | ||||||||
|
||||||||
publish-npm-package: | ||||||||
validate-versions: | ||||||||
needs: release-please | ||||||||
runs-on: ubuntu-latest | ||||||||
if: "${{ needs.release-please.outputs.release_created }}" | ||||||||
steps: | ||||||||
- name: Checkout | ||||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||||||||
|
||||||||
- name: Validate chart version synchronization | ||||||||
run: | | ||||||||
APP_VERSION="${{ needs.release-please.outputs.version }}" | ||||||||
CHART_APP_VERSION=$(yq e '.appVersion' charts/gitops-server/Chart.yaml) | ||||||||
CHART_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml) | ||||||||
IMAGE_TAG=$(yq e '.image.tag' charts/gitops-server/values.yaml) | ||||||||
|
||||||||
echo "Application Version: $APP_VERSION" | ||||||||
echo "Chart AppVersion: $CHART_APP_VERSION" | ||||||||
echo "Chart Version: $CHART_VERSION" | ||||||||
echo "Image Tag: $IMAGE_TAG" | ||||||||
|
||||||||
# Validate that chart appVersion matches application version | ||||||||
if [[ "$CHART_APP_VERSION" != "$APP_VERSION" ]]; then | ||||||||
echo "Error: Chart appVersion ($CHART_APP_VERSION) does not match application version ($APP_VERSION)" | ||||||||
exit 1 | ||||||||
fi | ||||||||
|
||||||||
# Validate that image tag matches application version | ||||||||
if [[ "$IMAGE_TAG" != "$APP_VERSION" ]]; then | ||||||||
echo "Error: Image tag ($IMAGE_TAG) does not match application version ($APP_VERSION)" | ||||||||
exit 1 | ||||||||
fi | ||||||||
|
||||||||
# Validate that chart version follows expected pattern (remove 'v' prefix from app version) | ||||||||
EXPECTED_CHART_VERSION=$(echo "$APP_VERSION" | sed 's/^v//') | ||||||||
if [[ "$CHART_VERSION" != "$EXPECTED_CHART_VERSION" ]]; then | ||||||||
echo "Error: Chart version ($CHART_VERSION) does not match expected version ($EXPECTED_CHART_VERSION)" | ||||||||
exit 1 | ||||||||
fi | ||||||||
|
||||||||
echo "All versions are synchronized correctly" | ||||||||
|
||||||||
publish-npm-package: | ||||||||
needs: [release-please, validate-versions] | ||||||||
runs-on: ubuntu-latest | ||||||||
permissions: | ||||||||
packages: write # needed for GitHub Packages registry access | ||||||||
if: "${{ needs.release-please.outputs.release_created }}" | ||||||||
|
@@ -48,7 +92,7 @@ jobs: | |||||||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||
|
||||||||
build-and-push-image: | ||||||||
needs: release-please | ||||||||
needs: [release-please, validate-versions] | ||||||||
uses: ./.github/workflows/build-push-image.yaml | ||||||||
with: | ||||||||
file: gitops-server.dockerfile | ||||||||
|
@@ -67,48 +111,81 @@ jobs: | |||||||
if: "${{ needs.release-please.outputs.release_created }}" | ||||||||
|
||||||||
build-and-push-chart: | ||||||||
needs: | ||||||||
- release-please | ||||||||
- build-and-push-image # as we want to push chart when images are available | ||||||||
needs: [release-please, validate-versions, build-and-push-image] | ||||||||
runs-on: ubuntu-latest | ||||||||
permissions: | ||||||||
contents: read # for actions/checkout to fetch code | ||||||||
id-token: write # for Cosign to be able to sign chart with GHA token | ||||||||
packages: write # for helm to push OCI chart | ||||||||
if: "${{ needs.release-please.outputs['charts/gitops-server--release_created'] }}" | ||||||||
if: "${{ needs.release-please.outputs.release_created }}" | ||||||||
steps: | ||||||||
- name: Checkout | ||||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||||||||
|
||||||||
- name: Validate chart before packaging | ||||||||
run: | | ||||||||
APP_VERSION="${{ needs.release-please.outputs.version }}" | ||||||||
CHART_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml) | ||||||||
|
||||||||
echo "Packaging chart version: $CHART_VERSION for app version: $APP_VERSION" | ||||||||
|
||||||||
# Validate chart syntax | ||||||||
helm lint charts/gitops-server/ | ||||||||
|
||||||||
- name: Package chart | ||||||||
run: | | ||||||||
mkdir helm-release | ||||||||
helm package charts/gitops-server/ -d helm-release | ||||||||
|
||||||||
# List packaged chart for verification | ||||||||
ls -la helm-release/ | ||||||||
|
||||||||
- name: Log in to the Container registry | ||||||||
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 | ||||||||
with: | ||||||||
registry: ghcr.io | ||||||||
username: ${{ github.actor }} | ||||||||
password: ${{ secrets.GITHUB_TOKEN }} | ||||||||
|
||||||||
- name: Publish chart | ||||||||
id: publish-chart | ||||||||
run: | | ||||||||
helm push helm-release/weave-gitops-${{ needs.release-please.outputs['charts/gitops-server--version'] }}.tgz \ | ||||||||
oci://ghcr.io/weaveworks/charts &> helm-release/push-metadata.txt | ||||||||
CHART_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml) | ||||||||
CHART_FILE="helm-release/weave-gitops-${CHART_VERSION}.tgz" | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The chart name 'weave-gitops' is hardcoded in multiple places. Consider extracting it to a variable or using the chart name from Chart.yaml to improve maintainability.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||
|
||||||||
if [[ ! -f "$CHART_FILE" ]]; then | ||||||||
echo "Error: Chart file $CHART_FILE not found" | ||||||||
ls -la helm-release/ | ||||||||
exit 1 | ||||||||
fi | ||||||||
|
||||||||
echo "Publishing chart: $CHART_FILE" | ||||||||
helm push "$CHART_FILE" oci://ghcr.io/weaveworks/charts &> helm-release/push-metadata.txt | ||||||||
|
||||||||
# Extract digest for signing | ||||||||
CHART_DIGEST=$(awk '/Digest: /{print $2}' helm-release/push-metadata.txt) | ||||||||
echo "Chart digest: $CHART_DIGEST" | ||||||||
echo "digest=$CHART_DIGEST" >> $GITHUB_OUTPUT | ||||||||
|
||||||||
# Display push metadata for debugging | ||||||||
echo "Push metadata:" | ||||||||
cat helm-release/push-metadata.txt | ||||||||
|
||||||||
- name: Install cosign | ||||||||
uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3.9.1 | ||||||||
|
||||||||
- name: Keyless signing of chart | ||||||||
run: | | ||||||||
cosign sign --yes ghcr.io/weaveworks/charts@${{ steps.publish-chart.outputs.digest }} | ||||||||
|
||||||||
- name: Verify the chart signing | ||||||||
run: | | ||||||||
cosign verify ghcr.io/weaveworks/charts@${{ steps.publish-chart.outputs.digest }} \ | ||||||||
--certificate-identity "https://github.com/${{ github.workflow_ref }}" \ | ||||||||
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" | jq . | ||||||||
|
||||||||
goreleaser: | ||||||||
needs: release-please | ||||||||
needs: [release-please, validate-versions] | ||||||||
runs-on: ubuntu-latest | ||||||||
permissions: | ||||||||
contents: read # for actions/checkout to fetch code | ||||||||
|
@@ -136,3 +213,28 @@ jobs: | |||||||
env: | ||||||||
GITHUB_TOKEN: ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }} | ||||||||
BOT_TOKEN: ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }} | ||||||||
|
||||||||
create-release-summary: | ||||||||
needs: [release-please, validate-versions, publish-npm-package, build-and-push-image, build-and-push-chart, goreleaser] | ||||||||
runs-on: ubuntu-latest | ||||||||
if: "${{ needs.release-please.outputs.release_created }}" | ||||||||
steps: | ||||||||
- name: Create release summary | ||||||||
run: | | ||||||||
echo "# Release Summary" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "**Version:** ${{ needs.release-please.outputs.version }}" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "**Tag:** ${{ needs.release-please.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "## Components Released" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "- Application binaries (GoReleaser)" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "- Container images (ghcr.io/weaveworks/wego-app)" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "- Helm chart (ghcr.io/weaveworks/charts)" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "- NPM package (@weaveworks scope)" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "## Version Synchronization" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "All components have been released with synchronized versions:" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "- Application: ${{ needs.release-please.outputs.version }}" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "- Chart AppVersion: ${{ needs.release-please.outputs.version }}" >> $GITHUB_STEP_SUMMARY | ||||||||
echo "- Chart Version: $(echo '${{ needs.release-please.outputs.version }}' | sed 's/^v//')" >> $GITHUB_STEP_SUMMARY | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The version transformation logic (removing 'v' prefix) is duplicated here and in the validation step. Consider extracting this to a reusable variable or function. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same sed issue as in the validation step. This command assumes the version always has a 'v' prefix, which may not be consistent.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||
echo "- Image Tag: ${{ needs.release-please.outputs.version }}" >> $GITHUB_STEP_SUMMARY |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
{ | ||
".": "0.39.0-rc.2", | ||
"charts/gitops-server": "4.0.36" | ||
".": "0.39.0-rc.2" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sed command will fail if APP_VERSION doesn't have a 'v' prefix. Consider using a more robust approach that handles both 'v0.39.0-rc.2' and '0.39.0-rc.2' formats.
Copilot uses AI. Check for mistakes.