Code Monkey home page Code Monkey logo

agconnect-publishing-gradle-plugin's Introduction

Huawei AppGallery Connect Publishing Gradle Plugin

Social Media Preview

Legal Disclaimer: This product is NOT officially endorsed or certified by Huawei Technologies Co., Ltd.
The trademarks are being referenced for identification purposes only, in terms of a nominative fair use.

The official Huawei repositories can be found there: @HMS-Core.


Features

  • It automates the Huawei AppGallery Connect Publishing API.
  • It can upload and release Android APK/ABB packages.

Development

The plugin source code can be swiftly installed into any Android Gradle project with git clone:

git clone https://github.com/syslogic/agconnect-publishing-gradle-plugin.git ./buildSrc

Package Installation

Plugin io.syslogic.agconnect.publishing depends on com.android.application.

These plugins can be set up in the buildscript block of the root project's build.gradle:

buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://developer.huawei.com/repo/' }
        maven { url 'https://jitpack.io' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.3.1'
        classpath 'com.huawei.agconnect:agcp:1.9.1.303'
        classpath 'io.syslogic:agconnect-publishing-gradle-plugin:1.3.4'
    }
}

Or in the version-catalog gradle/libs.versions.toml:

[versions]
agconnect_publishing_plugin = '1.3.4'

[plugins]
agconnect_publishing = { id = "io.syslogic.agconnect.publishing", version.ref = "agconnect_publishing_plugin" }

Then they can be applied in the module's build.gradle:

plugins {
    id 'com.android.application'
    id 'com.huawei.agconnect'
    // id 'io.syslogic.agconnect.publishing'
    alias(libs.plugins.agconnect.publishing)
}

Configuration

PublicationExtension can be configured with the following properties:

  • configFile: The path to the API client credentials file is absolute.
  • releaseType: Release Type, 1=network (default), 3=phased.
  • verbose: Verbose logging, on/off.
  • logHttp: HTTP logging, on/off.
/** Huawei AppGallery Connect: agc-apiclient.json */
def json_agc = "distribution${File.separator}agconnect_apiclient.json"
if (rootProject.file(json_agc).exists()) {
    agcPublishing {
        configFile = rootProject.file(json_agc).absolutePath
        releaseType = 1
        verbose = false
        logHttp = true
    }
}

These properties are all optional, while:

  • providing the config file at the default location: distribution/agconnect_apiclient.json.

Plugin Tasks

Gradle Plugin Tasks

Example Log Output

The log output for task :mobile:uploadReleaseAab explains what it does.
To be precise, it only uploads APK/ABB packages, but does not release them.

> Task :mobile:bundleRelease
> Task :mobile:uploadReleaseAab
> POST /api/oauth2/v1/token HTTP/1.1
> HTTP/1.1 200 OK
> GET /api/publish/v2/upload-url?appId=000000000&releaseType=1&suffix=aab HTTP/1.1
> HTTP/1.1 200 OK
> POST /FileServer/uploadFile HTTP/1.1
> HTTP/1.1 200 OK
> PUT /api/publish/v2/app-file-info?appId=000000000&releaseType=1 HTTP/1.1
> HTTP/1.1 200 OK
> GET /api/publish/v2/package/compile/status?appId=000000000&pkgIds=00000000000000000 HTTP/1.1
> HTTP/1.1 200 OK

AAB file someapp_1.0.0-huawei-release.aab has been uploaded.
13.1 MB in 14s equals a transfer-rate of 957.0 kB/s.

Note: After this, some app-information still needs to be manually completed.

The log output for task :mobile:publishReleaseAab explains what it does.
To be precise, it submits an already uploaded APK/ABB package for review.

> Task :mobile:publishReleaseAab
> POST /api/oauth2/v1/token HTTP/1.1
> HTTP/1.1 200 OK
> POST /api/publish/v2/app-submit?appId=000000000&releaseType=1 HTTP/1.1
> HTTP/1.1 200 OK
Submitted for release: org.acme.someapp (000000000).

Support

Status

Gradle CI

Release

MIT License

agconnect-publishing-gradle-plugin's People

Contributors

syslogic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

agconnect-publishing-gradle-plugin's Issues

How to make get upload-url api call working

Hey, we are trying to make api call to upload-url but all I am getting is 404

$ curl -I -H 'Accept: application/json' \
               -H 'Content-Type: application/json' \
               -H "client_id: ${client_id}"
               -H "Authorization: Bearer ${access_token}" \
               'https://connect-api.cloud.huawei.com/api/publish/v2/upload-url?appId=${appid}&suffix=aab&releaseType=1'
HTTP/1.1 404 Not Found
Connection: keep-alive
Date: Thu, 23 Mar 2023 15:10:26 GMT
X-Cache: Error from cloudfront
Via: 1.1 f3303a5632dc925c26253530523fa328.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: PRG50-C1
X-Amz-Cf-Id: cgRkAZ4FbsHwuJnAda-VCcPe2QI7N87oPWd8h6aBb2fH6MqEhMoXMA==

We have

  1. created an api client in AG in users-permission - connect api - api client - create. It has role of administrator and our only project which our apps are part of
  2. Used its client_id and client_secret in curl above
  3. Fetched access_token by succesfully calling https://connect-api.cloud.huawei.com/api/oauth2/v1/token

We have double checked all with your source code and every single thing seems to be matching. Headers, query params etc. Is there anything we need to do in AG console? Enable something somewhere....

We are terribly sorry to mis-use this bugtracker for this question. Your gradle plugin is one of rare resources we were able to find. You can maybe as well see this as question of what needs to be configured in AppGallery Connect to make your gradle plugin work. Thanks for any sort of reply ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.