Skip to content

Bump version

Bump version #4

Workflow file for this run

# 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_OUTPUT
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Bump version
id: bump_version
run: |
pushd serverless-s3-local
version=$(npm version ${{ github.event.inputs.bumpTarget }})
echo "{VERSION}={version}" >> $GITHUB_OUTPUT
echo $GITHUB_OUTPUT
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}"
env:
VERSION: ${{ steps.bump_version.outputs.VERSION }}
- name: Push branch
run: |
git branch -m bump-${VERSION}
git push -u origin bump-${VERSION}
env:
VERSION: ${{ steps.bump_version.outputs.VERSION }}
- name: Create pull request
uses: actions/github-script@v6
env:
BRANCH: ${{ steps.get_branch.outputs.BRANCH }}
VERSION: ${{ steps.bump_version.outputs.VERSION }}
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']
});