Skip to content

Commit

Permalink
Create changelog orb (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr authored Jan 6, 2020
1 parent 0dc12b0 commit 7397c6b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 103 deletions.
51 changes: 7 additions & 44 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,13 @@ version: 2.1
description: Creates and updates the CHANGELOG.md file

orbs:
changelog:
executors:
changelog:
docker:
-
image: circleci/ruby:2.5-node
jobs:
changelog:
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: The git committer's username
type: string
executor: changelog
steps:
- run: git config --global push.default matching
- checkout
- run: gem install github_changelog_generator -v 1.14.3
- run: sudo npm i -g doctoc
- restore_cache:
keys:
- changelog-v1
- run: github_changelog_generator -u $CIRCLE_PROJECT_USERNAME -p $CIRCLE_PROJECT_REPONAME -o CHANGELOG.md --token <<parameters.gitauthtoken>> --cache-file /tmp/github_changelog_generator
- save_cache:
key: changelog-v1
paths:
- "/tmp/github_changelog_generator"
- run: doctoc CHANGELOG.md
- run: git config --global user.email "<<parameters.gitemail>>"
- run: git config --global user.name "<<parameters.gitusername>>"
- run: git add CHANGELOG.md
- run: |
git commit -m "Update CHANGELOG [ci skip]" -- CHANGELOG.md
- run: git push origin
orb-tools: circleci/[email protected]

workflows:
changelog:
btd:
jobs:
- changelog/changelog:
gitauthtoken: $GITHUB_TOKEN
- orb-tools/publish:
orb-path: src/changelog.yml
orb-ref: ory/changelog@dev:${CIRCLE_BRANCH}
publish-token-variable: "$CIRCLECI_DEV_API_TOKEN"
validate: true
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
**Table of Contents**

- [Change Log](#change-log)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# Change Log

This Change Log was automatically generated


\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
56 changes: 0 additions & 56 deletions changelog.yml

This file was deleted.

60 changes: 60 additions & 0 deletions src/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: 2.1
description: Creates and updates the CHANGELOG.md file

orbs:
changelog:
executors:
changelog:
docker:
-
image: circleci/ruby:2.5-node
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: gem install github_changelog_generator -v 1.14.3
- run: sudo npm i -g doctoc
- restore_cache:
keys:
- changelog-v1
- run: github_changelog_generator -u $CIRCLE_PROJECT_USERNAME -p $CIRCLE_PROJECT_REPONAME -o CHANGELOG.md --token ${<<parameters.gitauthtoken>>} --cache-file /tmp/github_changelog_generator
- save_cache:
key: changelog-v1
paths:
- "/tmp/github_changelog_generator"
- run: doctoc CHANGELOG.md
- run: "sed -i 's/\\*\\*Table of Contents.*/**Table of Contents**/' CHANGELOG.md"
- run: "sed -i 's/\\*This Change Log was.*/This Change Log was automatically generated/' CHANGELOG.md"
- run: git config --global user.email "<<parameters.gitemail>>"
- run: git config --global user.name "<<parameters.gitusername>>"
- run: git add CHANGELOG.md
- run: |
git commit -m "Update CHANGELOG [ci skip]" -- CHANGELOG.md || true
- run: git push origin || true

examples:
changelog:
description: Generate and commit the changelog
usage:
version: 2.1
orbs:
foo: ory/[email protected]
workflows:
generate:
jobs:
- changelog/changelog

0 comments on commit 7397c6b

Please sign in to comment.