Skip to content

Bump App Version

Bump App Version #155

name: Bump App Version
on:
workflow_dispatch:
push:
# trigger on new minor release tags only
tags:
- valora-v[0-9]+.[0-9]+.0
permissions:
contents: write
pull-requests: write
concurrency:
group: bump-app-version
cancel-in-progress: false
jobs:
bump-app-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
- uses: ./.github/actions/yarn-install
- name: Generate Valora Actions Token
id: valora-actions-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.VALORA_ACTIONS_APP_ID }}
private-key: ${{ secrets.VALORA_ACTIONS_PRIVATE_KEY }}
- name: Bump App Version
env:
GH_TOKEN: ${{ steps.valora-actions-token.outputs.token }}
GITHUB_ACTIONS_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
git config user.name "valora-actions[bot]"
git config user.email "${{ vars.VALORA_ACTIONS_APP_ID }}+valora-actions[bot]@users.noreply.github.com"
BRANCH="valora-actions/bump-app-version-${GITHUB_RUN_ID}"
git checkout -b "$BRANCH"
yarn version --no-git-tag-version --minor
VERSION="$(node -p "require('./package.json').version")"
# Verify only package.json was modified
CHANGED_FILES=$(git diff --name-only)
if [[ "$CHANGED_FILES" != "package.json" ]]; then
echo "Unexpected files modified: $CHANGED_FILES"
exit 1
fi
git add package.json
if git diff --cached --quiet; then
echo "No changes to commit."
exit 0
fi
git commit -m "chore: bump app version to ${VERSION}"
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push --set-upstream origin "$BRANCH"
PR_URL="$(gh pr create \
--repo "$GITHUB_REPOSITORY" \
--base main \
--head "$BRANCH" \
--title "chore: bump app version to ${VERSION}" \
--body "Bump app version to ${VERSION}")"
# Approve using github-actions (different identity than valora-actions)
GH_TOKEN="$GITHUB_ACTIONS_TOKEN" gh pr review --approve "$PR_URL" --repo "$GITHUB_REPOSITORY"
gh pr merge --auto --squash "$PR_URL" --repo "$GITHUB_REPOSITORY"