Skip to content

Release improvements #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 4, 2021
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions codebuild/release/prod-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: 0.2

env:
variables:
NODE_OPTIONS: "--max-old-space-size=4096"
BRANCH: "master"
secrets-manager:
OTP_SECRET_KEY: npm/aws-crypto-tools-ci-bot/2FA:OTP_SECRET_KEY
NPM_TOKEN: npm/aws-crypto-tools-ci-bot/2FA:NPM_TOKEN
git-credential-helper: yes

phases:
install:
commands:
- npm ci --unsafe-perm
# Install `otplib` to extract the OTP from the npm 2FA secret
- npm install otplib --no-save
- npm run build
runtime-versions:
nodejs: 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nodejs: 10
nodejs: 14

pre_build:
commands:
- git config --global user.name "aws-crypto-tools-ci-bot"
- git config --global user.email "[email protected]"
- git checkout $BRANCH
build:
commands:
# Pre-check, make sure everything is happy
- npm test
- npm run test_conditions
- npm run verdaccio
# Generate new version and CHANGELOG entry. Because we specify `--no-push` this
# does not yet push any changes to the remote
- npx lerna version --conventional-commits --git-remote origin --yes --no-push
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do want to push here

# Log the commit for posterity
- git log -n 1
# Publish to the local verdaccio server and run all tests
- npm run verdaccio-publish
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better tested at npm run verdaccio

# Extract the otp using the secrets environment variables from above.
# This will wait for the next token. This is because npm uses
# TOTP and the tokens time out after 30 seconds. If the process just
# extracted the token then the lifetime for this token
# would be very random. This will maximize the amount of time
# available on the OTP to publish.
- >-
OTP=`node -e "
auth=require('otplib').authenticator;
setTimeout(() =>
console.log(auth.generate(process.env.OTP_SECRET_KEY)),
auth.timeRemaining() * 1000);
"`
# Now we publish to npm.
# This is going to use the OTP generated above and the NPM_TOKEN
# environment variable. This will only publish things that are
# missing from npm. It is therefore safe to run repeatedly.
- npx lerna publish from-package --yes --otp $OTP
# Clear out the verdaccio cache so that we get the latest version
# of everything from public npm
- rm -rf verdaccio/storage/
# Since the cache is empty, and we don't call `verdaccio-publish`
# this will run the integrations from the public code in npm
- npx run-s verdaccio-publish-*


# Batching is technically unnecessary for now since we have just the one
# buildspec, but leaving it in place makes it easier to extend later on
batch:
fast-fail: true
build-graph:
- identifier: release_to_prod