Skip to content

Commit a3d2098

Browse files
committed
Merge branch 'master' into rename-release-task
2 parents 4e76b53 + 16c5f25 commit a3d2098

File tree

6 files changed

+86
-8
lines changed

6 files changed

+86
-8
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Gradle Build
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request:
8+
types: [opened, reopened, synchronize]
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'temurin'
23+
java-version: '17'
24+
25+
- name: Run Gradle Build
26+
run: ./gradlew build --no-daemon

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
on:
2+
workflow_dispatch:
3+
4+
push:
5+
branches: [ master ]
6+
paths: [ VERSION ]
7+
8+
jobs:
9+
release:
10+
if: "contains(github.event.head_commit.message, '[release]')"
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '17'
20+
distribution: 'temurin'
21+
22+
- name: Publish Plugin
23+
env:
24+
GRADLE_PUBLISH_KEY: ${{ vars.GRADLE_PUBLISH_KEY }}
25+
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
26+
run: ./gradlew publishPlugins --no-daemon --stacktrace
27+
28+
- name: Create Git Tag
29+
run: |
30+
git config user.name "${GITHUB_ACTOR}"
31+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
32+
VERSION=$(cat VERSION)
33+
git tag -a v$VERSION -m "Release v$VERSION"
34+
git push origin v$VERSION

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1-alpha8

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group = 'io.nextflow'
9-
version = '0.0.1-alpha6'
9+
version = file('VERSION').text.trim()
1010

1111
repositories {
1212
mavenCentral()

src/main/groovy/io/nextflow/gradle/registry/RegistryClient.groovy

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ package io.nextflow.gradle.registry
22

33
import com.google.gson.Gson
44
import groovy.transform.CompileStatic
5+
import groovy.util.logging.Slf4j
6+
import org.apache.http.client.methods.CloseableHttpResponse
57
import org.apache.http.client.methods.HttpPost
68
import org.apache.http.entity.mime.MultipartEntityBuilder
79
import org.apache.http.impl.client.HttpClients
10+
import org.apache.http.util.EntityUtils
811

12+
@Slf4j
913
@CompileStatic
1014
class RegistryClient {
1115
private final Gson gson = new Gson()
@@ -33,18 +37,21 @@ class RegistryClient {
3337
def rep = http.execute(req)) {
3438

3539
if (rep.statusLine.statusCode != 200) {
36-
def err = gson.fromJson(new InputStreamReader(rep.entity.content), ErrorResponse)
37-
throw new RuntimeException("Failed to publish plugin: ${err.type} - ${err.message}")
40+
throw new RegistryPublishException(getErrorMessage(rep))
3841
}
3942
} catch (ConnectException e) {
4043
throw new RuntimeException("Unable to connect to plugin repository: (${e.message})")
4144
}
4245
}
4346

44-
// ----------------------------------------------------------------------------
45-
46-
private static class ErrorResponse {
47-
String type
48-
String message
47+
private String getErrorMessage(CloseableHttpResponse rep) {
48+
def message = "Failed to publish plugin to registry $url: HTTP Response:${rep.statusLine}"
49+
if( rep.entity ) {
50+
final String entityStr = EntityUtils.toString(rep.entity)
51+
if (entityStr) {
52+
return "$message - $entityStr".toString()
53+
}
54+
}
55+
return message.toString()
4956
}
5057
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package io.nextflow.gradle.registry
2+
3+
/**
4+
* Custom exception class for registry publish task
5+
*/
6+
class RegistryPublishException extends Exception{
7+
RegistryPublishException(String s) {
8+
super(s)
9+
}
10+
}

0 commit comments

Comments
 (0)