|
20 | 20 |
|
21 | 21 | # TODO: figure out how to make deploy.py rebuild the index. |
22 | 22 | # python ~/packs/.circle/deploy.py pack.yaml "${CIRCLE_PROJECT_REPONAME}" |
| 23 | + |
23 | 24 | # Clean up so the script can be retries in case of failure (e.g. race) |
24 | 25 | rm -rf ~/index |
25 | 26 | git clone https://${MACHINE_USER}:${MACHINE_PASSWORD}@github.com/StackStorm-Exchange/index ~/index 2>/dev/null |
26 | 27 |
|
27 | 28 | echo "Processing pack ${PACK_NAME}" |
28 | 29 |
|
| 30 | +# NOTE: We create tags before re-building the index to ensure latest tag is reflected in the index |
| 31 | + |
| 32 | +# Create version tags |
| 33 | +METADATA_CHANGES=$(git rev-list --all --no-abbrev --remove-empty -- pack.yaml) |
| 34 | +for COMMIT in $(echo $METADATA_CHANGES) |
| 35 | +do |
| 36 | + git checkout ${COMMIT} pack.yaml > /dev/null |
| 37 | + VERSION=$(~/virtualenv/bin/python ~/ci/.circle/semver.py pack.yaml 2>/dev/null || true) |
| 38 | + |
| 39 | + # 1. Create a tag if version is specified and tag doesn't exist locally |
| 40 | + if [[ ${VERSION} ]] && [[ -z $(git rev-parse -q --verify "refs/tags/v${VERSION}") ]] |
| 41 | + then |
| 42 | + echo "Creating tag ${VERSION} for commit ${COMMIT}" |
| 43 | + git tag v${VERSION} ${COMMIT} |
| 44 | + fi |
| 45 | + |
| 46 | + # 2. If version is specified and tag doesn't exist on the remote, push it |
| 47 | + if [[ ${VERSION} ]] && [[ -z $(git ls-remote origin "refs/tags/v${VERSION}") ]] |
| 48 | + then |
| 49 | + echo "Pushing tag v${VERSION} to origin remote" |
| 50 | + git push origin v${VERSION} |
| 51 | + fi |
| 52 | +done |
| 53 | + |
| 54 | +# Rebuild pack index directory |
29 | 55 | ~/virtualenv/bin/python ~/ci/utils/pack_content.py --input . --output ~/index/v1/packs/"${PACK_NAME}" |
30 | 56 |
|
31 | 57 | # Rebuild the index JSON |
@@ -57,7 +83,6 @@ git -C ~/index status |
57 | 83 |
|
58 | 84 | if ! git -C ~/index diff --quiet --exit-code --cached |
59 | 85 | then |
60 | | - |
61 | 86 | echo "Updating the index repo..." |
62 | 87 | git -C ~/index commit -m "Update the ${PACK_NAME} pack." |
63 | 88 | git -C ~/index push origin 2>/dev/null |
|
73 | 98 | else |
74 | 99 | echo "No changes to pack metadata, skipping the index update." |
75 | 100 | fi |
76 | | - |
77 | | -# Create version tags |
78 | | -METADATA_CHANGES=$(git rev-list --all --no-abbrev --remove-empty -- pack.yaml) |
79 | | -for COMMIT in $(echo $METADATA_CHANGES) |
80 | | -do |
81 | | - git checkout ${COMMIT} pack.yaml > /dev/null |
82 | | - VERSION=$(~/virtualenv/bin/python ~/ci/.circle/semver.py pack.yaml 2>/dev/null || true) |
83 | | - |
84 | | - # 1. Create a tag if version is specified and tag doesn't exist locally |
85 | | - if [[ ${VERSION} ]] && [[ -z $(git rev-parse -q --verify "refs/tags/v${VERSION}") ]] |
86 | | - then |
87 | | - echo "Creating tag ${VERSION} for commit ${COMMIT}" |
88 | | - git tag v${VERSION} ${COMMIT} |
89 | | - fi |
90 | | - |
91 | | - # 2. If version is specified and tag doesn't exist on the remote, push it |
92 | | - if [[ ${VERSION} ]] && [[ -z $(git ls-remote origin "refs/tags/v${VERSION}") ]] |
93 | | - then |
94 | | - echo "Pushing tag v${VERSION} to origin remote" |
95 | | - git push origin v${VERSION} |
96 | | - fi |
97 | | -done |
|
0 commit comments