Skip to content

Commit

Permalink
Promote from git tag (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr authored Jan 6, 2020
1 parent 7397c6b commit 8588d1c
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 3 deletions.
30 changes: 27 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,37 @@ version: 2.1
description: Creates and updates the CHANGELOG.md file

orbs:
orb-tools: circleci/orb-tools@2.0.0
orb-tools: circleci/orb-tools@9.0.0

workflows:
btd:
sdk:
jobs:
-
orb-tools/publish:
orb-path: src/sdk.yml
orb-ref: ory/sdk@dev:${CIRCLE_BRANCH}
publish-token-variable: CIRCLECI_DEV_API_TOKEN
validate: true
- orb-tools/dev-promote-prod-from-git-tag:
orb-name: ory/sdk
add-pr-comment: false
filters:
tags:
only: /.*/
branches:
ignore: /.*/
changelog:
jobs:
- orb-tools/publish:
orb-path: src/changelog.yml
orb-ref: ory/changelog@dev:${CIRCLE_BRANCH}
publish-token-variable: "$CIRCLECI_DEV_API_TOKEN"
validate: true
publish-token-variable: CIRCLECI_DEV_API_TOKEN
- orb-tools/dev-promote-prod-from-git-tag:
orb-name: ory/changelog
add-pr-comment: false
filters:
tags:
only: /.*/
branches:
ignore: /.*/
57 changes: 57 additions & 0 deletions src/sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: 2.1
description: Generates the Go SDK

orbs:
sdk:
executors:
changelog:
docker:
-
image: circleci/go:1.13
jobs:
generate:
parameters:
gitemail:
description: The git committer's email
type: string
default: [email protected]
gitusername:
description: The git committer's username
type: string
default: aeneasr
gitauthtoken:
description: A GitHub API Token
type: env_var_name
default: GITHUB_TOKEN
executor: changelog
steps:
- run: git config --global push.default matching
- checkout
- run: |
if [ "$(git show -s --format=%B | head -n 1)" != "Update SDK" ]]; then
echo "Generating SDK"
go install github.com/go-swagger/go-swagger/cmd/swagger github.com/ory/x/tools/listx github.com/sqs/goreturns
swagger generate spec -m -o ./docs/api.swagger.json -x sdk
swagger validate ./docs/api.swagger.json"
rm -rf ./sdk/go/$CIRCLE_PROJECT_REPONAME
swagger generate client -f ./docs/api.swagger.json -t sdk/go/$CIRCLE_PROJECT_REPONAME -A "Ory_$(tr '[:lower:]' '[:upper:]' <<< "${CIRCLE_PROJECT_REPONAME:0:1}")${CIRCLE_PROJECT_REPONAME:1})"
goreturns -w -local github.com/ory $(listx .)
git config --global user.email "<<parameters.gitemail>>"
git config --global user.name "<<parameters.gitusername>>"
git commit -m "Update SDK" -a || true
git push origin || true
else
echo "Skipping SDK generation"
fi
examples:
sdk:
description: Generate and commit the SDK
usage:
version: 2.1
orbs:
foo: ory/[email protected]
workflows:
generate:
jobs:
- sdk/generate

0 comments on commit 8588d1c

Please sign in to comment.