diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..4040fb1 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,12 @@ +module.exports = { + extends: 'eslint:recommended', + parserOptions: { + project: 'jsconfig.json', + ecmaVersion: 2018, + }, + root: true, + env: { + commonjs: true, + node: true, + }, +}; diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1c71ea3 --- /dev/null +++ b/.github/workflows/test.yml @@ -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: 'drassil-git-bot@drassil.org' + ref_branch: 'main' + use_rebase: true + version_args: 'prerelease --preid=rc${{ env.RC_VERSION }}' + node_version: ${{ env.NODE_VERSION }} + uses: ../../ \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..08b2553 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/README.md b/README.md index ecc3359..82f383a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..edd1453 --- /dev/null +++ b/action.yml @@ -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 + + diff --git a/index.js b/index.js new file mode 100644 index 0000000..13179f6 --- /dev/null +++ b/index.js @@ -0,0 +1,2 @@ +// nothing to do for now. It's a placeholder +console.log("Done") \ No newline at end of file diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..f3bf26e --- /dev/null +++ b/jsconfig.json @@ -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" + ] +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..f6629c8 --- /dev/null +++ b/package.json @@ -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" + } +} \ No newline at end of file