Skip to content

Commit

Permalink
feat: first implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Yehonal authored Feb 19, 2022
1 parent bb0d917 commit 8f54a2a
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
extends: 'eslint:recommended',
parserOptions: {
project: 'jsconfig.json',
ecmaVersion: 2018,
},
root: true,
env: {
commonjs: true,
node: true,
},
};
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Version bump (test)
on:
pull_request:
types:
- labeled
env:
NODE_VERSION: 16
RC_VERSION: 1
jobs:
version-bump:
runs-on: [ubuntu-latest]
steps:
- name: Test bump action
with:
repository: https://github.dev/Drassil/action-package-version-bump
user_name: 'drassil-git-bot'
user_email: '[email protected]'
ref_branch: 'main'
use_rebase: true
version_args: 'prerelease --preid=rc${{ env.RC_VERSION }}'
node_version: ${{ env.NODE_VERSION }}
uses: ../../
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# action-package-version-bump

Github action to upgrade the package.json version and create a changelog based on PR description that can be triggered in your workflows
58 changes: 58 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: 'action-package-version-bump'
description: 'Github action to upgrade the package.json version and create a changelog based on PR description that can be triggered in your workflows'
inputs:
repository:
description: 'The repository where to pull the changes'
required: true
user_name:
description: 'Name of the git user to push the changes'
required: true
user_email:
description: 'Email of the git user to push the changes'
required: true
ref_branch:
description: 'Branch to use as a base reference for the version bump'
required: false
default: 'master'
use_rebase:
description: 'Use rebase strategy for pull'
required: false
default: false
version_args:
description: 'npm version command arguments. '
required: false
default: 'patch'
node_version:
description: 'node version used for the npm commands'
required: false
default: '16'
runs:
using: 'composite'
steps:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ inputs.node_version }}
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Pull and bump version
run: |
git remote add main-repo ${{ inputs.repository }}
git config --global user.name ${{ inputs.user_name }}
git config --global user.email ${{ inputs.user_email }}
git config --global pull.rebase ${{ inputs.use_rebase }}
git pull main-repo
npm version ${{ inputs.version_arguments }}
PACKAGE_VERSION=`npm run --silent version`
PREV_CHANGELOG=`git show main-repo/dev:CHANGELOG.md || true`
echo -e "Rev: $PACKAGE_VERSION\n=============\n ${{ github.event.pull_request.body }}\n\n\n" > CHANGELOG.md
echo -e "$PREV_CHANGELOG" >> CHANGELOG.md
git add -u
git commit -m "chore: bump version and changelog"
git push --force
using: 'node12'
main: index.js


2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// nothing to do for now. It's a placeholder
console.log("Done")
18 changes: 18 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
},
"exclude": [
"**/node_modules"
],
"include": [
"index.js",
"src/**/*.js"
]
}
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "action-package-version-bump",
"version": "1.0.0-rc1.0",
"description": "Github action to upgrade the package.json version and create a changelog based on PR description that can be triggered in your workflows",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.4.0",
"@actions/exec": "^1.1.0",
"@actions/github": "^5.0.0"
}
}

0 comments on commit 8f54a2a

Please sign in to comment.