Skip to content

Commit b588d0e

Browse files
committed
chore(ci): Use workspace for storing release version
1 parent bff11f9 commit b588d0e

1 file changed

Lines changed: 30 additions & 26 deletions

File tree

.circleci/config.yml

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@ orbs:
1212
codecov: codecov/codecov@1.1.1
1313

1414
commands:
15-
lint:
16-
description: Run ESLint.
17-
parameters:
18-
path:
19-
type: string
20-
default: .
21-
steps:
22-
- run:
23-
name: ESLint
24-
command: |
25-
cd << parameters.path >>
26-
mkdir -p $ARTIFACTS/test_results/eslint
27-
yarn lint --format="junit" --output-file="$ARTIFACTS/test_results/eslint/eslint.xml"
2815
test:
2916
description: Run Jest.
3017
parameters:
@@ -65,6 +52,8 @@ commands:
6552
default: false
6653
steps:
6754
- checkout
55+
- attach_workspace:
56+
at: workspace
6857
- run:
6958
name: Node.js version
7059
command: |
@@ -108,6 +97,23 @@ commands:
10897
key: yarn-v5-{{ .Branch }}-{{ checksum "yarn.lock" }}
10998
paths:
11099
- yarn_cache
100+
- run:
101+
name: Compute release version
102+
command: |
103+
RELEASE_VERSION="$(./node_modules/.bin/json version < lerna.json)"
104+
105+
if [[ -z "<< pipeline.git.tag >>" ]]; then
106+
RELEASE_VERSION="${RELEASE_VERSION}-next.${CIRCLE_BUILD_NUM}+${CIRCLE_SHA1:0:7}"
107+
else
108+
RELEASE_VERSION="${RELEASE_VERSION}+${CIRCLE_SHA1:0:7}"
109+
fi
110+
111+
echo "Release version is: $RELEASE_VERSION"
112+
echo "$RELEASE_VERSION" > ./workspace/version
113+
- persist_to_workspace:
114+
root: workspace
115+
paths:
116+
- version
111117
- run:
112118
name: Setup artifacts directory
113119
command: |
@@ -117,18 +123,12 @@ commands:
117123
- run:
118124
name: Set release version
119125
command: |
120-
RELEASE_VERSION="$(./node_modules/.bin/json version < lerna.json)"
126+
RELEASE_VERSION="$(cat ./workspace/version)"
127+
echo "export RELEASE_VERSION=\"${RELEASE_VERSION}\"" >> $BASH_ENV
121128
122129
if [[ -z "<< pipeline.git.tag >>" ]]; then
123-
RELEASE_VERSION="${RELEASE_VERSION}+${CIRCLE_BUILD_NUM}.${CIRCLE_SHA1:0:7}"
124-
echo "<$RELEASE_VERSION>"
125-
yarn lerna version --ignore-scripts --no-git-tag-version --no-private --no-push --yes "$RELEASE_VERSION"
126-
else
127-
RELEASE_VERSION="${RELEASE_VERSION}-next.${CIRCLE_BUILD_NUM}+${CIRCLE_SHA1:0:7}"
130+
yarn lerna version --ignore-scripts --no-git-tag-version --no-private --no-push --yes "${RELEASE_VERSION}"
128131
fi
129-
130-
echo "export RELEASE_VERSION=\"${RELEASE_VERSION}\"" >> $BASH_ENV
131-
132132
finalize:
133133
description: Finalize a JS project build and upload its artifacts.
134134
parameters:
@@ -240,7 +240,11 @@ jobs:
240240
steps:
241241
- initialize:
242242
online: true
243-
- lint
243+
- run:
244+
name: ESLint
245+
command: |
246+
mkdir -p $ARTIFACTS/test_results/eslint
247+
yarn lint --format="junit" --output-file="$ARTIFACTS/test_results/eslint/eslint.xml"
244248
- test:
245249
coverage: true
246250
- finalize:
@@ -251,12 +255,12 @@ jobs:
251255
working_directory: /mnt/ramdisk
252256
steps:
253257
- attach_workspace:
254-
at: undercut
258+
at: workspace
255259
- run:
256-
name: Pack all
260+
name: Compose release tarball
257261
command: |
258262
mkdir artifacts
259-
tar -cv -f artifacts/undercut-${RELEASE_VERSION}.tar undercut
263+
tar -cv -f artifacts/undercut-${RELEASE_VERSION}.tar workspace
260264
- store_artifacts:
261265
path: artifacts
262266

0 commit comments

Comments
 (0)