Last active
October 16, 2020 15:37
-
-
Save InsanusMokrassar/52fe87ab2fb218d886b8b1e6964bcdf2 to your computer and use it in GitHub Desktop.
Changelog parser and gradle github release script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function parse() { | |
version="$1" | |
while IFS= read -r line && [ -z "`echo "$line" | grep -e "^#\+ $version"`" ] | |
do | |
: # do nothing | |
done | |
while IFS= read -r line && [ -z "`echo "$line" | grep -e "^#\+"`" ] | |
do | |
echo "$line" | |
done | |
} | |
version="$1" | |
file="$2" | |
if [ -n "$file" ]; then | |
parse "$version" < "$file" | |
else | |
parse "$version" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private String getCurrentVersionChangelog() { | |
OutputStream changelogDataOS = new ByteArrayOutputStream() | |
exec { | |
commandLine 'chmod', "+x", './changelog_parser.sh' | |
} | |
exec { | |
standardOutput = changelogDataOS | |
commandLine './changelog_parser.sh', "${project.version}", 'CHANGELOG.md' | |
} | |
return changelogDataOS.toString().trim() | |
} | |
if (new File(projectDir, "secret.gradle").exists()) { | |
apply from: './secret.gradle' | |
apply plugin: "com.github.breadmoirai.github-release" | |
githubRelease { | |
token "${project.property('GITHUB_RELEASE_TOKEN')}" | |
owner "HERE MUST BE PROJECT OWNER NAME" | |
repo "${rootProject.name}" | |
tagName "${project.version}" | |
releaseName "${project.version}" | |
targetCommitish "${project.version}" | |
body getCurrentVersionChangelog() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please, remember that you must add following lines to your main build gradle: