Create PR to bump version #16
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: "Create PR to bump version" | |
on: | |
workflow_dispatch: | |
inputs: | |
targetBranch: | |
description: 'Target Branch' | |
required: true | |
type: choice | |
options: | |
- bugfix | |
- master | |
versionType: | |
description: 'What Version to Bump' | |
required: true | |
type: choice | |
options: | |
- build | |
- minor | |
- major | |
jobs: | |
build: | |
if: ${{ github.event.inputs.versionType == 'build' }} | |
runs-on: ubuntu-latest | |
steps: | |
# Setup | |
- name: Checkout code | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Install required packages | |
uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
packages: jq | |
- name: Save targetBranch to env | |
if: github.event.inputs.targetBranch != 'bugfix' | |
run: echo "targetBranch=${{ github.event.inputs.targetBranch }}" >> $GITHUB_ENV | |
# Save old version | |
- name: Find and save old major_version from manifest | |
run: awk 'BEGIN { FS="=" } /^major_version/ { print "oldMajor="$2; }' manifest >> $GITHUB_ENV | |
- name: Find and save old minor_version from manifest | |
run: awk 'BEGIN { FS="=" } /^minor_version/ { print "oldMinor="$2; }' manifest >> $GITHUB_ENV | |
- name: Find and save old build_version from manifest | |
run: awk 'BEGIN { FS="=" } /^build_version/ { print "oldBuild="$2; }' manifest >> $GITHUB_ENV | |
# Bugfix branch | |
- name: Save bugfix branch name | |
if: github.event.inputs.targetBranch == 'bugfix' | |
run: echo "bugfixBranch=${{ env.oldMajor }}.${{ env.oldMinor }}.z" >> $GITHUB_ENV | |
- name: Update targetBranch with actual bugfix branch name | |
if: github.event.inputs.targetBranch == 'bugfix' | |
run: echo "targetBranch=${{ env.bugfixBranch }}" >> $GITHUB_ENV | |
- name: Checkout bugfix branch | |
if: github.event.inputs.targetBranch == 'bugfix' | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
with: | |
ref: ${{ env.targetBranch }} | |
# Save old version again if needed | |
- name: Find and save old major_version from manifest | |
if: github.event.inputs.targetBranch == 'bugfix' | |
run: awk 'BEGIN { FS="=" } /^major_version/ { print "oldMajor="$2; }' manifest >> $GITHUB_ENV | |
- name: Find and save old minor_version from manifest | |
if: github.event.inputs.targetBranch == 'bugfix' | |
run: awk 'BEGIN { FS="=" } /^minor_version/ { print "oldMinor="$2; }' manifest >> $GITHUB_ENV | |
- name: Find and save old build_version from manifest | |
if: github.event.inputs.targetBranch == 'bugfix' | |
run: awk 'BEGIN { FS="=" } /^build_version/ { print "oldBuild="$2; }' manifest >> $GITHUB_ENV | |
# Calculate new version | |
- name: Calculate new build_version | |
run: echo "newBuild=$((${{ env.oldBuild }} + 1))" >> $GITHUB_ENV | |
- name: Save new version to env var | |
run: echo "newVersion=${{ env.oldMajor }}.${{ env.oldMinor }}.${{ env.newBuild }}" >> $GITHUB_ENV | |
- name: Save a copy of newVersion without periods to env var | |
run: echo "newVersionSlug=${{ env.newVersion }}" | sed -e 's/\.//g' >> $GITHUB_ENV | |
# Update files with new versions | |
- name: Update manifest build_version | |
run: sed -i "s/build_version=.*/build_version=${{ env.newBuild }}/g" manifest | |
- name: Update package-lock.json version | |
run: echo "$( jq '.version = "'"${{ env.newVersion }}"'"' package-lock.json )" > package-lock.json | |
- name: Update package-lock.json version 2 | |
run: echo "$( jq '.packages."".version = "'"${{ env.newVersion }}"'"' package-lock.json )" > package-lock.json | |
- name: Update package.json version | |
run: echo "$( jq '.version = "'"${{ env.newVersion }}"'"' package.json )" > package.json | |
- name: Update Makefile version | |
run: sed -i "s/VERSION := .*/VERSION := ${{ env.newVersion }}/g" Makefile | |
# Create PR | |
- name: Save new branch name to env | |
run: echo "newBranch=bump-${{ github.event.inputs.targetBranch }}-to-${{ env.newVersionSlug }}" >> $GITHUB_ENV | |
- name: Create PR with new version | |
env: | |
GH_TOKEN: ${{ secrets.JF_BOT_TOKEN }} | |
run: |- | |
git config user.name "jellyfin-bot" | |
git config user.email "[email protected]" | |
git checkout -b "${{ env.newBranch }}" | |
git add . | |
git commit -m "Bump ${{ github.event.inputs.versionType }} version" | |
git push --set-upstream origin "${{ env.newBranch }}" | |
gh pr create --title "Bump ${{ github.event.inputs.targetBranch }} branch to ${{ env.newVersion }}" --body "Bump version to prep for next release. Generated by `.github/workflows/bump-version.yml`" --label ignore-changelog --base ${{ env.targetBranch }} | |
minor: | |
if: ${{ github.event.inputs.versionType == 'minor' }} | |
runs-on: ubuntu-latest | |
steps: | |
# Setup | |
- name: Checkout code | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Install jq to update json | |
uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
packages: jq | |
- name: Save targetBranch to env | |
if: github.event.inputs.targetBranch != 'bugfix' | |
run: echo "targetBranch=${{ github.event.inputs.targetBranch }}" >> $GITHUB_ENV | |
# Save old version | |
- name: Find and save old major_version from manifest | |
run: awk 'BEGIN { FS="=" } /^major_version/ { print "oldMajor="$2; }' manifest >> $GITHUB_ENV | |
- name: Find and save old minor_version from manifest | |
run: awk 'BEGIN { FS="=" } /^minor_version/ { print "oldMinor="$2; }' manifest >> $GITHUB_ENV | |
- name: Find and save old build_version from manifest | |
run: awk 'BEGIN { FS="=" } /^build_version/ { print "oldBuild="$2; }' manifest >> $GITHUB_ENV | |
# Bugfix branch | |
- name: Save bugfix branch name | |
if: github.event.inputs.targetBranch == 'bugfix' | |
run: echo "bugfixBranch=${{ env.oldMajor }}.${{ env.oldMinor }}.z" >> $GITHUB_ENV | |
- name: Update targetBranch with actual bugfix branch name | |
if: github.event.inputs.targetBranch == 'bugfix' | |
run: echo "targetBranch=${{ env.bugfixBranch }}" >> $GITHUB_ENV | |
- name: Checkout bugfix branch | |
if: github.event.inputs.targetBranch == 'bugfix' | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
with: | |
ref: ${{ env.targetBranch }} | |
# Calculate new version | |
- name: Calculate new build_version | |
run: echo "newMinor=$((${{ env.oldMinor }} + 1))" >> $GITHUB_ENV | |
- name: Save new version to env var | |
run: echo "newVersion=${{ env.oldMajor }}.${{ env.newMinor }}.0" >> $GITHUB_ENV | |
- name: Save a copy of newVersion without periods to env var | |
run: echo "newVersionSlug=${{ env.newVersion }}" | sed -e 's/\.//g' >> $GITHUB_ENV | |
# Update files with new versions | |
- name: Update manifest minor_version | |
run: sed -i "s/minor_version=.*/minor_version=${{ env.newMinor }}/g" manifest | |
- name: Update manifest build_version | |
run: sed -i "s/build_version=.*/build_version=0/g" manifest | |
- name: Update package-lock.json version | |
run: echo "$( jq '.version = "'"${{ env.newVersion }}"'"' package-lock.json )" > package-lock.json | |
- name: Update package-lock.json version 2 | |
run: echo "$( jq '.packages."".version = "'"${{ env.newVersion }}"'"' package-lock.json )" > package-lock.json | |
- name: Update package.json version | |
run: echo "$( jq '.version = "'"${{ env.newVersion }}"'"' package.json )" > package.json | |
- name: Update Makefile version | |
run: sed -i "s/VERSION := .*/VERSION := ${{ env.newVersion }}/g" Makefile | |
# Create PR | |
- name: Save new branch name to env | |
run: echo "newBranch=bump-${{ github.event.inputs.targetBranch }}-to-${{ env.newVersionSlug }}" >> $GITHUB_ENV | |
- name: Create PR with new version | |
env: | |
GH_TOKEN: ${{ secrets.JF_BOT_TOKEN }} | |
run: |- | |
git config user.name "jellyfin-bot" | |
git config user.email "[email protected]" | |
git checkout -b "${{ env.newBranch }}" | |
git add . | |
git commit -m "Bump ${{ github.event.inputs.versionType }} version" | |
git push --set-upstream origin "${{ env.newBranch }}" | |
gh pr create --title "Bump ${{ github.event.inputs.targetBranch }} branch to ${{ env.newVersion }}" --body "Bump version to prep for next release. Generated by `.github/workflows/bump-version.yml`" --label ignore-changelog --base ${{ env.targetBranch }} | |
major: | |
if: ${{ github.event.inputs.versionType == 'major' }} | |
runs-on: ubuntu-latest | |
steps: | |
# Setup | |
- name: Checkout code | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Install jq to update json | |
uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
packages: jq | |
- name: Save targetBranch to env | |
if: github.event.inputs.targetBranch != 'bugfix' | |
run: echo "targetBranch=${{ github.event.inputs.targetBranch }}" >> $GITHUB_ENV | |
# Save old version | |
- name: Find and save old major_version from manifest | |
run: awk 'BEGIN { FS="=" } /^major_version/ { print "oldMajor="$2; }' manifest >> $GITHUB_ENV | |
- name: Find and save old minor_version from manifest | |
run: awk 'BEGIN { FS="=" } /^minor_version/ { print "oldMinor="$2; }' manifest >> $GITHUB_ENV | |
- name: Find and save old build_version from manifest | |
run: awk 'BEGIN { FS="=" } /^build_version/ { print "oldBuild="$2; }' manifest >> $GITHUB_ENV | |
# Bugfix branch | |
- name: Save bugfix branch name | |
if: github.event.inputs.targetBranch == 'bugfix' | |
run: echo "bugfixBranch=${{ env.oldMajor }}.${{ env.oldMinor }}.z" >> $GITHUB_ENV | |
- name: Update targetBranch with actual bugfix branch name | |
if: github.event.inputs.targetBranch == 'bugfix' | |
run: echo "targetBranch=${{ env.bugfixBranch }}" >> $GITHUB_ENV | |
- name: Checkout bugfix branch | |
if: github.event.inputs.targetBranch == 'bugfix' | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
with: | |
ref: ${{ env.targetBranch }} | |
# Calculate new version | |
- name: Calculate new build_version | |
run: echo "newMajor=$((${{ env.oldMajor }} + 1))" >> $GITHUB_ENV | |
- name: Save new version to env var | |
run: echo "newVersion=${{ env.newMajor }}.0.0" >> $GITHUB_ENV | |
- name: Save a copy of newVersion without periods to env var | |
run: echo "newVersionSlug=${{ env.newVersion }}" | sed -e 's/\.//g' >> $GITHUB_ENV | |
# Update files with new versions | |
- name: Update manifest major_version | |
run: sed -i "s/major_version=.*/major_version=${{ env.newMajor }}/g" manifest | |
- name: Update manifest minor_version | |
run: sed -i "s/minor_version=.*/minor_version=0/g" manifest | |
- name: Update manifest build_version | |
run: sed -i "s/build_version=.*/build_version=0/g" manifest | |
- name: Update package-lock.json version | |
run: echo "$( jq '.version = "'"${{ env.newVersion }}"'"' package-lock.json )" > package-lock.json | |
- name: Update package-lock.json version 2 | |
run: echo "$( jq '.packages."".version = "'"${{ env.newVersion }}"'"' package-lock.json )" > package-lock.json | |
- name: Update package.json version | |
run: echo "$( jq '.version = "'"${{ env.newVersion }}"'"' package.json )" > package.json | |
- name: Update Makefile version | |
run: sed -i "s/VERSION := .*/VERSION := ${{ env.newVersion }}/g" Makefile | |
# Create PR | |
- name: Save new branch name to env | |
run: echo "newBranch=bump-${{ github.event.inputs.targetBranch }}-to-${{ env.newVersionSlug }}" >> $GITHUB_ENV | |
- name: Create PR with new version | |
env: | |
GH_TOKEN: ${{ secrets.JF_BOT_TOKEN }} | |
run: |- | |
git config user.name "jellyfin-bot" | |
git config user.email "[email protected]" | |
git checkout -b "${{ env.newBranch }}" | |
git add . | |
git commit -m "Bump ${{ github.event.inputs.versionType }} version" | |
git push --set-upstream origin "${{ env.newBranch }}" | |
gh pr create --title "Bump ${{ github.event.inputs.targetBranch }} branch to ${{ env.newVersion }}" --body "Bump version to prep for next release. Generated by `.github/workflows/bump-version.yml`" --label ignore-changelog --base ${{ env.targetBranch }} | |