Skip to content

Commit 3c49e6b

Browse files
committed
Release from Dockerfile
1 parent 9c84853 commit 3c49e6b

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ WORKDIR /app
1616
COPY . .
1717
RUN npm run bootstrap
1818
RUN npm run build
19+
20+
# release
21+
FROM build AS release
22+
23+
ARG npm_token
24+
ENV NPM_TOKEN=${npm_token}
25+
26+
RUN echo //registry.npmjs.org/:_authToken=$NPM_TOKEN > .npmrc
27+
RUN npm run publish -- --yes

cloudbuild.release.yaml

+24-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
steps:
2-
- name: 'gcr.io/cloud-builders/npm'
3-
args: ['ci']
4-
- name: 'gcr.io/cloud-builders/npm'
5-
args: ['run-script', 'build']
6-
- name: 'gcr.io/cloud-builders/npm'
7-
entrypoint: 'bash'
8-
args:
9-
- '-c'
10-
- |
11-
if [[ "${TAG_NAME}" =~ ^release-prod-v[0-9]+$ ]]; then
12-
echo //registry.npmjs.org/:_authToken=$$NPM_TOKEN > .npmrc
13-
npm publish
14-
fi
15-
secretEnv: ['NPM_TOKEN']
2+
- name: 'gcr.io/cloud-builders/docker'
3+
entrypoint: 'bash'
4+
args:
5+
- '-c'
6+
- |
7+
docker pull gcr.io/${PROJECT_ID}/${_SVC_BASENAME}/base || true
8+
docker pull gcr.io/${PROJECT_ID}/${_SVC_BASENAME}/lint || true
9+
docker pull gcr.io/${PROJECT_ID}/${_SVC_BASENAME}/build || true
10+
- name: 'gcr.io/cloud-builders/docker'
11+
args: [
12+
'build',
13+
'--cache-from', 'gcr.io/${PROJECT_ID}/${_SVC_BASENAME}/base',
14+
'--cache-from', 'gcr.io/${PROJECT_ID}/${_SVC_BASENAME}/build',
15+
'--build-arg npm_token=$$NPM_TOKEN',
16+
'--target', 'release',
17+
'.'
18+
]
19+
secretEnv:
20+
- 'NPM_TOKEN'
21+
22+
substitutions:
23+
_SLACK_NOTIFY_CHANNEL: '#triple-web-dev'
24+
_SVC_BASENAME: triple-frontend
25+
_AUTO_TAGGING_ENABLED: 'false'
1626

1727
secrets:
1828
- kmsKeyName: projects/titicaca-ci/locations/global/keyRings/npm/cryptoKeys/publish_token

0 commit comments

Comments
 (0)