From 0e51ba3e89c051171889e2ece1335bbd44d93b7c Mon Sep 17 00:00:00 2001 From: grapebaba <281165273@qq.com> Date: Sat, 17 Jun 2023 11:54:08 +0800 Subject: [PATCH] release:release for 0.1.0 Signed-off-by: grapebaba <281165273@qq.com> --- .github/workflows/release.yml | 78 ++++++++++++++++++++++++++--------- hildr-node/build.gradle | 47 ++++++++++++++++++++- 2 files changed, 105 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 23629094..8a2baa06 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ env: jobs: native-build: - name: GraalVM CE latest ${{ matrix.java-version }} on ${{ matrix.os }} + name: GraalVM latest ${{ matrix.java-version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -32,11 +32,10 @@ jobs: matrix: version: [ '20.0.1' ] java-version: [ '20.0.1' ] - os: [ macos-latest, windows-latest, ubuntu-latest ] + os: [ macos-latest, windows-latest ] outputs: - version: ${{ steps.native-build.outputs.version }} - native_image_name: ${{ steps.native-build.outputs.native_image_name }} + version: ${{ github.ref_name }} steps: - name: 🛎️ Check out repository @@ -44,7 +43,7 @@ jobs: with: fetch-depth: 0 - - name: ☕ Setup GraalVM CE Dev Build + - name: ☕ Setup GraalVM Build uses: graalvm/setup-graalvm@v1 with: version: ${{ matrix.version }} @@ -53,37 +52,78 @@ jobs: distribution: 'graalvm' cache: 'gradle' set-java-home: 'true' - native-image-job-reports: 'false' + native-image-job-reports: 'true' - name: 🏗️ Native Image Build & Test id: native-build run: | ./gradlew nativeCompile - ls -ltrh hildr-node/build/${{ github.event.repository.name }}*.tar.gz + ls -ltrh hildr-node/build/native/nativeCompile/hildr-node - name: 📤 Upload ${{ matrix.os }} native image uses: actions/upload-artifact@v3 with: - name: ${{ steps.native-build.outputs.native_image_name }} + name: hildr-node-${{ matrix.os }} path: | - hildr-node/build/${{ steps.native-build.outputs.native_image_name }} + hildr-node/build/native/nativeCompile/hildr-node if-no-files-found: error + native-build-linux: + name: GraalVM latest ${{ matrix.java-version }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + max-parallel: 3 + matrix: + version: [ '20.0.1' ] + java-version: [ '20.0.1' ] + os: [ ubuntu-latest ] + + outputs: + version: ${{ github.ref_name }} + + steps: + - name: 🛎️ Check out repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: ☕ Setup GraalVM Build + uses: graalvm/setup-graalvm@v1 + with: + version: ${{ matrix.version }} + java-version: ${{ matrix.java-version }} + github-token: ${{ secrets.GITHUB_TOKEN }} + distribution: 'graalvm' + cache: 'gradle' + set-java-home: 'true' + native-image-job-reports: 'true' + + - name: 🏗️ Native Image Build & Test + id: native-build + run: | + ./gradlew buildBinary + ls -ltrh hildr-node/build/binary/hildr-node + + - name: 📤 Upload ${{ matrix.os }} native image + uses: actions/upload-artifact@v3 + with: + name: hildr-node-${{ matrix.os }} + path: | + hildr-node/build/binary/hildr-node + if-no-files-found: error native-build-musl: - name: GraalVM CE Dev + musl static image + name: GraalVM + musl static image runs-on: ubuntu-latest - outputs: - native_image_name: ${{ steps.native-build.outputs.native_image_name }} - steps: - name: 🛎️ Check out repository uses: actions/checkout@v3 with: fetch-depth: 0 - - name: ☕ Setup GraalVM CE Dev Build + - name: ☕ Setup GraalVM Build uses: graalvm/setup-graalvm@v1 with: version: '20.0.1' @@ -98,20 +138,20 @@ jobs: - name: 🏗️ Build static image with musl libc id: native-build run: | - ./gradlew nativeCompile -Pmusl - ls -ltrh hildr-node/build/native/nativeCompile/hildr-node + ./gradlew buildBinaryStatic + ls -ltrh hildr-node/build/binary/hildr-node - name: 📤 Upload static binary uses: actions/upload-artifact@v3 with: - name: ${{ steps.native-build.outputs.native_image_name }} + name: hildr-node path: | - hildr-node/build/native/nativeCompile/hildr-node + hildr-node/build/binary/hildr-node if-no-files-found: error release: name: 🚰 Release new version. - needs: [ native-build, native-build-musl ] + needs: [ native-build, native-build-musl, native-build-linux ] if: startsWith(github.ref, 'refs/tags/') && needs.native-build.result == 'success' runs-on: ubuntu-latest diff --git a/hildr-node/build.gradle b/hildr-node/build.gradle index 8d9a6f95..0568893c 100644 --- a/hildr-node/build.gradle +++ b/hildr-node/build.gradle @@ -284,8 +284,53 @@ jar { } } - task buildBinary { + dependsOn jar + def buildBinaryDir = "build/binary" + def out = new ByteArrayOutputStream() + doFirst { + new File(buildBinaryDir).mkdirs() + copy { + from "build/libs/${project.name}-${project.version}.jar" + into buildBinaryDir + rename "${project.name}-${project.version}.jar", "${project.name}.jar" + } + } + doLast { + exec { + workingDir buildBinaryDir + executable "sh" + args "-c", "native-image -jar ${project.name}.jar --no-fallback --enable-http --enable-https --enable-preview --add-modules jdk.incubator.concurrent -H:EnableURLProtocols=http,https --initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback.core.CoreConstants,ch.qos.logback.core.util.Loader,ch.qos.logback.core.util.StatusPrinter,ch.qos.logback.core.status.InfoStatus,ch.qos.logback.classic.Logger,ch.qos.logback.core.rolling.helper.FileNamePattern,ch.qos.logback.classic.Level,ch.qos.logback.core.status.StatusBase,io.opentelemetry.api.trace.ArrayBasedTraceStateBuilder,io.opentelemetry.context.LazyStorage,ch.qos.logback.core.util.FileSize,ch.qos.logback.core.rolling.helper.RollingCalendar,io.opentelemetry.api.internal.ImmutableSpanContext,io.opentelemetry.api.internal.OtelEncodingUtils,ch.qos.logback.classic.PatternLayout,io.opentelemetry.context.ThreadLocalContextStorage,io.opentelemetry.api.trace.PropagatedSpan,io.opentelemetry.context.ContextStorageWrappers,ch.qos.logback.core.rolling.helper.Compressor\$1,io.opentelemetry.api.trace.ImmutableTraceFlags,ch.qos.logback.core.rolling.helper.RollingCalendar\$1,ch.qos.logback.classic.model.ConfigurationModel,ch.qos.logback.core.model.processor.DefaultProcessor\$1,ch.qos.logback.core.model.processor.ImplicitModelHandler\$1,ch.qos.logback.core.subst.Token,ch.qos.logback.core.pattern.parser.Parser,ch.qos.logback.core.subst.Parser\$1,ch.qos.logback.core.util.Duration,ch.qos.logback.core.model.processor.ChainedModelFilter\$1,ch.qos.logback.classic.model.processor.ConfigurationModelHandler,ch.qos.logback.classic.model.processor.LogbackClassicDefaultNestedComponentRules,ch.qos.logback.core.subst.NodeToStringTransformer\$1,ch.qos.logback.core.pattern.parser.TokenStream\$1,ch.qos.logback.core.subst.Tokenizer\$1 --initialize-at-run-time=io.netty.channel.AbstractChannel,io.netty.channel.socket.nio.SelectorProviderUtil,io.netty.util.concurrent.DefaultPromise,io.netty,org.slf4j.MDC,org.github.gestalt.config ${project.name}" + standardOutput out + } + } + println(out.toString()) +} + +task buildBinaryStatic { + dependsOn jar + def buildBinaryDir = "build/binary" + def out = new ByteArrayOutputStream() + doFirst { + new File(buildBinaryDir).mkdirs() + copy { + from "build/libs/${project.name}-${project.version}.jar" + into buildBinaryDir + rename "${project.name}-${project.version}.jar", "${project.name}.jar" + } + } + doLast { + exec { + workingDir buildBinaryDir + executable "sh" + args "-c", "native-image -jar ${project.name}.jar --gc=G1 --static --libc=musl --no-fallback --enable-http --enable-https --enable-preview --add-modules jdk.incubator.concurrent -H:EnableURLProtocols=http,https --initialize-at-build-time=org.slf4j.LoggerFactory,ch.qos.logback.core.CoreConstants,ch.qos.logback.core.util.Loader,ch.qos.logback.core.util.StatusPrinter,ch.qos.logback.core.status.InfoStatus,ch.qos.logback.classic.Logger,ch.qos.logback.core.rolling.helper.FileNamePattern,ch.qos.logback.classic.Level,ch.qos.logback.core.status.StatusBase,io.opentelemetry.api.trace.ArrayBasedTraceStateBuilder,io.opentelemetry.context.LazyStorage,ch.qos.logback.core.util.FileSize,ch.qos.logback.core.rolling.helper.RollingCalendar,io.opentelemetry.api.internal.ImmutableSpanContext,io.opentelemetry.api.internal.OtelEncodingUtils,ch.qos.logback.classic.PatternLayout,io.opentelemetry.context.ThreadLocalContextStorage,io.opentelemetry.api.trace.PropagatedSpan,io.opentelemetry.context.ContextStorageWrappers,ch.qos.logback.core.rolling.helper.Compressor\$1,io.opentelemetry.api.trace.ImmutableTraceFlags,ch.qos.logback.core.rolling.helper.RollingCalendar\$1,ch.qos.logback.classic.model.ConfigurationModel,ch.qos.logback.core.model.processor.DefaultProcessor\$1,ch.qos.logback.core.model.processor.ImplicitModelHandler\$1,ch.qos.logback.core.subst.Token,ch.qos.logback.core.pattern.parser.Parser,ch.qos.logback.core.subst.Parser\$1,ch.qos.logback.core.util.Duration,ch.qos.logback.core.model.processor.ChainedModelFilter\$1,ch.qos.logback.classic.model.processor.ConfigurationModelHandler,ch.qos.logback.classic.model.processor.LogbackClassicDefaultNestedComponentRules,ch.qos.logback.core.subst.NodeToStringTransformer\$1,ch.qos.logback.core.pattern.parser.TokenStream\$1,ch.qos.logback.core.subst.Tokenizer\$1 --initialize-at-run-time=io.netty.channel.AbstractChannel,io.netty.channel.socket.nio.SelectorProviderUtil,io.netty.util.concurrent.DefaultPromise,io.netty,org.slf4j.MDC,org.github.gestalt.config ${project.name}" + standardOutput out + } + } + println(out.toString()) +} + +task buildBinaryG1GC { dependsOn jar def buildBinaryDir = "build/binary" def out = new ByteArrayOutputStream()