Bump version #8
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
# from https://dev.to/puku0x/github-actions-1mi5 | |
name: Bump version | |
on: | |
workflow_dispatch: | |
inputs: | |
bumpTarget: | |
description: 'bump target major/minor/patch' | |
required: true | |
default: 'patch' | |
jobs: | |
bump: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Switch branch | |
run: git switch -c tmp | |
- name: Git config | |
run: | | |
git config --local user.email "machineuser+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
- name: Get branch | |
id: get_branch | |
run: echo "BRANCH=${GITHUB_REF/refs\/heads\//}" >> "$GITHUB_ENV" | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Bump version | |
id: bump_version | |
run: | | |
pushd serverless-s3-local | |
yarn version --${{ github.event.inputs.bumpTarget }} | |
jq -r '"VERSION=v\(.version)"' package.json >> "$GITHUB_ENV" | |
popd | |
- name: Commit pyproject.toml | |
id: commit_pyproject_toml | |
run: | | |
git add serverless-s3-local/package.json | |
git commit -m "chore(*): bump version to ${VERSION}" | |
- name: Push branch | |
run: | | |
git branch -m bump-${VERSION} | |
git push -u origin bump-${VERSION} | |
- name: Create pull request | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const result = await github.rest.pulls.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: 'chore(*): bump ' + process.env.VERSION, | |
head: context.repo.owner + ':' + 'bump-' + process.env.VERSION, | |
base: process.env.BRANCH, | |
body: 'Prepare release ' + process.env.VERSION | |
}); | |
github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: result.data.number, | |
labels: ['Ready For Review'] | |
}); |