From 67a69630ae52e370a69acc41b7ff0712929ccf6a Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Mon, 16 Jan 2023 12:43:26 +0000 Subject: [PATCH 1/2] [TH2-4566] reusable workflow --- .github/workflows/dev-docker-publish.yml | 48 ------------------ .../dev-java-publish-sonatype-and-docker.yml | 19 +++++++ .../workflows/dev-java-publish-sonatype.yml | 50 ------------------- .github/workflows/docker-publish.yml | 37 -------------- .../java-publish-sonatype-and-docker.yml | 19 +++++++ .github/workflows/java-publish-sonatype.yml | 27 ---------- build.gradle | 9 +++- 7 files changed, 46 insertions(+), 163 deletions(-) delete mode 100644 .github/workflows/dev-docker-publish.yml create mode 100644 .github/workflows/dev-java-publish-sonatype-and-docker.yml delete mode 100644 .github/workflows/dev-java-publish-sonatype.yml delete mode 100644 .github/workflows/docker-publish.yml create mode 100644 .github/workflows/java-publish-sonatype-and-docker.yml delete mode 100644 .github/workflows/java-publish-sonatype.yml diff --git a/.github/workflows/dev-docker-publish.yml b/.github/workflows/dev-docker-publish.yml deleted file mode 100644 index 07309ac..0000000 --- a/.github/workflows/dev-docker-publish.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Dev build and publish Docker distributions to Github Container Registry ghcr.io - -on: - push: - branches-ignore: - - master - - version-* -# paths: -# - gradle.properties -# - package_info.json - -jobs: - build: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 -# Prepare custom build version - - name: Get branch name - id: branch - run: echo ::set-output name=branch_name::${GITHUB_REF#refs/*/} - - name: Get release_version - id: ver - uses: christian-draeger/read-properties@1.0.1 - with: - path: gradle.properties - property: release_version - - name: Build custom release version - id: release_ver - run: echo ::set-output name=value::"${{ steps.ver.outputs.value }}-${{ steps.branch.outputs.branch_name }}-${{ github.run_id }}" - - name: Show custom release version - run: echo ${{ steps.release_ver.outputs.value }} -# Build and publish image - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.CR_PAT }} - - run: echo "::set-output name=REPOSITORY_NAME::$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" - id: meta - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - push: true - tags: ghcr.io/${{ github.repository }}:${{ steps.release_ver.outputs.value }} - labels: com.exactpro.th2.${{ steps.meta.outputs.REPOSITORY_NAME }}=${{ steps.ver.outputs.value }} diff --git a/.github/workflows/dev-java-publish-sonatype-and-docker.yml b/.github/workflows/dev-java-publish-sonatype-and-docker.yml new file mode 100644 index 0000000..6f77755 --- /dev/null +++ b/.github/workflows/dev-java-publish-sonatype-and-docker.yml @@ -0,0 +1,19 @@ +name: Dev build and publish Docker distributions to Github Container Registry ghcr.io + +on: + push: + branches-ignore: + - master + - version-* + - dependabot** + paths-ignore: + - README.md + +jobs: + build-job: + uses: th2-net/.github/.github/workflows/compound-java-dev.yml@main + with: + build-target: 'Docker' + docker-username: ${{ github.actor }} + secrets: + docker-password: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/dev-java-publish-sonatype.yml b/.github/workflows/dev-java-publish-sonatype.yml deleted file mode 100644 index 01f9487..0000000 --- a/.github/workflows/dev-java-publish-sonatype.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Dev build and publish Java distributions to sonatype snapshot repository - -on: - push: - branches-ignore: - - master - - version-* - # paths: - # - gradle.properties - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 -# Prepare custom build version - - name: Get branch name - id: branch - run: echo ::set-output name=branch_name::${GITHUB_REF#refs/*/} - - name: Get release_version - id: ver - uses: christian-draeger/read-properties@1.0.1 - with: - path: gradle.properties - property: release_version - - name: Build custom release version - id: release_ver - run: echo ::set-output name=value::"${{ steps.ver.outputs.value }}-${{ steps.branch.outputs.branch_name }}-${{ github.run_id }}-SNAPSHOT" - - name: Write custom release version to file - uses: christian-draeger/write-properties@1.0.1 - with: - path: gradle.properties - property: release_version - value: ${{ steps.release_ver.outputs.value }} - - name: Show custom release version - run: echo ${{ steps.release_ver.outputs.value }} -# Build and publish package - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: '11' - - name: Build with Gradle - run: ./gradlew --info clean build publish - env: - ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} - ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} - diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml deleted file mode 100644 index bd62052..0000000 --- a/.github/workflows/docker-publish.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Build and publish Docker distributions to Github Container Registry ghcr.io - -on: - push: - branches: - - master - - version-* -# paths: -# - gradle.properties - -jobs: - build: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.CR_PAT }} - - run: echo "::set-output name=REPOSITORY_NAME::$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" - id: meta - - name: Read version from gradle.properties - id: read_property - uses: christian-draeger/read-properties@1.0.1 - with: - path: ./gradle.properties - property: release_version - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - push: true - tags: ghcr.io/${{ github.repository }}:${{ steps.read_property.outputs.value }} - labels: com.exactpro.th2.${{ steps.meta.outputs.REPOSITORY_NAME }}=${{ steps.read_property.outputs.value }} diff --git a/.github/workflows/java-publish-sonatype-and-docker.yml b/.github/workflows/java-publish-sonatype-and-docker.yml new file mode 100644 index 0000000..6f77755 --- /dev/null +++ b/.github/workflows/java-publish-sonatype-and-docker.yml @@ -0,0 +1,19 @@ +name: Dev build and publish Docker distributions to Github Container Registry ghcr.io + +on: + push: + branches-ignore: + - master + - version-* + - dependabot** + paths-ignore: + - README.md + +jobs: + build-job: + uses: th2-net/.github/.github/workflows/compound-java-dev.yml@main + with: + build-target: 'Docker' + docker-username: ${{ github.actor }} + secrets: + docker-password: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/java-publish-sonatype.yml b/.github/workflows/java-publish-sonatype.yml deleted file mode 100644 index b8c3668..0000000 --- a/.github/workflows/java-publish-sonatype.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Build and release Java distributions to sonatype. - -on: - push: - branches: - - master - - version-* - paths: - - gradle.properties - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: '11' - - name: Build with Gradle - run: ./gradlew --info clean build publish closeAndReleaseSonatypeStagingRepository - env: - ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} - ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} - ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }} - ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} diff --git a/build.gradle b/build.gradle index 0da5f4d..ebd9ba0 100644 --- a/build.gradle +++ b/build.gradle @@ -219,4 +219,11 @@ serviceLoader { test { useJUnitPlatform() -} \ No newline at end of file +} + + +configurations { + compileClasspath { + resolutionStrategy.activateDependencyLocking() + } +} From aa7bb51fff7cca40312164f9b65b0524173e55df Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Mon, 16 Jan 2023 14:23:33 +0000 Subject: [PATCH 2/2] [TH2-4566] reusable workflow 2 --- .../dev-java-publish-sonatype-and-docker.yml | 14 +++++++--- .../java-publish-sonatype-and-docker.yml | 26 ++++++++++++------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dev-java-publish-sonatype-and-docker.yml b/.github/workflows/dev-java-publish-sonatype-and-docker.yml index 6f77755..48a1f47 100644 --- a/.github/workflows/dev-java-publish-sonatype-and-docker.yml +++ b/.github/workflows/dev-java-publish-sonatype-and-docker.yml @@ -1,19 +1,27 @@ -name: Dev build and publish Docker distributions to Github Container Registry ghcr.io +name: Dev build and publish Java distributions to sonatype snapshot repository on: push: branches-ignore: - master - version-* - - dependabot** + - dependabot* paths-ignore: - README.md + # paths: + # - gradle.properties jobs: build-job: uses: th2-net/.github/.github/workflows/compound-java-dev.yml@main with: - build-target: 'Docker' + build-target: 'Sonatype,Docker' + runsOn: ubuntu-latest + gradleVersion: '6' docker-username: ${{ github.actor }} secrets: + sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} + sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} + sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }} + sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} docker-password: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/java-publish-sonatype-and-docker.yml b/.github/workflows/java-publish-sonatype-and-docker.yml index 6f77755..306d64a 100644 --- a/.github/workflows/java-publish-sonatype-and-docker.yml +++ b/.github/workflows/java-publish-sonatype-and-docker.yml @@ -1,19 +1,25 @@ -name: Dev build and publish Docker distributions to Github Container Registry ghcr.io +name: Build and release Java distributions to sonatype. on: push: - branches-ignore: - - master - - version-* - - dependabot** - paths-ignore: - - README.md + branches: + - master + - version-* + paths: + - gradle.properties jobs: - build-job: - uses: th2-net/.github/.github/workflows/compound-java-dev.yml@main + build: + uses: th2-net/.github/.github/workflows/compound-java.yml@main with: - build-target: 'Docker' + build-target: 'Sonatype,Docker' + runsOn: ubuntu-latest + gradleVersion: '6' docker-username: ${{ github.actor }} secrets: + sonatypeUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} + sonatypePassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} + sonatypeSigningKey: ${{ secrets.SONATYPE_GPG_ARMORED_KEY }} + sonatypeSigningPassword: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} docker-password: ${{ secrets.GITHUB_TOKEN }} + \ No newline at end of file