Skip to content

Commit

Permalink
use version commit to update plugin version
Browse files Browse the repository at this point in the history
test

use Github token

missed one

now test with changeset

hardcode changeset remote branch for testing

revert testing
  • Loading branch information
kevjt committed Sep 24, 2024
1 parent 9559140 commit 9a05734
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 8 deletions.
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

0 comments on commit 9a05734

Please sign in to comment.