Version Kubernetes Agent Chart (#359) #275
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Version Kubernetes Agent chart | |
on: | |
push: | |
branches: | |
- main | |
- release/kubernetes-agent/v* | |
paths: | |
- charts/kubernetes-agent/** | |
- .github/workflows/create-versioning-pr.yaml | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
# When a changesets generated Versioning PR is merged, we want to publish the version as a tag | |
if: ${{ startsWith(github.event.commits[0].message, 'Version Kubernetes Agent Chart') }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.CHANGESETS_GITHUB_TOKEN }} | |
- name: setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 8.15.2 | |
run_install: true | |
- name: 'Tag version' | |
run: | | |
version=$(jq -r .version charts/kubernetes-agent/package.json) | |
tag="kubernetes-agent/$version" | |
git tag $tag | |
git push origin refs/tags/$tag | |
version: | |
runs-on: ubuntu-latest | |
# For all pushes that aren't creating a versioning commit | |
if: ${{ !startsWith(github.event.commits[0].message, 'Version Kubernetes Agent Chart') }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.CHANGESETS_GITHUB_TOKEN }} | |
- name: setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: setup-helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.13.2 | |
- name: Cache .pnpm-store | |
uses: actions/[email protected] | |
with: | |
path: ~/.pnpm-store | |
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 8.15.2 | |
run_install: true | |
- name: Install YQ | |
uses: dcarbone/[email protected] | |
- name: Create Release Pull Request | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
commit: 'Version Kubernetes Agent Chart' | |
title: 'Version Kubernetes Agent Chart' | |
createGitHubReleases: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.CHANGESETS_GITHUB_TOKEN }} | |
- name: 'Update version in Chart.yaml and pnpm-lock.yaml' | |
run: | | |
version=$(jq -r .version charts/kubernetes-agent/package.json) | |
version="$version" yq -i '.version = strenv(version)' charts/kubernetes-agent/Chart.yaml | |
pnpm i --lockfile-only | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
git add charts/kubernetes-agent/Chart.yaml | |
git add pnpm-lock.yaml | |
git commit -m "Update chart version in charts/kubernetes-agent/Chart.yaml and pnpm-lock.yaml" | |
if: steps.changesets.outputs.hasChangesets == 'true' | |
- name: 'Update version in test snapshots' | |
run: | | |
helm plugin install https://github.com/helm-unittest/helm-unittest.git | |
helm unittest -u charts/kubernetes-agent | |
git add charts/kubernetes-agent/tests/__snapshot__/* | |
git commit -m "Update chart version in Kubernetes agent test snapshots" | |
if: steps.changesets.outputs.hasChangesets == 'true' | |
- name: 'Update version in Readme' | |
working-directory: charts/kubernetes-agent | |
run: | | |
npm run generate-agent-docs | |
git add README.md | |
git commit -m "Update chart version in Kubernetes agent readme" | |
if: steps.changesets.outputs.hasChangesets == 'true' | |
- name: 'Push changes' | |
run: | | |
git push --set-upstream origin changeset-release/release/kubernetes-agent/v1 | |
if: steps.changesets.outputs.hasChangesets == 'true' | |