How do you guys handle CI versioning and deployment to multiple environments? (create-react-app, gitlab, AWS Lambda)
At work, we have a create-react-app project which we deploy built static files on a s3 instance. It then calls our APIs/Lambda functions and does stuff.
We have two environments, dev (staging) and prod.
Here's how I have the CI for the frontend set up:
- do dev work until it's time for next deployment
- update package.json version and CHANGELOG.md
- push to master
- create tag locally with shell script that checks if package.json version and CHANGELOG.md is up to date and in sync
- push tag to remote
- gitlab CI detects semver formatted tag, and triggers build process
- if there is a -beta suffix in the tag name, it deploys to staging, otherwise deploy to prod
One thing i feel there is room for improvement: branches. We are not utilizing branches fully, usually it's just one branch per development cycle, sometimes a feature, but mostly it's just me pushing to master straightaway (as I'm the main person working on this project)
I feel that having to add a -beta suffix to the tag all the time for frequent deployments to our dev/staging environment is a little out of place, but it feels better than having to do it the other way round and add something like a -release suffix to the ones deployed to prod.
Should each tag be a distinct build version (1.0.1 vs 1.0.1-beta)? If so, I would then have a clean list of tags for each version, but I would then lose the ability to push to different environment via tag name.
Is there a better way of managing tags and the environment those certain versions are deployed to?
Is there something inherently wrong about the direction I'm heading?
Posted Aug 16, 2018, 10:49 AM UTC
I don't think there is anything entirely wrong with your way of managing build versioning as long as you have a need for it.
An alternative would be using branches to identify deploys.
For example, pushing to "master" would deploy to your staging env and pushing to "production" would deploy to your prod env.