diff --git a/.github/workflows/java-build-and-publish.yml b/.github/workflows/java-build-and-publish.yml index 15a61d6..6520196 100644 --- a/.github/workflows/java-build-and-publish.yml +++ b/.github/workflows/java-build-and-publish.yml @@ -1,18 +1,36 @@ -name: GitHub Actions Demo -run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +name: Java Build and Publish + on: [push] + jobs: - Explore-GitHub-Actions: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: Check out repository code - uses: actions/checkout@v4 - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ github.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Build with Gradle + uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + with: + arguments: build + + # The USERNAME and TOKEN need to correspond to the credentials environment variables used in + # the publishing section of your build.gradle + - name: Publish to GitHub Packages + uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + with: + arguments: publish + env: + USERNAME: ${{ github.actor }} + TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }} diff --git a/build.gradle b/build.gradle index cdc56f6..b7987ca 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,6 @@ configurations { repositories { mavenLocal() mavenCentral() - maven { url "https://artifactory.elyxor.com/artifactory/libs-release-local" } jcenter() } @@ -156,7 +155,16 @@ publishing { } } repositories { - maven { url = 'https://artifactory.elyxor.com/artifactory/libs-release-local' } + maven { + url = 'https://artifactory.elyxor.com/artifactory/libs-snapshot-local' + credentials(HttpHeaderCredentials) { + name = "X-JFrog-Art-API" + value = System.getenv('TOKEN') + } + authentication { + header(HttpHeaderAuthentication) + } + } } } @@ -167,6 +175,12 @@ import io.swagger.codegen.v3.ClientOptInput import io.swagger.codegen.v3.ClientOpts import io.swagger.v3.parser.OpenAPIV3Parser +task copyPyProjectFile(type: Copy, dependsOn: classes) { + println "Copy pyproject.toml" + from "${rootProject.projectDir}/pyproject.toml" + into 'python-client' +} + task generateApi { FileTree swaggerFiles = fileTree('.') { include '*.yaml' @@ -204,8 +218,42 @@ task generateApi { } } +task generateApiPython { + FileTree swaggerFiles = fileTree('.') { + include '*.yaml' + } + + inputs.files(swaggerFiles) + outputs.dir('python-client') + outputs.dir('python-client/cachethq_client') + + doLast { + swaggerFiles.each { File file -> + println "Processing file: " + file + def codegenConfig = CodegenConfigLoader.forName('python') + codegenConfig.setOutputDir('python-client') + def options = new ClientOpts() + options.setProperties([ + 'packageName': 'cachethq_client', + 'interfaceOnly': 'true' + ]) + def openAPI = new OpenAPIV3Parser().read(file.toString(), null, null) + def clientOpts = new ClientOptInput() + clientOpts.setOpenAPI(openAPI) + clientOpts.setConfig(codegenConfig) + clientOpts.setOpts(options) + + new DefaultGenerator().opts(clientOpts).generate() + + } + } +} + compileJava.dependsOn generateApi +generateApi.finalizedBy generateApiPython +generateApiPython.finalizedBy copyPyProjectFile clean.doFirst { delete(codegenOutputDir) + delete('python-client') } diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..bf64125 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,20 @@ +[tool.poetry] +name = "cachethq_client" +version = "0.1.0" +description = "" +authors = ["cbrand "] +readme = "README.md" +license = "Apache-2.0" + +[tool.poetry.dependencies] +python = "^3.11" +certifi = "^2023.11.17" +six = "^1.16.0" +python-dateutil = "^2.8.2" +setuptools = "^69.0.3" +urllib3 = "^2.1.0" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api"