Skip to content

Merge branch 'swagger-api:master' into master #2

Merge branch 'swagger-api:master' into master

Merge branch 'swagger-api:master' into master #2

Workflow file for this run

name: Build Test Push
on:
push:
branches: [ "master" ]
jobs:
build_push:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11, 17 ]
env:
GENERATORS_VERSION_PROPERTY: ""
steps:
- uses: actions/checkout@v3
name: git checkout
with:
ref: master
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
cache: maven
- name: preliminary checks
run: |
docker login --username=${{ secrets.DOCKERHUB_SB_USERNAME }} --password=${{ secrets.DOCKERHUB_SB_PASSWORD }}
set -e
# fail if templates/generators contain carriage return '\r'
/bin/bash ./bin/utils/detect_carriage_return.sh
# fail if generators contain merge conflicts
/bin/bash ./bin/utils/detect_merge_conflict.sh
# fail if generators contain tab '\t'
/bin/bash ./bin/utils/detect_tab_in_java_class.sh
- uses: s4u/maven-settings-action@v2.8.0
name: setup maven settings.xml
with:
servers: |
[{
"id": "sonatype-nexus-staging",
"username": "${{ secrets.OSSRH_USERNAME }}",
"password": "${{ secrets.OSSRH_TOKEN }}"
},
{
"id": "sonatype-nexus-snapshots",
"username": "${{ secrets.OSSRH_USERNAME }}",
"password": "${{ secrets.OSSRH_TOKEN }}"
}]
- name: Build with Maven
if: ${{ matrix.java != 8 }}
run: |
export MY_POM_VERSION=`mvn -Dswagger-codegen-version=3.0.38 -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
export CODEGEN_VERSION=`sed -n 's/<swagger\-codegen\-version>\([^\s]*\)<\/swagger\-codegen\-version>/\1/p' pom.xml`
export CODEGEN_VERSION=`echo ${CODEGEN_VERSION} | tr -d '[:space:]'`
echo "CODEGEN_VERSION" ${CODEGEN_VERSION}
export CODEGEN_VERSION_PROPERTY=""
if [[ ! $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
if [[ ! $CODEGEN_VERSION =~ ^.*SNAPSHOT$ ]];
then
# check release version exists
export CODEGEN_FOUND_JSON=`curl -s --max-time 60 --retry 15 --connect-timeout 20 https://search.maven.org/solrsearch/select?q=g:io.swagger.codegen.v3%20AND%20a:swagger-codegen%20AND%20v:${CODEGEN_VERSION}%20AND%20p:jar`
export CODEGEN_FOUND=`echo ${CODEGEN_FOUND_JSON} | jq '.response.numFound'`
echo "CODEGEN_FOUND" ${CODEGEN_FOUND}
if [[ $CODEGEN_FOUND == '0' ]];
then
echo "codegen version not found"
rm -f maven-metadata.json
curl -o maven-metadata.json -s --max-time 60 --retry 15 --connect-timeout 30 -H "accept: application/json" https://oss.sonatype.org/service/local/repositories/snapshots/content/io/swagger/codegen/v3/swagger-codegen/
LAST_SNAP=`jq '[.data | sort_by(.lastModified) | reverse | .[] | select( .text | contains("3."))]| .[0].text' maven-metadata.json`
export LAST_SNAP=${LAST_SNAP:1:${#LAST_SNAP}-2}
echo "LAST_SNAP $LAST_SNAP"
export CODEGEN_VERSION_PROPERTY=-Dswagger-codegen-version=$LAST_SNAP
fi
fi
fi
echo "CODEGEN_VERSION_PROPERTY ${CODEGEN_VERSION_PROPERTY}"
echo "CODEGEN_VERSION_PROPERTY=${CODEGEN_VERSION_PROPERTY}" >> $GITHUB_ENV
./mvnw clean verify -U ${CODEGEN_VERSION_PROPERTY}
- name: Deploy Maven Snapshot
if: ${{ matrix.java == 17 }}
run: |
export MY_POM_VERSION=`mvn -Dswagger-codegen-version=3.0.38 -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
./mvnw clean deploy -U --settings $HOME/.m2/settings.xml
else
echo "not deploying release: " ${MY_POM_VERSION}
fi