From 3019aaf811b0acbfda53107e7691e1219bffb937 Mon Sep 17 00:00:00 2001 From: Nikita Samoylov Date: Mon, 3 Jun 2024 22:29:40 +0300 Subject: [PATCH] CI configuration --- .github/workflows/neutral-build.yml | 16 ++++---- common-scripts.gradle | 59 +++++++++++++---------------- versions.gradle | 4 +- vico/compose-m2/build.gradle | 22 ----------- vico/compose-m3/build.gradle | 22 ----------- vico/compose/build.gradle | 22 ----------- vico/core/build.gradle | 22 ----------- vico/views/build.gradle | 22 ----------- 8 files changed, 38 insertions(+), 151 deletions(-) diff --git a/.github/workflows/neutral-build.yml b/.github/workflows/neutral-build.yml index 9bf7c7a5a..c0dc4141f 100644 --- a/.github/workflows/neutral-build.yml +++ b/.github/workflows/neutral-build.yml @@ -26,10 +26,11 @@ jobs: distribution: zulu - uses: gradle/gradle-build-action@v3 - - run: | + - name: Build + run: | + cd ${{ github.workspace }}/vico VERSION_NAME=$(grep -oP "(?<=version_name).*(?=\",)" versions.gradle | grep -oP "(?<=\").*") echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV - echo "TAG_NAME=v$VERSION_NAME" >> $GITHUB_ENV ./gradlew assembleDebug - name: Create tag @@ -40,17 +41,18 @@ jobs: github.git.createRef({ owner: context.repo.owner, repo: context.repo.repo, - ref: "refs/tags/${{ env.VERSION_NAME }}", + ref: "refs/tags/${{ env.VERSION_NAME }}-tangem${{ github.run_number }}", sha: context.sha }) - - name: Build and publish + - name: Publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }} run: | + cd ${{ github.workspace }}/vico echo sdk.dir = $ANDROID_HOME > local.properties - ./gradlew -PgithubUser=${{ secrets.GITHUB_ACTOR }} -PgithubPass=${{ secrets.GITHUB_TOKEN }} -PartifactVersion=${{ env.VERSION_NAME }} publish + ./gradlew -PgithubUser=${{ secrets.GITHUB_ACTOR }} -PgithubPass=${{ secrets.GITHUB_TOKEN }} -PpublishVersion=${{ env.VERSION_NAME }}-tangem${{ github.run_number }} publish - name: Build notification if: always() @@ -58,9 +60,9 @@ jobs: with: channel: '#development-android' status: ${{ job.status }} - success_text: 'Tangem Vico library build (${{ env.VERSION_NAME }}) has been created and uploaded to Nexus.' + success_text: 'Tangem Vico library build (${{ env.VERSION_NAME }}-tangem${{ github.run_number }}) has been created and uploaded to Nexus.' failure_text: 'GitHub Action #${{ github.run_number }} failed. Tag has not been not created.' cancelled_text: 'GitHub Action #${{ github.run_number }} was cancelled' fields: | - [{"title": "TAG", "value": "${{ env.VERSION_NAME }}"}, + [{"title": "TAG", "value": "${{ env.VERSION_NAME }}-tangem${{ github.run_number }}"}, {"title": "Action URL", "value": "${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}"}] diff --git a/common-scripts.gradle b/common-scripts.gradle index 436fe022a..024a5d378 100644 --- a/common-scripts.gradle +++ b/common-scripts.gradle @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +apply plugin: 'maven-publish' android { @@ -48,18 +49,35 @@ android { ext { getNamespace = this.&getNamespace - getArtifactId = this.&getArtifactId - customizePom = this.&customizePom - setUpRepositories = this.&setUpRepositories - setUpSigning = this.&setUpSigning } -String getNamespace(Project project) { - return "${library.groupId}.${project.name.replace("-", ".")}" +afterEvaluate { + publishing { + publications { + maven(MavenPublication) { + groupId = library.publishGroupId + artifactId = project.name + version = library.publishVersion + from components.release + + customizePom(pom) + } + } + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/tangem/vico") + credentials { + username = "$githubUser" + password = "$githubPass" + } + } + } + } } -String getArtifactId(Project project) { - return project.name +String getNamespace(Project project) { + return "${library.groupId}.${project.name.replace("-", ".")}" } void customizePom(MavenPom pom) { @@ -75,29 +93,4 @@ void customizePom(MavenPom pom) { url = "http://www.apache.org/licenses/LICENSE-2.0.txt" } } - - pom.scm { - connection = "scm:git:git://github.com/tangem/vico.git" - developerConnection = "scm:git:ssh://github.com/tangem/vico.git" - url = "https://github.com/patrykandpatrick/vico" - } -} - -boolean isReleaseVersion() { - return !project.version.endsWith("SNAPSHOT") -} - -void setUpRepositories(RepositoryHandler handler) { - handler.maven { - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/tangem/vico") - credentials { - username = "$githubUser" - password = "$githubPass" - } - } -} - -void setUpSigning(SigningExtension signing, MavenPublication publication) { - } diff --git a/versions.gradle b/versions.gradle index c1722bdb9..4d2c5dd34 100644 --- a/versions.gradle +++ b/versions.gradle @@ -18,7 +18,9 @@ ext { library = [ groupId : "com.patrykandpatrick.vico", - version_name : "2.0.0-alpha.21-tangem1", + publishGroupId : "com.tangem.vico", + version_name : "2.0.0-alpha.21", + publishVersion : project.hasProperty('publishVersion') ? project.getProperty('publishVersion') : '0.0.1', version_code : 1, target_sdk : 34, min_sdk : 19, diff --git a/vico/compose-m2/build.gradle b/vico/compose-m2/build.gradle index 7fda3e724..07b46020f 100644 --- a/vico/compose-m2/build.gradle +++ b/vico/compose-m2/build.gradle @@ -44,28 +44,6 @@ android { } } -afterEvaluate { - - publishing { - - publications { - - VicoComposeM2(MavenPublication) { - - groupId = library.groupId - artifactId = getArtifactId(project) - version = project.version - from components.release - - customizePom(pom) - setUpRepositories(repositories) - } - } - } - - setUpSigning(signing, publishing.publications.VicoComposeM2) -} - dependencies { api project(":vico:compose") diff --git a/vico/compose-m3/build.gradle b/vico/compose-m3/build.gradle index bfeb96fff..896512e51 100644 --- a/vico/compose-m3/build.gradle +++ b/vico/compose-m3/build.gradle @@ -45,28 +45,6 @@ android { } } -afterEvaluate { - - publishing { - - publications { - - VicoComposeM3(MavenPublication) { - - groupId = library.groupId - artifactId = getArtifactId(project) - version = project.version - from components.release - - customizePom(pom) - setUpRepositories(repositories) - } - } - } - - setUpSigning(signing, publishing.publications.VicoComposeM3) -} - dependencies { api project(":vico:compose") diff --git a/vico/compose/build.gradle b/vico/compose/build.gradle index 5d33619d1..4e24b6554 100644 --- a/vico/compose/build.gradle +++ b/vico/compose/build.gradle @@ -45,28 +45,6 @@ android { } } -afterEvaluate { - - publishing { - - publications { - - VicoCompose(MavenPublication) { - - groupId = library.groupId - artifactId = getArtifactId(project) - version = project.version - from components.release - - customizePom(pom) - setUpRepositories(repositories) - } - } - } - - setUpSigning(signing, publishing.publications.VicoCompose) -} - dependencies { api project(":vico:core") diff --git a/vico/core/build.gradle b/vico/core/build.gradle index 469c48e86..d26fa0af3 100644 --- a/vico/core/build.gradle +++ b/vico/core/build.gradle @@ -36,28 +36,6 @@ android { } } -afterEvaluate { - - publishing { - - publications { - - VicoCore(MavenPublication) { - - groupId = library.groupId - artifactId = getArtifactId(project) - version = project.version - from components.release - - customizePom(pom) - setUpRepositories(repositories) - } - } - } - - setUpSigning(signing, publishing.publications.VicoCore) -} - dependencies { implementation libs.androidXAnnotation implementation libs.coroutinesCore diff --git a/vico/views/build.gradle b/vico/views/build.gradle index 89d27bd5d..2ce295b00 100644 --- a/vico/views/build.gradle +++ b/vico/views/build.gradle @@ -34,28 +34,6 @@ android { } } -afterEvaluate { - - publishing { - - publications { - - VicoView(MavenPublication) { - - groupId = library.groupId - artifactId = getArtifactId(project) - version = project.version - from components.release - - customizePom(pom) - setUpRepositories(repositories) - } - } - } - - setUpSigning(signing, publishing.publications.VicoView) -} - dependencies { api project(":vico:core")