Skip to content

Commit 81b306c

Browse files
authored
Migrate to gradle and automate release (#66)
1 parent c4c25c9 commit 81b306c

14 files changed

Lines changed: 697 additions & 270 deletions

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## What does this PR do?
2+
3+
[Description here]
4+
5+
## CHANGELOG
6+
7+
- [CHANGED] Describe your change here. Look at CHANGELOG.md to see the format.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
java-version: [8, 9, 10, 11, 17]
14+
java-version: [8, 11, 17]
1515

1616
steps:
1717
- uses: actions/checkout@v2
@@ -21,4 +21,4 @@ jobs:
2121
java-version: "${{ matrix.java-version }}"
2222
distribution: "adopt"
2323
- name: Build & Test
24-
run: mvn --batch-mode --update-snapshots verify
24+
run: ./gradlew build

.github/workflows/release.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
on:
2+
push:
3+
branches: [ master ]
4+
5+
jobs:
6+
check-release-tag:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v2
11+
with:
12+
fetch-depth: 0
13+
- name: Prepare tag
14+
id: prepare_tag
15+
continue-on-error: true
16+
run: |
17+
export TAG=v$(awk '/^version = / { gsub("\"", ""); print $3 }' build.gradle)
18+
echo "TAG=$TAG" >> $GITHUB_ENV
19+
20+
export CHECK_TAG=$(git tag | grep $TAG)
21+
if [[ $CHECK_TAG ]]; then
22+
echo "Skipping because release tag already exists"
23+
exit 1
24+
fi
25+
- name: Output
26+
id: release_output
27+
if: ${{ steps.prepare_tag.outcome == 'success' }}
28+
run: |
29+
echo "::set-output name=tag::${{ env.TAG }}"
30+
outputs:
31+
tag: ${{ steps.release_output.outputs.tag }}
32+
33+
create-github-release:
34+
runs-on: ubuntu-latest
35+
needs: check-release-tag
36+
if: ${{ needs.check-release-tag.outputs.tag }}
37+
steps:
38+
- uses: actions/checkout@v2
39+
- name: Prepare tag
40+
run: |
41+
export TAG=v$(awk '/^version = / { gsub("\"", ""); print $3 }' build.gradle)
42+
echo "TAG=$TAG" >> $GITHUB_ENV
43+
- name: Setup git
44+
run: |
45+
git config user.email "pusher-ci@pusher.com"
46+
git config user.name "Pusher CI"
47+
- name: Prepare description
48+
run: |
49+
csplit -s CHANGELOG.md "/##/" {1}
50+
cat xx01 > CHANGELOG.tmp
51+
- name: Create Release
52+
uses: actions/create-release@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
with:
56+
tag_name: ${{ env.TAG }}
57+
release_name: ${{ env.TAG }}
58+
body_path: CHANGELOG.tmp
59+
draft: false
60+
prerelease: false
61+
62+
publish:
63+
runs-on: ubuntu-latest
64+
needs: create-github-release
65+
steps:
66+
- uses: actions/checkout@v2
67+
- name: Create gradle.properties
68+
shell: bash
69+
run: |
70+
mkdir -p _gradle_user_home
71+
echo "GRADLE_USER_HOME=_gradle_user_home" >> $GITHUB_ENV
72+
cat <<FILE > _gradle_user_home/gradle.properties
73+
github.username=${{ secrets.PUSHER_CI_GITHUB_PRIVATE_TOKEN }}
74+
github.password=""
75+
maven.username=${{ secrets.MAVEN_USERNAME }}
76+
maven.password=${{ secrets.MAVEN_PASSWORD }}
77+
signing.keyId=${{ secrets.SIGNING_KEY_ID }}
78+
signing.password=${{ secrets.SIGNING_PASSWORD }}
79+
signing.secretKeyRingFile=_gradle_user_home/pusher-maven-gpg-signing-key.gpg
80+
FILE
81+
echo "${{ secrets.PUSHER_MAVEN_GPG_SIGNING_KEY }}" | base64 --decode > _gradle_user_home/pusher-maven-gpg-signing-key.gpg
82+
- name: Publish
83+
run: |
84+
./gradlew publish
85+
86+
finish-release:
87+
runs-on: ubuntu-latest
88+
needs: publish
89+
env:
90+
NEXUS_USERNAME: ${{ secrets.MAVEN_USERNAME }}
91+
NEXUS_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
92+
steps:
93+
- id: get_staging_repository_id
94+
name: Get staging repository id
95+
run: |
96+
echo "staging_repository_id=$(python3 scripts/get_staging_repository_id.py)" >> $GITHUB_OUTPUT
97+
- name: Release
98+
uses: nexus-actions/release-nexus-staging-repo@main
99+
with:
100+
username: ${{ secrets.MAVEN_USERNAME }}
101+
password: ${{ secrets.MAVEN_PASSWORD }}
102+
staging_repository_id: ${{ steps.get_staging_repository_id.outputs.staging_repository_id }}

.github/workflows/release_pr.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: release
2+
3+
on:
4+
pull_request:
5+
types: [ labeled ]
6+
branches:
7+
- master
8+
9+
jobs:
10+
prepare-release:
11+
name: Prepare release
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Get current version
16+
shell: bash
17+
run: |
18+
CURRENT_VERSION=$(awk '/^version = / { gsub("\"", ""); print $3 }' build.gradle)
19+
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
20+
- uses: actions/checkout@v2
21+
with:
22+
repository: pusher/public_actions
23+
path: .github/actions
24+
- uses: ./.github/actions/prepare-version-bump
25+
id: bump
26+
with:
27+
current_version: ${{ env.CURRENT_VERSION }}
28+
- name: Push
29+
shell: bash
30+
run: |
31+
perl -pi -e 's/version = "${{env.CURRENT_VERSION}}"/version = "${{steps.bump.outputs.new_version}}"/' build.gradle
32+
perl -pi -e 's/${{env.CURRENT_VERSION}}/${{steps.bump.outputs.new_version}}/' README.md
33+
34+
git add README.md CHANGELOG.md
35+
git commit -m "Bump to version ${{ steps.bump.outputs.new_version }}"
36+
git push

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22
.project
33
target
44

5+
# Output directory
6+
target
7+
8+
build
9+
.gradle
10+
.idea

CHANGELOG.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
# 1.3.1 2022-05-16
1+
# Changelog
22

3-
[CHANGED] Use SecureRandom.nextBytes instead of SecureRandom.generateSeed
3+
## 1.3.1 2022-05-16
44

5-
# 1.3.0 2021-09-02
5+
- [CHANGED] Use SecureRandom.nextBytes instead of SecureRandom.generateSeed
66

7-
[ADDED] Add end-to-end encryption support
7+
## 1.3.0 2021-09-02
88

9-
# 1.2.1 2021-04-19
9+
- [ADDED] Add end-to-end encryption support
1010

11-
[CHANGED] Upgraded asynchttpclient to v2.12.13 (https://nvd.nist.gov/vuln/detail/CVE-2019-20444)
11+
## 1.2.1 2021-04-19
1212

13-
# 1.2.0 2020-04-20
13+
- [CHANGED] Upgraded asynchttpclient to v2.12.13 (https://nvd.nist.gov/vuln/detail/CVE-2019-20444)
1414

15-
[ADDED] Support for asynchronous http calls
15+
## 1.2.0 2020-04-20
16+
17+
- [ADDED] Support for asynchronous http calls

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ In order to use this library, you need to have an account on <http://pusher.com/
88

99
## Supported platforms
1010

11-
* Java SE - supports versions 8, 9, 10, 11 and 17.
11+
* Java SE - supports versions 8, 11 and 17.
1212
* Oracle JDK
1313
* OpenJDK
1414

@@ -20,7 +20,7 @@ The pusher-http-java library is available in Maven Central:
2020
<dependency>
2121
<groupId>com.pusher</groupId>
2222
<artifactId>pusher-http-java</artifactId>
23-
<version>1.3.1</version>
23+
<version>1.3.3</version>
2424
</dependency>
2525
```
2626

@@ -276,7 +276,7 @@ pusher.configureHttpClient(
276276

277277
### End-to-end encryption
278278

279-
This library supports end-to-end encryption of your private channels. This means that only you and your connected clients will be able to read your messages. Pusher cannot decrypt them.
279+
This library supports end-to-end encryption of your private channels. This means that only you and your connected clients will be able to read your messages. Pusher cannot decrypt them.
280280

281281
You can enable this feature by following these steps:
282282

build.gradle

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
import org.apache.tools.ant.filters.ReplaceTokens
2+
3+
buildscript {
4+
repositories {
5+
mavenCentral()
6+
}
7+
dependencies {
8+
classpath 'org.ajoberstar:gradle-git:1.1.0'
9+
}
10+
}
11+
12+
plugins {
13+
id 'java-library'
14+
id 'maven-publish'
15+
id "signing"
16+
id "org.ajoberstar.github-pages" version "1.7.2"
17+
}
18+
19+
def getProperty = { property ->
20+
if (!project.hasProperty(property)) {
21+
throw new GradleException("${property} property must be set")
22+
}
23+
return project.property(property)
24+
}
25+
26+
repositories {
27+
mavenCentral()
28+
}
29+
30+
group = "com.pusher"
31+
version = "1.3.3"
32+
description = "Pusher HTTP Client"
33+
sourceCompatibility = "1.8"
34+
targetCompatibility = "1.8"
35+
36+
ext.sharedManifest = manifest {
37+
attributes(
38+
'Created-By': 'Pusher',
39+
'Implementation-Vendor': 'Pusher',
40+
'Implementation-Title': 'Pusher HTTP Java',
41+
'Implementation-Version': version
42+
)
43+
}
44+
45+
dependencies {
46+
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
47+
implementation 'org.asynchttpclient:async-http-client:2.12.3'
48+
implementation 'com.google.code.gson:gson:2.8.9'
49+
testImplementation 'org.apache.httpcomponents:httpclient:4.5.13'
50+
testImplementation 'org.hamcrest:hamcrest-all:1.3'
51+
testImplementation 'org.jmock:jmock-junit5:2.12.0'
52+
testImplementation 'org.jmock:jmock-imposters:2.12.0'
53+
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
54+
}
55+
56+
processResources {
57+
filter(ReplaceTokens, tokens: [
58+
version: project.version
59+
])
60+
}
61+
62+
javadoc {
63+
title "Pusher HTTP Java"
64+
options.linkSource = true
65+
}
66+
67+
jar {
68+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
69+
manifest = project.manifest {
70+
from sharedManifest
71+
}
72+
}
73+
74+
task sourcesJar(type: Jar, dependsOn: classes) {
75+
archiveClassifier.set('sources')
76+
from sourceSets.main.allSource
77+
}
78+
assemble.dependsOn sourcesJar
79+
80+
81+
task javadocJar(type: Jar, dependsOn: javadoc) {
82+
archiveClassifier.set('javadoc')
83+
from javadoc.destinationDir
84+
}
85+
assemble.dependsOn javadocJar
86+
87+
artifacts {
88+
archives jar, sourcesJar, javadocJar
89+
}
90+
91+
java {
92+
withSourcesJar()
93+
withJavadocJar()
94+
}
95+
96+
githubPages {
97+
repoUri = 'https://github.com/pusher/pusher-http-java.git'
98+
pages {
99+
from javadoc.outputs.files
100+
}
101+
commitMessage = "JavaDoc gh-pages for ${version}"
102+
credentials {
103+
username = { getProperty("github.username") }
104+
password = { getProperty("github.password") }
105+
}
106+
}
107+
108+
publishing {
109+
publications {
110+
mavenJava(MavenPublication) {
111+
artifactId = 'pusher-http-java'
112+
113+
from components.java
114+
pom {
115+
name = 'Pusher HTTP Client'
116+
packaging = 'jar'
117+
artifactId = 'pusher-java-client'
118+
description = "This is a Java library for interacting with Pusher.com's HTTP API."
119+
url = 'http://github.com/pusher/pusher-http-java'
120+
scm {
121+
connection = 'scm:git:git@github.com:pusher/pusher-http-java'
122+
developerConnection = 'scm:git:git@github.com:pusher/pusher-http-java'
123+
url = 'http://github.com/pusher/pusher-http-java'
124+
}
125+
licenses {
126+
license {
127+
name = 'MIT'
128+
url = 'https://raw.github.com/pusher/pusher-http-java/master/LICENCE.txt'
129+
distribution = 'https://raw.github.com/pusher/pusher-http-java/mvn-repo/'
130+
}
131+
}
132+
organization {
133+
name = 'Pusher'
134+
url = 'http://pusher.com'
135+
}
136+
issueManagement {
137+
system = 'GitHub'
138+
url = 'https://github.com/pusher/pusher-http-java/issues'
139+
}
140+
}
141+
}
142+
}
143+
repositories {
144+
maven {
145+
def releaseRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
146+
def snapshotRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
147+
url = version.endsWith("SNAPSHOT") ? snapshotRepositoryUrl : releaseRepositoryUrl
148+
credentials {
149+
username = findProperty("maven.username") ?: ""
150+
password = findProperty("maven.password") ?: ""
151+
}
152+
}
153+
}
154+
}
155+
156+
signing {
157+
sign publishing.publications.mavenJava
158+
}
159+
160+
test {
161+
useJUnitPlatform()
162+
163+
testLogging {
164+
showStandardStreams = true
165+
}
166+
}

gradle/wrapper/gradle-wrapper.jar

59.3 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)