Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
AndroidUtils
VPNTunnelProxy
Commits
f5685b43
Commit
f5685b43
authored
Aug 18, 2021
by
Daniel Wolf
Browse files
Add task to bump versions, only build tags
parent
1852dfbd
Changes
2
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
f5685b43
...
...
@@ -7,4 +7,6 @@ test-build-deploy:
stage
:
test
script
:
-
./gradlew clean assembleRelease sourcesJar test --stacktrace
-
./gradlew publish --stacktrace
\ No newline at end of file
-
./gradlew publish --stacktrace
only
:
-
/^v[0-9]+$
\ No newline at end of file
library/build.gradle
View file @
f5685b43
...
...
@@ -3,10 +3,21 @@ apply plugin: 'kotlin-android'
apply
plugin:
'kotlin-android-extensions'
group
=
'com.frostnerd.utils'
version
=
'1.0.5'
ext
{
libraryGroupId
=
group
libraryArtifactId
=
rootProject
.
name
libraryVersion
=
'1.0.0'
}
task
bumpPatch
(
type:
Exec
)
{
dependsOn
(
"bumpPatchVersion"
)
}
task
bumpMinor
(
type:
Exec
)
{
dependsOn
(
"bumpMinorVersion"
)
}
task
bumpMajor
(
type:
Exec
)
{
dependsOn
(
"bumpMajorVersion"
)
}
android
{
...
...
@@ -43,7 +54,7 @@ android {
exclude
'META-INF/ASL2.0'
}
compileOptions
{
kotlinOptions
.
freeCompilerArgs
+=
[
'-module-name'
,
"$
libraryG
roup
Id
.$libraryArtifactId"
]
kotlinOptions
.
freeCompilerArgs
+=
[
'-module-name'
,
"$
g
roup.$libraryArtifactId"
]
}
}
...
...
@@ -72,12 +83,13 @@ task sourcesJar(type: Jar) {
classifier
=
'sources'
}
afterEvaluate
{
publishing
{
publications
{
aar
(
MavenPublication
)
{
groupId
libraryG
roup
Id
version
libraryV
ersion
groupId
g
roup
version
v
ersion
artifactId
libraryArtifactId
artifact
(
"$buildDir/outputs/aar/library-release.aar"
)
...
...
@@ -110,4 +122,67 @@ afterEvaluate {
}
}
}
publish
.
dependsOn
(
"assembleRelease"
,
"sourcesJar"
)
\ No newline at end of file
publish
.
dependsOn
(
"assembleRelease"
,
"sourcesJar"
)
class
Version
{
private
int
major
private
int
minor
private
int
patch
Version
(
String
version
)
{
def
(
major
,
minor
,
patch
)
=
version
.
tokenize
(
'.'
)
this
.
major
=
major
.
toInteger
()
this
.
minor
=
minor
.
toInteger
()
this
.
patch
=
patch
.
toInteger
()
}
void
bumpMajor
()
{
major
+=
1
minor
=
0
patch
=
0
}
void
bumpMinor
()
{
minor
+=
1
patch
=
0
}
void
bumpPatch
()
{
patch
+=
1
}
String
getName
()
{
"$major.$minor.$patch"
}
}
tasks
.
addRule
(
"Pattern: bump<TYPE>Version"
)
{
String
taskName
->
if
(
taskName
.
matches
(
"bump(Major|Minor|Patch)Version"
))
{
task
(
taskName
)
{
doLast
{
String
type
=
(
taskName
-
'bump'
-
'Version'
)
println
"Bumping ${type.toLowerCase()} version"
def
parsedVersion
=
new
Version
(
version
)
parsedVersion
.
"bump$type"
()
println
"${version} => ${parsedVersion.name}"
def
updated
=
buildFile
.
getText
()
updated
=
updated
.
replaceFirst
(
"version\\s*=\\s*'$version'"
,
"version = '${parsedVersion.name}'"
)
buildFile
.
setText
(
updated
)
exec
{
commandLine
(
"git"
,
"add"
,
"build.gradle"
)
}
exec
{
commandLine
(
"git"
,
"commit"
,
"-m"
,
"\"Bump version to ${parsedVersion.name}\""
)
}
exec
{
commandLine
(
"git"
,
"tag"
,
"v${parsedVersion.name}"
)
}
exec
{
commandLine
(
"git"
,
"push"
,
"origin"
,
"v${parsedVersion.name}"
)
}
}
}
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment