Skip to content

Commit ed92bc3

Browse files
authored
ci: Setup canary semantic release pipeline (#177)
* footer shows current version * prepare test publish * v2.0.0-alpha.2 * new package * setup lerna * move changelog * test semantic release * fix: semantic release setup * fix: circleci setup * test if no lockfile is ok * add missing plugin * ci(renovate): better automerge rules * chore: test the release
1 parent 22a6eb5 commit ed92bc3

File tree

22 files changed

+1727
-47
lines changed

22 files changed

+1727
-47
lines changed

.circleci/config.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ aliases:
77
- v4-dependencies-{{ .Branch }}-
88

99
- &install
10-
# --frozen-lockfile ensures the build will fail if the lockfile needs to be updated
11-
run: yarn --no-progress --frozen-lockfile
10+
run: yarn --no-progress
1211

1312
- &build
1413
run:
@@ -74,9 +73,9 @@ jobs:
7473
- *build
7574
- save-cache: *save-cache
7675
- add-ssh-keys:
77-
fingerprints:
78-
- "e1:ca:5d:f0:58:11:c7:ae:b7:ac:4a:1b:cc:3a:0d:4a"
79-
- run: yarn semantic-release || true
76+
fingerprints:
77+
- "e1:ca:5d:f0:58:11:c7:ae:b7:ac:4a:1b:cc:3a:0d:4a"
78+
- run: yarn semantic-release
8079

8180
# Workflows enables us to run multiple jobs in parallel
8281
workflows:
@@ -93,4 +92,6 @@ workflows:
9392
- Website
9493
filters:
9594
branches:
96-
only: master
95+
only:
96+
- master
97+
- semantic-release

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
This used to be just a [ponyfill](https://ponyfill.com) for `Element.scrollIntoViewIfNeeded` but is currently being rewritten to cover `Element.scrollIntoView(ScrollIntoViewOptions)` including the new `scrollMode: "if-needed"` option.
77
This readme will be updated when it's ready for stable release.
88

9-
## [Demo](https://scroll-into-view.netlify.com)
9+
## [Demo](https://scroll-into-view-if-needed.netlify.com)

lerna.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"lerna": "2.10.2",
3+
"npmClient": "yarn",
4+
"useWorkspaces": true,
5+
"version": "independent"
6+
}

package.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@
77
"scripts": {
88
"precommit": "lint-staged",
99
"predeploy:website": "cd packages/scroll-into-view-if-needed && yarn build",
10-
"deploy:website": "cd website && yarn deploy"
10+
"deploy:website": "cd website && yarn deploy",
11+
"publish:canary": "lerna publish --npm-tag=next --canary",
12+
"semantic-release": "lerna exec --concurrency 1 -- npx --no-install semantic-release -e semantic-release-monorepo"
1113
},
1214
"devDependencies": {
15+
"@semantic-release/git": "4.0.2",
1316
"husky": "0.14.3",
17+
"lerna": "2.10.2",
1418
"lint-staged": "7.0.4",
1519
"prettier": "1.12.1",
16-
"prettier-package-json": "1.5.1"
20+
"prettier-package-json": "1.5.1",
21+
"semantic-release": "15.1.7",
22+
"semantic-release-monorepo": "6.0.1"
1723
},
1824
"lint-staged": {
1925
"*.js": [
@@ -54,6 +60,18 @@
5460
}
5561
]
5662
},
63+
"release": {
64+
"branch": "semantic-release",
65+
"prepare": [
66+
"@semantic-release/npm",
67+
"@semantic-release/git"
68+
],
69+
"verifyConditions": [
70+
"@semantic-release/npm",
71+
"@semantic-release/git",
72+
"@semantic-release/github"
73+
]
74+
},
5775
"resolutions": {
5876
"@types/react": "*"
5977
}

packages/scroll-into-view-if-needed/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ es
33
typings
44
umd
55
/*.js
6-
!.babelrc.js
6+
!.babelrc.js
7+
!rollup.config.js
File renamed without changes.

packages/scroll-into-view-if-needed/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "git",
99
"url": "git+https://github.com/stipsan/scroll-into-view-if-needed.git"
1010
},
11-
"version": "2.0.0-dev",
11+
"version": "2.0.0-alpha.3",
1212
"main": "index.js",
1313
"files": [
1414
"auto.js",
@@ -68,6 +68,9 @@
6868
"smoothscroll",
6969
"typescript"
7070
],
71+
"publishConfig": {
72+
"tag": "next"
73+
},
7174
"browserify": {
7275
"transform": [
7376
"loose-envify"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const BABEL_ENV = process.env.BABEL_ENV
2+
const building = BABEL_ENV != undefined && BABEL_ENV !== 'cjs'
3+
4+
const plugins = []
5+
6+
if (process.env.NODE_ENV === 'production') {
7+
plugins.push('dev-expression')
8+
}
9+
10+
module.exports = {
11+
presets: [
12+
'@babel/preset-typescript',
13+
[
14+
'@babel/preset-env',
15+
{
16+
loose: true,
17+
modules: building ? false : 'commonjs',
18+
},
19+
],
20+
],
21+
plugins: plugins,
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dist
2+
es
3+
typings
4+
umd
5+
/*.js
6+
!.babelrc.js
7+
!rollup.config.js
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[![CircleCI Status](https://img.shields.io/circleci/project/github/stipsan/scroll-into-view-if-needed.svg?style=flat-square)](https://circleci.com/gh/stipsan/scroll-into-view-if-needed) [![npm stat](https://img.shields.io/npm/dm/scroll-into-view-if-needed.svg?style=flat-square)](https://npm-stat.com/charts.html?package=scroll-into-view-if-needed) [![npm version](https://img.shields.io/npm/v/scroll-into-view-if-needed.svg?style=flat-square)](https://www.npmjs.com/package/scroll-into-view-if-needed) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
2+
![scroll-into-view-if-needed](https://user-images.githubusercontent.com/81981/39098948-61a1e60a-4672-11e8-80a3-16f0e57e4b9d.png)
3+
4+
This is a [ponyfill](https://ponyfill.com) for smooth scrolling `scroll-into-view-if-needed`.
5+
6+
## [Demo](https://scroll-into-view-if-needed.netlify.com/)
7+
8+
## Install
9+
10+
```bash
11+
yarn add smooth-scroll-into-view-if-needed
12+
```
13+
14+
## Usage
15+
16+
```js
17+
import scrollIntoView from 'smooth-scroll-into-view-if-needed'
18+
const node = document.getElementById('hero')
19+
20+
// If all you want is for all your users to have stuff smooth scroll into view
21+
scrollIntoView(node, { behavior: 'smooth' })
22+
23+
// combine it with any of the other options
24+
scrollIntoView(node, {
25+
behavior: 'smooth',
26+
scrollMode: 'if-needed',
27+
block: 'nearest',
28+
inline: 'nearest',
29+
})
30+
31+
// It returns a promise that is resolved when the animation is finished
32+
const sequence = async () => {
33+
const slide = document.getElementById('slide-3')
34+
// First smooth scroll to hero
35+
await scrollIntoView(node, { behavior: 'smooth' })
36+
// Then we scroll to a slide in a slideshow
37+
return scrollIntoView(slide, { behavior: 'smooth' })
38+
}
39+
```
40+
41+
### Custom scrolling transition
42+
43+
If the default smooth scrolling ponyfill isn't the duration or easing you want, you can provide your own scrolling logic by giving `behavior` a callback.
44+
45+
```js
46+
import scrollIntoView from 'smooth-scroll-into-view-if-needed'
47+
const node = document.getElementById('hero')
48+
49+
scrollIntoView(node, {
50+
// Your scroll actions will always be an array, even if there is nothing to scroll
51+
behavior: scrollActions =>
52+
// list is sorted from innermost (closest parent to your target) to outermost (often the document.body or viewport)
53+
scrollActions.forEach(([el, scrollTop, scrollLeft]) => {
54+
// implement the scroll anyway you want
55+
el.scrollTop = scrollTop
56+
el.scrollLeft = scrollLeft
57+
58+
// If you need the relative scroll coordinates, for things like window.scrollBy style logic, just do the math
59+
const offsetTop = el.scrollTop - scrollTop
60+
const offsetLeft = el.scrollLeft - scrollLeft
61+
}),
62+
// all the other options (scrollMode, block, inline) still work, so you don't need to reimplement them (unless you really really want to)
63+
})
64+
```
65+
66+
## More documentation will be added (hang in there)

0 commit comments

Comments
 (0)