|
| 1 | +version: 2 |
| 2 | +jobs: |
| 3 | + build: |
| 4 | + docker: |
| 5 | + - image: martinthomson/i-d-template:latest |
| 6 | + resource_class: small |
| 7 | + working_directory: ~/draft |
| 8 | + |
| 9 | + steps: |
| 10 | + - run: |
| 11 | + name: "Print Configuration" |
| 12 | + command: | |
| 13 | + xml2rfc --version |
| 14 | + gem list -q kramdown-rfc |
| 15 | + echo -n 'mmark '; mmark --version |
| 16 | +
|
| 17 | + - restore_cache: |
| 18 | + name: "Restoring cache - Git" |
| 19 | + keys: |
| 20 | + - v2-cache-git-{{ .Branch }}-{{ .Revision }} |
| 21 | + - v2-cache-git-{{ .Branch }} |
| 22 | + - v2-cache-git- |
| 23 | + |
| 24 | + - restore_cache: |
| 25 | + name: "Restoring cache - References" |
| 26 | + keys: |
| 27 | + - v1-cache-references-{{ epoch }} |
| 28 | + - v1-cache-references- |
| 29 | + |
| 30 | + # Workaround for https://discuss.circleci.com/t/22437 |
| 31 | + - run: |
| 32 | + name: Tag Checkout |
| 33 | + command: | |
| 34 | + if [ -n "$CIRCLE_TAG" ] && [ -d .git ]; then |
| 35 | + remote=$(echo "$CIRCLE_REPOSITORY_URL" | \ |
| 36 | + sed -e 's,/^git.github.com:,https://github.com/,') |
| 37 | + git fetch -f "$remote" "refs/tags/$CIRCLE_TAG:refs/tags/$CIRCLE_TAG" || \ |
| 38 | + (echo 'Removing .git cache for tag build'; rm -rf .git) |
| 39 | + fi |
| 40 | +
|
| 41 | + - checkout |
| 42 | + |
| 43 | + # Build txt and html versions of drafts |
| 44 | + - run: |
| 45 | + name: "Build Drafts" |
| 46 | + command: make |
| 47 | + |
| 48 | + # Update editor's copy on gh-pages |
| 49 | + - run: |
| 50 | + name: "Update GitHub Pages" |
| 51 | + command: | |
| 52 | + if [ "${CIRCLE_TAG#draft-}" == "$CIRCLE_TAG" ]; then |
| 53 | + make gh-pages |
| 54 | + fi |
| 55 | +
|
| 56 | + # For tagged builds, upload to the datatracker. |
| 57 | + - deploy: |
| 58 | + name: "Upload to Datatracker" |
| 59 | + command: | |
| 60 | + if [ "${CIRCLE_TAG#draft-}" != "$CIRCLE_TAG" ]; then |
| 61 | + make upload |
| 62 | + fi |
| 63 | +
|
| 64 | + # Archive GitHub Issues |
| 65 | + - run: |
| 66 | + name: "Archive GitHub Issues" |
| 67 | + command: "make archive || make archive DISABLE_ARCHIVE_FETCH=true && make gh-archive" |
| 68 | + |
| 69 | + # Create and store artifacts |
| 70 | + - run: |
| 71 | + name: "Create Artifacts" |
| 72 | + command: "make artifacts CI_ARTIFACTS=/tmp/artifacts" |
| 73 | + |
| 74 | + - store_artifacts: |
| 75 | + path: /tmp/artifacts |
| 76 | + |
| 77 | + - run: |
| 78 | + name: "Prepare for Caching" |
| 79 | + command: "git reflog expire --expire=now --all && git gc --prune=now" |
| 80 | + |
| 81 | + - save_cache: |
| 82 | + name: "Saving Cache - Git" |
| 83 | + key: v2-cache-git-{{ .Branch }}-{{ .Revision }} |
| 84 | + paths: |
| 85 | + - ~/draft/.git |
| 86 | + |
| 87 | + - save_cache: |
| 88 | + name: "Saving Cache - Drafts" |
| 89 | + key: v1-cache-references-{{ epoch }} |
| 90 | + paths: |
| 91 | + - ~/.cache/xml2rfc |
| 92 | + |
| 93 | + |
| 94 | +workflows: |
| 95 | + version: 2 |
| 96 | + build: |
| 97 | + jobs: |
| 98 | + - build: |
| 99 | + filters: |
| 100 | + tags: |
| 101 | + only: /.*?/ |
0 commit comments