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

Add bump-version workflow #259

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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 }}`.

Loading