Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit 59aa760

Browse files
dhayabsarahdayan
andauthored
chore(release): migrate to shipjs (#573)
Co-authored-by: Sarah Dayan <[email protected]>
1 parent 618d30a commit 59aa760

File tree

7 files changed

+762
-1181
lines changed

7 files changed

+762
-1181
lines changed

.circleci/config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ jobs:
154154
template: 'Vue InstantSearch with Vue 3'
155155
app: 'vue-instantsearch-vue3'
156156

157+
release_if_needed:
158+
<<: *defaults
159+
steps:
160+
- checkout
161+
- run: *install_yarn_version
162+
- restore_cache: *restore_yarn_cache
163+
- run: *run_yarn_install
164+
- save_cache: *save_yarn_cache
165+
- run:
166+
name: Trigger a release if the latest commit is a release commit
167+
command: yarn shipjs trigger
168+
157169
workflows:
158170
version: 2.1
159171
ci:
@@ -163,3 +175,8 @@ workflows:
163175
- test_e2e
164176
- test_apps_node_14
165177
- test_apps_node_16
178+
- release_if_needed:
179+
filters:
180+
branches:
181+
only:
182+
- master

.release-it.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -98,32 +98,17 @@ You will need to follow these steps:
9898

9999
We will then review your pull request!
100100

101-
### Releasing
101+
### Release
102102

103-
We rely on [release-it](https://github.com/webpro/release-it) to release new versions of Create InstantSearch App.
103+
We rely on [Ship.js](https://github.com/algolia/shipjs) to release new versions of Create InstantSearch App.
104104

105-
#### Release flow
105+
You need to have `GITHUB_TOKEN` added to your `.env` file. You can create a [personal access token](https://github.com/settings/tokens).
106106

107-
1. Bump the project version in [`package.json`](package.json) based on [the commits](#conventions)
108-
1. Generate the changelog
109-
1. Commit the new release
110-
1. Create the new release tag
111-
1. Push to GitHub
112-
1. Create the new release on GitHub
113-
1. Publish to npm
114-
1. Push the generated templates to the [`templates`](https://github.com/algolia/create-instantsearch-app/tree/templates) branch (usable on CodeSandbox)
115-
116-
#### Release steps
117-
118-
To release a new version of the package, you need to:
107+
```sh
108+
yarn release
109+
```
119110

120-
1. [Generate a new GitHub token](https://github.com/settings/tokens/new) with the scope `repo` (necessary for creating GitHub releases)
121-
1. Store this token in an [environment variable](https://en.wikipedia.org/wiki/Environment_variable) called `GITHUB_TOKEN_CISA`
122-
1. Make sure you're on the `master` branch
123-
1. Run commands (_do not_ use `yarn` for releasing):
124-
- `npm run release:beta` for a new beta version
125-
- `npm run release` for a new stable version
126-
1. Follow the command-line instructions
111+
It will create a pull request for the next release. When it's reviewed, approved and merged, CircleCI will automatically publish it to npm.
127112

128113
### Updating templates on CodeSandbox
129114

package.json

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
"version": "6.0.0",
44
"license": "MIT",
55
"description": "⚡️ Build InstantSearch apps at the speed of thought",
6-
"keywords": [
7-
"algolia",
8-
"instantsearch"
9-
],
6+
"keywords": ["algolia", "instantsearch"],
107
"repository": "algolia/create-instantsearch-app",
118
"author": "Algolia <[email protected]>",
129
"main": "index.js",
@@ -25,13 +22,9 @@
2522
"doctoc": "doctoc --maxlevel 3 README.md CONTRIBUTING.md docs/",
2623
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
2724
"release-templates": "node ./scripts/release-templates",
28-
"release": "release-it",
29-
"release:beta": "release-it --preRelease=beta"
25+
"release": "shipjs prepare"
3026
},
31-
"files": [
32-
"index.js",
33-
"src"
34-
],
27+
"files": ["index.js", "src"],
3528
"engines": {
3629
"node": ">= 10"
3730
},
@@ -67,7 +60,7 @@
6760
"eslint-plugin-prettier": "3.1.2",
6861
"jest": "25.1.0",
6962
"jest-image-snapshot": "2.12.0",
70-
"release-it": "10.4.5",
63+
"shipjs": "0.24.4",
7164
"walk-sync": "2.0.2"
7265
}
7366
}

scripts/release-templates.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,17 @@ async function build() {
124124

125125
execSync(`git commit -m "${commitMessage}"`);
126126

127+
// Use the `origin-with-token` remote if it exists (when run with Ship.js)
128+
const origin = execSync(
129+
`git remote | grep origin-with-token || echo origin`
130+
)
131+
.toString()
132+
.trim();
133+
127134
// Push the new demos to the `templates` branch
128135
console.log();
129136
console.log(`▶︎ Pushing to branch "${chalk.green(TEMPLATES_BRANCH)}"`);
130-
execSync(`git push origin ${TEMPLATES_BRANCH}`);
137+
execSync(`git push ${origin} ${TEMPLATES_BRANCH}`);
131138

132139
console.log();
133140
console.log(

ship.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
shouldPrepare: ({ releaseType, commitNumbersPerType }) => {
3+
const { fix = 0 } = commitNumbersPerType;
4+
if (releaseType === 'patch' && fix === 0) {
5+
return false;
6+
}
7+
return true;
8+
},
9+
buildCommand: () => null,
10+
afterPublish: ({ exec }) => exec('yarn run release-templates'),
11+
};

0 commit comments

Comments
 (0)