Skip to content

Commit

Permalink
Build and upload Swagger Codegen CLI Docker image on release (swagger…
Browse files Browse the repository at this point in the history
…-api#4912)

* Run mvn in batch-mode to be less verbose on download

* Build and upload Swagger Codegen CLI Docker image on release

* Ensure we only push master and tags to Docker Hub
  • Loading branch information
arnested authored and wing328 committed Mar 12, 2017
1 parent c76f006 commit 0b9aaad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ script:
# fail if generators contain tab '\t'
- /bin/bash ./bin/utils/detect_tab_in_java_class.sh
# run integration tests defined in maven pom.xml
- mvn verify -Psamples
# docker test
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_IMAGE_NAME:latest $DOCKER_IMAGE_NAME:$TRAVIS_TAG; fi && docker push $DOCKER_IMAGE_NAME; fi
- mvn --batch-mode verify -Psamples
# docker: build generator image and push to Docker Hub
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME; fi; fi
# docker: build cli image and push to Docker Hub
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/swagger-codegen-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME; fi; fi

env:
- DOCKER_IMAGE_NAME=swaggerapi/swagger-generator
- DOCKER_GENERATOR_IMAGE_NAME=swaggerapi/swagger-generator DOCKER_CODEGEN_CLI_IMAGE_NAME=swaggerapi/swagger-codegen-cli
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ docker stop $CID && docker rm $CID

In the example above, `result.zip` will contain the generated client.

##### Swagger Codegen Docker Image
##### Swagger Codegen CLI Docker Image

The Swagger Codegen image acts as a standalone executable. It can be used as an alternative to installing via homebrew, or for developers who are unable to install Java or upgrade the installed version.

Expand All @@ -200,7 +200,7 @@ To generate code with this image, you'll need to mount a local location as a vol
Example:

```
docker run --rm -v ${PWD}:/local swagger-api/swagger-codegen generate \
docker run --rm -v ${PWD}:/local swagger-api/swagger-codegen-cli generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l go \
-o /local/out/go
Expand Down

0 comments on commit 0b9aaad

Please sign in to comment.