Skip to content

Commit

Permalink
Stop reinventing the wheel - announce plugin already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher committed Jun 1, 2018
1 parent bffa498 commit f664e52
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
paths:
- ~/.gradle
key: v1-dependencies-{{ checksum "build.gradle" }}
- run: ./gradlew -Prelease.useLastTag=true final createTweet
- run: ./gradlew -Prelease.useLastTag=true final

workflows:
version: 2
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ buildscript {
classpath "com.netflix.nebula:nebula-release-plugin:6.3.3"
classpath "com.netflix.nebula:nebula-publishing-plugin:7.1.0"
classpath "com.netflix.nebula:nebula-bintray-plugin:3.5.2"
classpath "com.ferranpons:twitter-gradle-plugin:1.0.2"
}
}

Expand Down
25 changes: 11 additions & 14 deletions gradle/announce.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
apply plugin: "twitter-gradle-plugin"
apply plugin: "announce"

def tag = System.getenv("CIRCLE_TAG")
def releaseName = new groovy.json.JsonSlurper()
.parseText("https://api.github.com/repos/robfletcher/strikt/releases/tags/v0.7.1?access_token=${System.getenv("GITHUB_OAUTH_TOKEN")}".toURL().text)
.name

twitterPlugin {
consumerKey = System.getenv("TWITTER_CONSUMER_KEY")
consumerSecret = System.getenv("TWITTER_CONSUMER_SECRET")
accessToken = System.getenv("TWITTER_ACCESS_TOKEN")
accessTokenSecret = System.getenv("TWITTER_ACCESS_TOKEN_SECRET")
message = "Strikt ${tag} ${releaseName} is available. https://strikt.io"
announce {
username = "stri_kt"
password = System.getenv("TWITTER_PASSWORD")
}

createTweet.doFirst {
if (!tag) throw new IllegalStateException("Should not be tweeting without a tag!")
task("final").doLast {
def tag = System.getenv("CIRCLE_TAG")
if (!tag) throw new IllegalStateException("Should not be tweeting without a release tag!")
def releaseName = new groovy.json.JsonSlurper()
.parseText("https://api.github.com/repos/robfletcher/strikt/releases/tags/v0.7.1?access_token=${System.getenv("GITHUB_OAUTH_TOKEN")}".toURL().text)
.name
announce.announce("Strikt ${tag} ${releaseName} is available. https://strikt.io", "twitter")
}

0 comments on commit f664e52

Please sign in to comment.