Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
91f9b96
extended bumping for more branches.
Jul 5, 2021
8b475bf
ci: version bumped to v 1.0.2
Jul 5, 2021
dece81c
extended bumping for more branches.
Jul 5, 2021
7a904fb
Merge remote-tracking branch 'origin/master'
Jul 5, 2021
46a7c50
ci: version bumped to v 1.0.3
Jul 5, 2021
f205fd8
extended bumping for more branches.
Jul 5, 2021
26e27da
Merge remote-tracking branch 'origin/master'
Jul 5, 2021
8b18249
ci: version bumped to v 1.0.4
Jul 5, 2021
c5f0ad9
extended bumping for more branches.
Jul 5, 2021
f59d9a1
Merge remote-tracking branch 'origin/master'
Jul 5, 2021
09ebc1d
extended bumping for more branches.
Jul 5, 2021
3fff985
ci: version bumped to v 1.0.5
Jul 5, 2021
35708e4
extended bumping for more branches.
Jul 5, 2021
98281a6
Merge remote-tracking branch 'origin/master'
Jul 5, 2021
3c00b97
ci: version bumped to v 1.0.6
Jul 5, 2021
f4841b4
extended bumping for more branches.
Jul 5, 2021
b3eb720
Merge remote-tracking branch 'origin/master'
Jul 5, 2021
0e0bb50
ci: version bumped to v 1.0.7
Jul 5, 2021
cd982d2
extended bumping for more branches.
Jul 5, 2021
8855e8c
Merge remote-tracking branch 'origin/master'
Jul 5, 2021
7f29457
ci: version bumped to v 1.0.8
Jul 5, 2021
a6a24e5
extended bumping for more branches.
Jul 13, 2021
33d61b6
Merge remote-tracking branch 'origin/master'
Jul 13, 2021
9d0f70b
ci: version bumped to v 1.0.9
Jul 13, 2021
6bc7435
extended bumping for more branches.
Jul 13, 2021
e6a406b
ci: version bumped to v 1.0.10
Jul 13, 2021
8cade9f
extended bumping for more branches.
Jul 13, 2021
52ff364
Merge remote-tracking branch 'origin/master'
Jul 13, 2021
85025af
ci: version bumped to v 1.0.11
Jul 13, 2021
2b6bfcf
extended bumping for more branches.
Jul 13, 2021
8fc054c
Merge remote-tracking branch 'origin/master'
Jul 13, 2021
71f0923
ci: version bumped to v 1.0.12
Jul 13, 2021
db10ead
extended bumping for more branches.
Jul 13, 2021
e6fed2a
Merge remote-tracking branch 'origin/master'
Jul 13, 2021
8f2d64e
ci: version bumped to v 1.0.13
Jul 13, 2021
ecaf818
extended bumping for more branches.
Jul 13, 2021
f6ac913
Merge remote-tracking branch 'origin/master'
Jul 13, 2021
e08175c
ci: version bumped to v 1.0.14
Jul 13, 2021
4a59fa3
extended bumping for more branches.
Jul 13, 2021
ea89277
ci: version bumped to v 1.0.15
Jul 13, 2021
336c97d
extended bumping for more branches.
Jul 13, 2021
26a6dc9
ci: version bumped to v 1.0.16
Jul 13, 2021
5a26476
extended bumping for more branches.
Jul 13, 2021
e3f0f4c
Merge remote-tracking branch 'origin/master'
Jul 13, 2021
9ed8362
ci: version bumped to v 1.0.17
Jul 13, 2021
ce5b4af
extended bumping for more branches.
Jul 13, 2021
7a32744
Merge remote-tracking branch 'origin/master'
Jul 13, 2021
cf1a41c
ci: version bumped to v 1.0.18
Jul 13, 2021
d871f09
extended bumping for more branches.
Jul 13, 2021
02bb618
Merge remote-tracking branch 'origin/master'
Jul 13, 2021
446945e
ci: version bumped to v 1.0.19
Jul 13, 2021
e1d5353
extended bumping for more branches.
Jul 14, 2021
0a1b3d3
extended bumping for more branches.
Jul 20, 2021
81f3ef2
ci: version bumped to v 1.0.20
Jul 20, 2021
9b09a7a
extended bumping for more branches.
Jul 20, 2021
ff76706
Merge remote-tracking branch 'origin/master'
Jul 20, 2021
577d6c0
ci: version bumped to v 1.0.21
Jul 20, 2021
2ded855
extended bumping for more branches.
Jul 20, 2021
beb497f
Merge remote-tracking branch 'origin/master'
Jul 20, 2021
a75b376
ci: version bumped to v 1.0.22
Jul 20, 2021
b8f63ff
extended bumping for more branches.
Jul 20, 2021
f9e8433
Merge remote-tracking branch 'origin/master'
Jul 20, 2021
03f5913
ci: version bumped to v 1.0.23
Jul 20, 2021
f0bf79c
extended bumping for more branches.
Jul 20, 2021
5559608
Merge remote-tracking branch 'origin/master'
Jul 20, 2021
7d2ec7d
ci: version bumped to v 1.0.24
Jul 20, 2021
d89857b
extended bumping for more branches.
Jul 20, 2021
c76f8a3
Merge remote-tracking branch 'origin/master'
Jul 20, 2021
8bcb878
ci: version bumped to v 1.0.25
Jul 20, 2021
6fb2caa
extended bumping for more branches.
Jul 20, 2021
7187212
Merge remote-tracking branch 'origin/master'
Jul 20, 2021
d99ed7c
extended bumping for more branches.
Jul 20, 2021
ab598cc
ci: version bumped to v 1.0.26
Jul 20, 2021
e06458f
extended bumping for more branches.
Jul 20, 2021
b33d33d
Merge remote-tracking branch 'origin/master'
Jul 20, 2021
1cddd1b
ci: version bumped to v 1.0.27
Jul 20, 2021
17439ce
extended bumping for more branches.
Jul 20, 2021
9f237e3
Merge remote-tracking branch 'origin/master'
Jul 20, 2021
a7058bf
ci: version bumped to v 1.0.28
Jul 20, 2021
b01408d
expand bumping feature set
Jul 20, 2021
edb2797
Merge remote-tracking branch 'origin/master' into expand-feature-set-…
Jul 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "github-version-bumper",
"version": "1.0.1",
"version": "1.0.28",
"repository": {
"type": "git",
"url": "git+https://github.com/kaangokdemir/github-version-bumper.git"
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/bumper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const bump = require('json-bumper')

export const bumpVersion = async (fileName: string, options?: object) => {
await bump(fileName, options)
return await bump(fileName, options)
if (fileName === 'package.json') {
try {
await bump('package-lock.json', options)
return await bump('package-lock.json', options)
} catch (error) {
console.log(error)
}
Expand Down
103 changes: 68 additions & 35 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { Toolkit } from 'actions-toolkit'
import { bumpVersion } from './helpers/bumper'
const { version } = require('../version.json')

const bump = require('json-bumper')
console.log(`Version ${version}`)

Toolkit.run(async (tools) => {
const fileName = process.env.VERSION_FILE_NAME || 'package.json'
const entry = process.env.VERSION_ENTRY || 'version'
let fileName = process.env.VERSION_FILE_NAME || 'package.json'
let entry = process.env.VERSION_ENTRY || 'version'
const githubUser = process.env.GITHUB_USER || 'GitHub Version Bumper'
const githubEmail =
process.env.GITHUB_EMAIL || 'github-version-bumper@users.noreply.github.com'
process.env.GITHUB_EMAIL || 'github-version-bumper@users.noreply.github.com'

const commitMessage = 'version bumped to v'

console.log('fileName', fileName)
try {
// SET USER
console.log('process-started---')
await tools.runInWorkspace('git', [
'config',
'user.name',
Expand All @@ -28,56 +29,88 @@ Toolkit.run(async (tools) => {
let ignoreBump = false

const currentBranch = /refs\/[a-zA-Z]+\/(.*)/.exec(
process.env.GITHUB_REF as string,
process.env.GITHUB_REF as string,
)?.[1] as string

await tools.runInWorkspace('git', ['checkout', currentBranch])

// Getting last commit information
const lastCommit =
JSON.stringify(await tools.runInWorkspace('git', ['log', '-1'])).toLowerCase() || ''

console.log('lastcommitmessage', lastCommit)
JSON.stringify(await tools.runInWorkspace('git', ['log', '-1'])).toLowerCase() || ''

console.log('lastcommitmessage', lastCommit)
console.log('current branch', currentBranch)
// Bumping Starts

if (lastCommit.toLowerCase().includes('ci-ignore')) {
console.log('ci-ignore')
ignoreBump = true
} else if (lastCommit.toLowerCase().includes('ci-version=')) {
const splitted = lastCommit.toLowerCase().split('ci-version=\\"')
const replace = splitted[1].split('\\"')[0]
console.log('replace:', replace)
await bumpVersion(fileName, { replace, entry })
} else if (lastCommit.toLowerCase().includes('ci-pre=')) {
console.log('pre')
const splitted = lastCommit.toLowerCase().split('ci-pre=\\"')
const pre = splitted[1].split('\\"')[0]
console.log('pre:', pre)
await bumpVersion(fileName, { pre, entry })
} else if (lastCommit.toLowerCase().includes('ci-major')) {
console.log('major')
await bumpVersion(fileName, { major: true, entry })
} else if (lastCommit.toLowerCase().includes('ci-minor')) {
console.log('minor')
await bumpVersion(fileName, { minor: true, entry })
} else {
console.log('patch')
await bumpVersion(fileName)
if(currentBranch === 'master'){
if (lastCommit.toLowerCase().includes('ci-ignore')) {
console.log('ci-ignore')
ignoreBump = true
} else if (lastCommit.toLowerCase().includes('ci-version=')) {
const splitted = lastCommit.toLowerCase().split('ci-version=\\"')
const replace = splitted[1].split('\\"')[0]
console.log('replace:', replace)
await bumpVersion(fileName, { replace, entry })
} else if (lastCommit.toLowerCase().includes('ci-pre=')) {
console.log('pre')
const splitted = lastCommit.toLowerCase().split('ci-pre=\\"')
const pre = splitted[1].split('\\"')[0]
console.log('pre:', pre)
await bumpVersion(fileName, { pre, entry })
} else if (lastCommit.toLowerCase().includes('ci-major')) {
console.log('major')
await bumpVersion(fileName, { major: true, entry })
} else if (lastCommit.toLowerCase().includes('ci-minor')) {
console.log('minor')
await bumpVersion(fileName, { minor: true, entry })
} else {
console.log('patch')
await bumpVersion(fileName)
}
}
else if(currentBranch === 'staging' || currentBranch === 'qc' || currentBranch === 'production' ){
const bumpedBranch = await bumpVersion(fileName)
;
if(bumpedBranch.original.includes("rc")){
let branchVersion = bumpedBranch.original.split('-rc.')[1]
branchVersion++;
const str2 = bumpedBranch.original.slice(0, -1) + branchVersion
await bumpVersion(fileName, { replace : str2 })
}else{
const vO = bumpedBranch.original
const pre = `-rc.0`
const replace = vO.concat(pre)
await bumpVersion(fileName, { replace })
}
}
else if(currentBranch === 'alpha'){
const bumpedBranch = await bumpVersion(fileName)
;
if(bumpedBranch.original.includes("pr")){
let branchVersion = bumpedBranch.original.split('-pr.')[1]
branchVersion++;
const str2 = bumpedBranch.original.slice(0, -1) + branchVersion
await bumpVersion(fileName, { replace : str2 })
}else{
const vO = bumpedBranch.original
const pre = `-pr.0`
const replace = vO.concat(pre)
await bumpVersion(fileName, { replace })
}
}

if (!ignoreBump) {
const newVersion = JSON.parse(tools.getFile(fileName)).version

console.log('-newVersion', newVersion)
await tools.runInWorkspace('git', [
'commit',
'-a',
'-m',
`ci: ${commitMessage} ${newVersion}`,
`ci: ${commitMessage} ${newVersion}`,
])

// PUSH THE CHANGES
const remoteRepo = `https://${process.env.GITHUB_ACTOR}:${process.env.GITHUB_TOKEN}@github.com/${process.env.GITHUB_REPOSITORY}.git`
await tools.runInWorkspace('git', ['pull', '--tags'])
await tools.runInWorkspace('git', ['tag', newVersion])
await tools.runInWorkspace('git', ['push', remoteRepo, '--follow-tags'])
await tools.runInWorkspace('git', ['push', remoteRepo, '--tags'])
Expand Down