Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Add release.sh: automated releases! #1308

Open
wants to merge 11 commits into
base: publisher-production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
40 changes: 0 additions & 40 deletions DEPLOYING.md

This file was deleted.

66 changes: 66 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Creating a release of mapbox.js

The majority of the release process is done on a release branch. Once all the artifacts are built and published, you will need to get your release reviewed and approved. Once approved the release branch is ready to be merged into the default `publisher-production` branch. After being merged the release can be tagged and Github release created.

Checklist:
- [ ] Make sure the changelog has been updated
- [ ] Do the release (part 1) in a release branch (using manual or automated process below)
- [ ] Create release PR and get it reviewed and approved
- [ ] Merge release branch into `publisher-production`
- [ ] Finalize the release (part 2)

> Replace any instance of <MAJOR.MINOR.PATCH> with your version

## Part 1:
- This part of the release is done on a release branch
- This part of the relase will:
- version bump
- cdn publish
- npm publish
- generate docs pages

### Option A: Automated release

```terminal
$ npm run release <MAJOR.MINOR.PATCH>
```

### Option B: Manual release

```terminal
# Bump version
$ npm version --no-git-tag-version <MAJOR.MINOR.PATCH>
$ git add package*.json
$ git commit -m "Update package*.json: <MAJOR.MINOR.PATCH>"

# Publish to NPM
$ npm login
$ npm publish

# Publish to Mapbox CDN
$ ./deploy.sh v<MAJOR.MINOR.PATCH>

# Generate docs pages
$ ./deploy.sh v<MAJOR.MINOR.PATCH>

# Update mapboxjs version in `_config.yaml`, `_config.publisher-production.yml`, `_config.publisher-staging.yml`
$ find . -name '_config*.yml' -exec sed -i '' "s/^\\(\\s*mapboxjs\\s*:\\s*\\).*/\\1 <MAJOR.MINOR.PATCH>/" {} \;

# Commit configs and docs.
$ git add _config*.yml docs/*
$ git commit -m "Update docs/*: <MAJOR.MINOR.PATCH>"
```

## Part 2:
- This part of the release is done on the publisher-production
- This part of the release will:
- git tag
- create Github release

```terminal
$ git checkout publisher-production
$ git pull origin publisher-production
$ git tag -a v<MAJOR.MINOR.PATCH> -m <MAJOR.MINOR.PATCH> release
$ git push origin "$tag" --tags
# login to Github and create release
```
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"scripts": {
"test": "eslint src && phantomjs node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index.html",
"prepublishOnly": "npm run build",
"build": "make"
"build": "make",
"release": "./release.sh"
},
"license": "BSD-3-Clause",
"devDependencies": {
Expand Down
67 changes: 67 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

set -e

version="$1"
tag="v${version}"

if [[ -z $version ]]; then
echo "First order argument of version required. i.e. ./bump 3.2.0"
fi

if [[ $(git status --porcelain) ]]; then
echo "You cannot have any local changes to run release. Stash or commmit and rerun."
exit 1
fi

echo "Have you updated and commited the CHANGELOG? (y/n)"
read -r changelog_updated

if [[ "$changelog_updated" != "y" ]]; then
echo "Update the changelog and commit then run release again."
exit 1
fi

echo "Creating release branch ${tag}."
git checkout -b "$tag"

echo "Bumping version in package.json and package-lock.json, tagging, comiting and pushing to remote"
npm version --no-git-tag-version "$version"
$ git add package*.json
$ git commit -m "Update package*.json: <MAJOR.MINOR.PATCH>"
git push origin "$tag"

echo "Do you want to publish NPM? (y/n)"
read -r should_publish_npm

if [[ "$should_publish_npm" == "y" ]]; then
npm login
npm publish
fi

echo "Do you want to publish to the Mapbox CDN? (y/n)"
read -r should_publish_cdn

if [[ "$should_publish_cdn" == "y" ]]; then
make
./deploy.sh "$tag"
fi

echo "Do you want to update and commit the documentation pages? (y/n)"
read -r should_update_documentation

if [[ "$should_update_documentation" == "y" ]]; then
echo "Building docs"
./_docs/build.sh "$tag"

echo "Bumping version in publishers _config files"
find . -name '_config*.yml' -exec sed -i '' "s/^\\(\\s*mapboxjs\\s*:\\s*\\).*/\\1 ${version}/" {} \;

echo "Commiting publisher _config files"
git add _config*.yml docs/*
git commit -m "Update docs: ${tag}"

echo "Bumping version in package.json and package-lock.json, commiting and tagging"
npm version "$version"
git push origin "$tag"
fi