Skip to content

Commit

Permalink
Add bump-version workflow (#259) (#260)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
(cherry picked from commit f17bde4)

Co-authored-by: Thomas Farr <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and Xtansia authored Jul 6, 2023
1 parent 87afb27 commit 97f3a48
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -ex

IFS='.' read -r -a VERSION_COMPONENTS <<< "$1"
MAJOR="${VERSION_COMPONENTS[0]}"
MINOR="${VERSION_COMPONENTS[1]}"
PATCH="${VERSION_COMPONENTS[2]}"

if [[ -z "$MAJOR" || -z "$MINOR" || -z "$PATCH" ]]; then
echo "Usage: $0 <major>.<minor>.<patch>"
exit 1
fi

VERSION="$MAJOR.$MINOR.$PATCH"

AUTO_LABEL_JSON=$(jq \
--arg v "$VERSION" \
'.rules |= with_entries(if .key | test("^v\\d+\\.\\d+\\.\\d+$") then .key |= "v\($v)" else . end)' \
.github/auto-label.json)
echo "$AUTO_LABEL_JSON" > .github/auto-label.json

GLOBAL_JSON=$(jq \
--arg v "$VERSION" \
--arg maj "$MAJOR" \
--arg min "$MINOR" \
'.version = "\($v)" | .doc_current = "\($maj).\($min)" | .doc_branch = "\($maj).x"' \
global.json)
echo "$GLOBAL_JSON" > global.json

sed -i '' -E "s/^([[:space:]]+VERSION: )([0-9]+\.){2}[0-9]+$/\1$VERSION/" .github/workflows/release.yml
sed -i '' -E "s/(<Current(Assembly(File)?)?Version>)([0-9]+\.){2}[0-9]+<\//\1$VERSION<\//" Directory.Build.props
44 changes: 44 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to bump version on'
required: true
version:
description: 'Version to bump to'
required: true

jobs:
bump-version:
name: Bump Version
runs-on: ubuntu-latest
steps:
- name: GitHub App Token
id: github_app_token
uses: tibdex/[email protected]
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
installation_id: 22958780

- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch }}
token: ${{ steps.github_app_token.outputs.token }}

- name: Bump Version
run: bash .github/bump-version.sh "${{ github.event.inputs.version }}"

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ steps.github_app_token.outputs.token }}
base: ${{ github.event.inputs.branch }}
branch: "feat/${{ github.event.inputs.branch }}/bump-version"
commit-message: Bump version to ${{ github.event.inputs.version }}
signoff: true
delete-branch: true
title: 'Bump version on ${{ github.event.inputs.branch }} to ${{ github.event.inputs.version }}.'
body: |
Bumping version on `${{ github.event.inputs.branch }}` to `${{ github.event.inputs.version }}`.

0 comments on commit 97f3a48

Please sign in to comment.