bump_version #51
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
# Workflow which bumps the version of all packages in the repo | |
name: bump_version | |
on: | |
# run manually | |
workflow_dispatch: | |
inputs: | |
version: | |
type: string | |
description: Version number (e.g. 1.2.3) | |
required: true | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
bump_version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print contexts | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
ENV_CONTEXT: ${{ toJson(env) }} | |
VARS_CONTEXT: ${{ toJson(vars) }} | |
JOB_CONTEXT: ${{ toJson(job) }} | |
STEPS_CONTEXT: ${{ toJson(steps) }} | |
RUNNER_CONTEXT: ${{ toJson(runner) }} | |
SECRETS_CONTEXT: ${{ toJson(secrets) }} | |
STRATEGY_CONTEXT: ${{ toJson(strategy) }} | |
MATRIX_CONTEXT: ${{ toJson(matrix) }} | |
NEEDS_CONTEXT: ${{ toJson(needs) }} | |
INPUTS_CONTEXT: ${{ toJson(inputs) }} | |
run: | | |
echo "******************************" | |
echo "github:" "$GITHUB_CONTEXT" | |
echo "******************************" | |
echo "env:" "$ENV_CONTEXT" | |
echo "******************************" | |
echo "vars:" "$VARS_CONTEXT" | |
echo "******************************" | |
echo "job:" "$JOB_CONTEXT" | |
echo "******************************" | |
echo "steps:" "$STEPS_CONTEXT" | |
echo "******************************" | |
echo "runner:" "$RUNNER_CONTEXT" | |
echo "******************************" | |
echo "secrets:" "$SECRETS_CONTEXT" | |
echo "******************************" | |
echo "strategy:" "$STRATEGY_CONTEXT" | |
echo "******************************" | |
echo "matrix:" "$MATRIX_CONTEXT" | |
echo "******************************" | |
echo "needs:" "$NEEDS_CONTEXT" | |
echo "******************************" | |
echo "inputs:" "$INPUTS_CONTEXT" | |
echo "******************************" | |
- uses: actions/checkout@v3 | |
- name: Bump version | |
env: | |
GITHUB_TOKEN: ${{ secrets.PROSOPONATOR_PAT }} | |
run: | | |
set -euxo pipefail # stop on errors, print commands, fail on pipe fails | |
# make a new branch for the version changes | |
git switch -c release/${{ github.event.inputs.version }} | |
# find all package.json files, recursively | |
pkgJsons=$(find . -name package.json -prune -not -path '*/node_modules/*' -not -path '*/.next/*') | |
# replace the version in all package.json files | |
xargs -I % sh -c "cat % | jq '.version = \"${{ github.event.inputs.version }}\"' > %.new && mv %.new %" <<< "$pkgJsons" | |
# set the author in git | |
git config user.name "prosoponator[bot]" | |
git config user.email "[email protected]" | |
# commit the version changes | |
git add . | |
git commit -m "Bump version to ${{ github.event.inputs.version }}" | |
# push version changes | |
git push --set-upstream origin bump-version-${{ github.event.inputs.version }} | |
# create a PR for the release | |
gh pr create --base main --title "Release ${{ github.event.inputs.version }}" --fill |