Skip to content

Commit

Permalink
Test artifactory publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
elx-cbrandom committed Jan 24, 2024
1 parent 0b36100 commit 0b3474e
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 16 deletions.
46 changes: 32 additions & 14 deletions .github/workflows/java-build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
52 changes: 50 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ configurations {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://artifactory.elyxor.com/artifactory/libs-release-local" }
jcenter()
}

Expand Down Expand Up @@ -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)
}
}
}
}

Expand All @@ -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'
Expand Down Expand Up @@ -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')
}
20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tool.poetry]
name = "cachethq_client"
version = "0.1.0"
description = ""
authors = ["cbrand <chris.brandom@elyxor.com>"]
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"

0 comments on commit 0b3474e

Please sign in to comment.