Skip to content
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

Update the plugin's version as part of the release creation process #18

Merged
merged 4 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
72 changes: 72 additions & 0 deletions .github/workflows/create-versioning-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Version Plugin

on:
push:
branches:
- 'main'

jobs:
version:
runs-on: ubuntu-latest

# For all pushes that aren't creating a versioning commit
if: ${{ !startsWith(github.event.commits[0].message, 'Version Helm Plugin') }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: setup-node
uses: actions/setup-node@v4
with:
node-version: 20

- 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: 9.11.0
run_install: true

- name: Install YQ
uses: dcarbone/[email protected]

- name: Create Release Pull Request
id: changesets
uses: changesets/action@v1
with:
commit: 'Version Helm Plugin'
title: 'Version Helm Plugin'
createGitHubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Determine whether version has changed
id: changed_packages
run: |
packageVersion=$(yq -r .version package.json)
pluginVersion=$(yq -r .version plugin.yaml)

if [[ "packageVersion" != "pluginVersion" ]]; then
echo "pluginChanged=true" >> $GITHUB_OUTPUT
fi
if: steps.changesets.outputs.hasChangesets == 'true'

- name: 'Update version in plugin.yaml'
run: |
version=$(yq -r .version package.json)
version="$version" yq -i '.version = strenv(version)' plugin.yaml
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add plugin.yaml
git commit -m "Update plugin version in plugin.yaml"
if: steps.changesets.outputs.hasChangesets == 'true' && steps.changed_packages.outputs.pluginChanged == 'true'

- name: 'Push changes'
run: |
git push --set-upstream origin changeset-release/main
if: steps.changesets.outputs.hasChangesets == 'true'
15 changes: 7 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,27 @@ name: Release

on:
push:
tags:
- '*'
branches:
- 'main'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest

if: ${{ startsWith(github.event.commits[0].message, 'Version Helm Plugin') }}
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
-
name: Run GoReleaser
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ go.work.sum
# Jetbrains IDE
.idea
dist/

# Nodejs
node_modules
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "helm-migrate-values",
"version": "0.2.2",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've set this to be the same as the version on the latest tag that we have

"description": "Helm plugin for migrating user-provided release values between chart schema versions",
"scripts": {
"changeset": "changeset"
},
"devDependencies": {
"@changesets/cli": "^2.27.8"
},
"author": "Octopus Deploy",
"license": "Apache-2.0"
}
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "migrate-values"
version: "0.0.1"
version: "0.2.2"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also updated the version directly here because there won't be a changeset associated with this PR (no changes to the actual migrator functionality itself).

usage: "schema migration for Helm values"
description: "Tool for ensuring user-supplied chart values are kept up to date with the chart's values schema."
command: "$HELM_PLUGIN_DIR/bin/migrate-values"
Expand Down
Loading
Loading