Skip to content

Commit 87c1176

Browse files
authored
ci: Add auto tag release scripts for prefixed branch (#245)
* feat(e2e): add tag release script for prefixed branch * remove null safety tag release
1 parent aa14e86 commit 87c1176

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

.circleci/config.base.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,7 @@ jobs:
118118
- run:
119119
name: Publish Amplify Codegen
120120
command: |
121-
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
122-
git config --global user.email $GITHUB_EMAIL
123-
git config --global user.name $GITHUB_USER
124-
npm run publish:$CIRCLE_BRANCH
125-
else
126-
echo "Skipping deploy."
127-
fi
121+
bash ./.circleci/publish.sh
128122
129123
publish_to_local_registry:
130124
<<: *defaults
@@ -235,7 +229,7 @@ workflows:
235229
only:
236230
- master
237231
- e2e-testing
238-
- dart-modelgen-null-safety
232+
- /tagged-release\/.*/
239233
- e2e-test:
240234
context:
241235
- cleanup-resources
@@ -249,7 +243,7 @@ workflows:
249243
only:
250244
- master
251245
- e2e-testing
252-
- dart-modelgen-null-safety
246+
- /tagged-release\/.*/
253247
- deploy:
254248
os: linux_node12
255249
requires:
@@ -261,7 +255,8 @@ workflows:
261255
only:
262256
- release
263257
- master
264-
- dart-modelgen-null-safety
258+
- /tagged-release\/.*/
259+
- /tagged-release-without-e2e-tests\/.*/
265260
- done_with_node_e2e_tests:
266261
os: linux_node12
267262
requires:

.circleci/config.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,7 @@ jobs:
126126
- run:
127127
name: Publish Amplify Codegen
128128
command: |
129-
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
130-
git config --global user.email $GITHUB_EMAIL
131-
git config --global user.name $GITHUB_USER
132-
npm run publish:$CIRCLE_BRANCH
133-
else
134-
echo "Skipping deploy."
135-
fi
129+
bash ./.circleci/publish.sh
136130
publish_to_local_registry:
137131
working_directory: ~/repo
138132
parameters: *ref_0
@@ -420,7 +414,7 @@ workflows:
420414
only:
421415
- master
422416
- e2e-testing
423-
- dart-modelgen-null-safety
417+
- /tagged-release\/.*/
424418
- deploy:
425419
os: linux_node12
426420
requires:
@@ -432,7 +426,8 @@ workflows:
432426
only:
433427
- release
434428
- master
435-
- dart-modelgen-null-safety
429+
- /tagged-release\/.*/
430+
- /tagged-release-without-e2e-tests\/.*/
436431
- done_with_node_e2e_tests:
437432
os: linux_node12
438433
requires:
@@ -471,7 +466,7 @@ workflows:
471466
only:
472467
- master
473468
- e2e-testing
474-
- dart-modelgen-null-safety
469+
- /tagged-release\/.*/
475470
- add-codegen-android-e2e-test:
476471
context: *ref_8
477472
os: linux_node12

.circleci/publish.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash -e
2+
if [ -z "$CIRCLE_PULL_REQUEST" ]; then
3+
git config --global user.email $GITHUB_EMAIL
4+
git config --global user.name $GITHUB_USER
5+
if [[ "$CIRCLE_BRANCH" =~ ^tagged-release ]]; then
6+
if [[ "$CIRCLE_BRANCH" =~ ^tagged-release-without-e2e-tests\/.* ]]; then
7+
# Remove tagged-release-without-e2e-tests/
8+
export NPM_TAG="${CIRCLE_BRANCH/tagged-release-without-e2e-tests\//}"
9+
elif [[ "$CIRCLE_BRANCH" =~ ^tagged-release\/.* ]]; then
10+
# Remove tagged-release/
11+
export NPM_TAG="${CIRCLE_BRANCH/tagged-release\//}"
12+
fi
13+
if [ -z "$NPM_TAG" ]; then
14+
echo "Tag name is missing. Name your branch with either tagged-release/<tag-name> or tagged-release-without-e2e-tests/<tag-name>"
15+
exit 1
16+
fi
17+
echo "Publishing to NPM with tag $NPM_TAG"
18+
yarn publish:tag
19+
else
20+
yarn publish:$CIRCLE_BRANCH
21+
fi
22+
else
23+
echo "Skipping deploy."
24+
fi

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"production-build": "yarn && lerna run build --concurrency 3 --stream",
1414
"publish:master": "lerna publish --canary --exact --force-publish --preid=dev --dist-tag=dev --include-merged-tags --conventional-prerelease --yes",
1515
"publish:release": "lerna publish --exact --conventional-commits --message 'chore(release): Publish [ci skip]' --yes",
16-
"publish:dart-modelgen-null-safety": "lerna publish --canary --exact --force-publish --preid=flutter-preview --dist-tag=flutter-preview --include-merged-tags --conventional-prerelease --yes",
16+
"publish:tag": "lerna publish --exact --dist-tag=$NPM_TAG --preid=$NPM_TAG --conventional-commits --conventional-prerelease --message 'chore(release): Publish tagged release $NPM_TAG [ci skip]' --no-verify-access --yes",
1717
"postpublish:release": "git fetch . release:master && git push origin master",
1818
"yarn-use-bash": "yarn config set script-shell /bin/bash",
1919
"verdaccio-start": "yarn yarn-use-bash && source .circleci/local_publish_helpers.sh && startLocalRegistry \"$(pwd)/.circleci/verdaccio.yaml\"",

0 commit comments

Comments
 (0)