Skip to content

Commit 18ac6e3

Browse files
committed
Update build and release workflows
- Remove the gradle-git and github-pages plugins, whose dependencies no longer resolve, so the project builds again - Publish through gradle-nexus/publish-plugin and remove the staging repository script - Run CI on ubuntu-latest with current action versions and JDK 8, 11, 17 - Publish before creating the GitHub release so a failed publish does not leave a tag behind
1 parent d7ef941 commit 18ac6e3

5 files changed

Lines changed: 43 additions & 125 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,24 @@ on:
77

88
jobs:
99
build:
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-latest
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
java-version: [ 8, 9, 10, 11, 17, 18 ]
14+
java-version: [ 8, 11, 17 ]
1515

1616
steps:
17-
- uses: actions/checkout@v2.3.1
17+
- uses: actions/checkout@v4
1818
- name: Set up JDK ${{ matrix.java-version }}
19-
uses: actions/setup-java@v2.3.1
19+
uses: actions/setup-java@v4
2020
with:
2121
java-version: "${{ matrix.java-version }}"
22-
distribution: "adopt-openj9"
22+
distribution: "temurin"
2323
- name: Build & Test
2424
run: ./gradlew jacocoTestReport test
2525
- name: Code coverage
26-
run: bash <(curl -s https://codecov.io/bash)
26+
if: ${{ matrix.java-version == 17 }}
27+
uses: codecov/codecov-action@v5
28+
with:
29+
token: ${{ secrets.CODECOV_TOKEN }}
30+
fail_ci_if_error: false

‎.github/workflows/release.yml‎

Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout code
10-
uses: actions/checkout@v2
10+
uses: actions/checkout@v4
1111
with:
1212
fetch-depth: 0
1313
- name: Prepare tag
@@ -26,78 +26,49 @@ jobs:
2626
id: release_output
2727
if: ${{ steps.prepare_tag.outcome == 'success' }}
2828
run: |
29-
echo "::set-output name=tag::${{ env.TAG }}"
29+
echo "tag=${{ env.TAG }}" >> $GITHUB_OUTPUT
3030
outputs:
3131
tag: ${{ steps.release_output.outputs.tag }}
3232

33-
create-github-release:
33+
publish:
3434
runs-on: ubuntu-latest
3535
needs: check-release-tag
3636
if: ${{ needs.check-release-tag.outputs.tag }}
3737
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 }}
38+
- uses: actions/checkout@v4
39+
- uses: actions/setup-java@v4
5540
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
41+
java-version: "17"
42+
distribution: "temurin"
6743
- name: Create gradle.properties
6844
shell: bash
6945
run: |
7046
mkdir -p _gradle_user_home
7147
echo "GRADLE_USER_HOME=_gradle_user_home" >> $GITHUB_ENV
7248
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 }}
49+
sonatypeUsername=${{ secrets.MAVEN_USERNAME }}
50+
sonatypePassword=${{ secrets.MAVEN_PASSWORD }}
7751
signing.keyId=${{ secrets.SIGNING_KEY_ID }}
7852
signing.password=${{ secrets.SIGNING_PASSWORD }}
7953
signing.secretKeyRingFile=_gradle_user_home/pusher-maven-gpg-signing-key.gpg
8054
FILE
8155
echo "${{ secrets.PUSHER_MAVEN_GPG_SIGNING_KEY }}" | base64 --decode > _gradle_user_home/pusher-maven-gpg-signing-key.gpg
8256
- name: Publish
8357
run: |
84-
./gradlew publish
58+
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
8559
86-
finish-release:
60+
create-github-release:
8761
runs-on: ubuntu-latest
88-
needs: publish
89-
env:
90-
NEXUS_USERNAME: ${{ secrets.MAVEN_USERNAME }}
91-
NEXUS_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
62+
needs: [ check-release-tag, publish ]
9263
steps:
93-
- uses: actions/checkout@v2
94-
- id: get_staging_repository_id
95-
name: Get staging repository id
64+
- uses: actions/checkout@v4
65+
- name: Prepare description
9666
run: |
97-
echo "staging_repository_id=$(python3 scripts/get_staging_repository_id.py)" >> $GITHUB_OUTPUT
98-
- name: Release
99-
uses: nexus-actions/release-nexus-staging-repo@main
100-
with:
101-
username: ${{ secrets.MAVEN_USERNAME }}
102-
password: ${{ secrets.MAVEN_PASSWORD }}
103-
staging_repository_id: ${{ steps.get_staging_repository_id.outputs.staging_repository_id }}
67+
csplit -s CHANGELOG.md "/##/" {1}
68+
cat xx01 > CHANGELOG.tmp
69+
- name: Create Release
70+
env:
71+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
TAG: ${{ needs.check-release-tag.outputs.tag }}
73+
run: |
74+
gh release create "$TAG" --title "$TAG" --notes-file CHANGELOG.tmp --target "$GITHUB_SHA"

‎.github/workflows/release_pr.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ jobs:
1111
name: Prepare release
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515
- name: Get current version
1616
shell: bash
1717
run: |
1818
CURRENT_VERSION=$(awk '/^version = / { gsub("\"", ""); print $3 }' build.gradle)
1919
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
2121
with:
2222
repository: pusher/public_actions
2323
path: .github/actions

‎build.gradle‎

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
11
import org.apache.tools.ant.filters.ReplaceTokens
22

3-
buildscript {
4-
repositories {
5-
mavenCentral()
6-
}
7-
dependencies {
8-
classpath 'org.ajoberstar:gradle-git:1.1.0'
9-
}
10-
}
11-
123
plugins {
134
id "eclipse"
145
id "jacoco"
156
id "java-library"
167
id "maven-publish"
17-
id "org.ajoberstar.github-pages" version "1.7.2"
188
id "signing"
19-
}
20-
21-
def getProperty = { property ->
22-
if (!project.hasProperty(property)) {
23-
throw new GradleException("${property} property must be set")
24-
}
25-
return project.property(property)
9+
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
2610
}
2711

2812
group = "com.pusher"
@@ -111,18 +95,6 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
11195
}
11296
assemble.dependsOn javadocJar
11397

114-
githubPages {
115-
repoUri = 'https://github.com/pusher/pusher-websocket-java.git'
116-
pages {
117-
from javadoc.outputs.files
118-
}
119-
commitMessage = "JavaDoc gh-pages for ${version}"
120-
credentials {
121-
username = { getProperty("github.username") }
122-
password = { getProperty("github.password") }
123-
}
124-
}
125-
12698
artifacts {
12799
archives jar, fatJar, sourcesJar, javadocJar
128100
}
@@ -174,15 +146,15 @@ publishing {
174146
}
175147
}
176148
}
149+
}
150+
151+
nexusPublishing {
177152
repositories {
178-
maven {
179-
def releaseRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
180-
def snapshotRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
181-
url = version.endsWith("SNAPSHOT") ? snapshotRepositoryUrl : releaseRepositoryUrl
182-
credentials {
183-
username = findProperty("maven.username") ?: ""
184-
password = findProperty("maven.password") ?: ""
185-
}
153+
sonatype {
154+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
155+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
156+
username = findProperty("sonatypeUsername") ?: ""
157+
password = findProperty("sonatypePassword") ?: ""
186158
}
187159
}
188160
}

‎scripts/get_staging_repository_id.py‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)