Skip to content

Commit 7a68079

Browse files
committed
fix: setup improved semantic-release
1 parent b056e3e commit 7a68079

File tree

9 files changed

+26390
-6124
lines changed

9 files changed

+26390
-6124
lines changed

.circleci/config.yml

-19
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,6 @@ jobs:
9999
- tests/web-platform/node_modules
100100
key: v6-tests-web-platform-dependencies-{{ .Branch }}-{{ checksum "tests/web-platform/yarn.lock" }}
101101

102-
Semantic Release:
103-
docker:
104-
- image: circleci/node:12
105-
steps:
106-
- checkout
107-
- restore-cache: *restore-cache
108-
- *install
109-
- run: npx semantic-release
110-
111102
# Workflows enables us to run multiple jobs in parallel
112103
workflows:
113104
version: 2
@@ -117,13 +108,3 @@ workflows:
117108
- Build
118109
- Web Platform Tests
119110
- Browserstack
120-
- Semantic Release:
121-
requires:
122-
- Typecheck
123-
- Build
124-
- Web Platform Tests
125-
- Browserstack
126-
filters:
127-
branches:
128-
only:
129-
- master

.github/workflows/ci.yml

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
name: CI & Release
3+
4+
# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
5+
run-name: >-
6+
${{
7+
inputs.release && inputs.test && 'Build ➤ Test ➤ Publish to NPM' ||
8+
inputs.release && !inputs.test && 'Build ➤ Skip Tests ➤ Publish to NPM' ||
9+
github.event_name == 'workflow_dispatch' && inputs.test && 'Build ➤ Test' ||
10+
github.event_name == 'workflow_dispatch' && !inputs.test && 'Build ➤ Skip Tests' ||
11+
''
12+
}}
13+
14+
on:
15+
pull_request:
16+
push:
17+
branches: [main]
18+
workflow_dispatch:
19+
inputs:
20+
test:
21+
description: 'Run tests'
22+
required: true
23+
default: true
24+
type: boolean
25+
release:
26+
description: 'Publish new release'
27+
required: true
28+
default: false
29+
type: boolean
30+
31+
concurrency:
32+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
33+
cancel-in-progress: true
34+
35+
jobs:
36+
build:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
40+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
41+
with:
42+
cache: npm
43+
node-version: lts/*
44+
- run: npm ci
45+
- run: npm run typecheck
46+
if: github.event.inputs.test != 'false'
47+
- run: npm run lint
48+
if: github.event.inputs.test != 'false'
49+
- run: npm run prepublishOnly
50+
51+
test:
52+
needs: build
53+
if: github.event.inputs.test != 'false'
54+
runs-on: ${{ matrix.os }}
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
os: [macos-latest, ubuntu-latest, windows-latest]
59+
node: [lts/*]
60+
include:
61+
- os: ubuntu-latest
62+
node: lts/-2
63+
- os: ubuntu-latest
64+
node: current
65+
steps:
66+
- name: Set git to use LF
67+
if: matrix.os == 'windows-latest'
68+
run: |
69+
git config --global core.autocrlf false
70+
git config --global core.eol lf
71+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
72+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
73+
with:
74+
cache: npm
75+
node-version: ${{ matrix.node }}
76+
- run: npm i
77+
- run: npm run build
78+
# - run: npm test
79+
80+
release:
81+
needs: [build, test]
82+
# only run if opt-in during workflow_dispatch
83+
if: always() && github.event.inputs.release == 'true' && needs.build.result != 'failure' && needs.test.result != 'failure' && needs.test.result != 'cancelled'
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
87+
with:
88+
# Need to fetch entire commit history to
89+
# analyze every commit since last release
90+
fetch-depth: 0
91+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
92+
with:
93+
cache: npm
94+
node-version: lts/*
95+
- run: npm ci
96+
# Branches that will release new versions are defined in .releaserc.json
97+
- run: npx semantic-release
98+
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
99+
# e.g. git tags were pushed but it exited before `npm publish`
100+
if: always()
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
104+
# Re-run semantic release with rich logs if it failed to publish for easier debugging
105+
- run: npx semantic-release --dry-run --debug
106+
if: failure()
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

.github/workflows/prettier.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Prettier
3+
4+
on:
5+
push:
6+
branches: [main]
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
run:
15+
name: 🤔
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
19+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3
20+
with:
21+
cache: npm
22+
node-version: lts/*
23+
- run: npm ci --ignore-scripts --only-dev
24+
- uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3
25+
with:
26+
path: node_modules/.cache/prettier/.prettier-cache
27+
key: prettier-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.gitignore') }}
28+
- name: check if workflows needs prettier
29+
run: npx prettier --cache --check ".github/workflows/**/*.yml" || (echo "An action can't make changes to actions, you'll have to run prettier manually" && exit 1)
30+
- run: npx prettier --ignore-path .gitignore --cache --write .
31+
- uses: EndBug/add-and-commit@61a88be553afe4206585b31aa72387c64295d08b # tag=v9
32+
with:
33+
default_author: github_actions
34+
commit: --no-verify
35+
message: 'chore(prettier): 🤖 ✨'

.releaserc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "@sanity/semantic-release-preset",
3+
"branches": ["main"]
4+
}

CHANGELOG.md

+21-29
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
# Changelog
2-
3-
All notable changes to this project will be documented in this file.
4-
5-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6-
and this project adheres to
7-
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).
8-
9-
## [Unreleased]
1+
## [1.6.0]
102

113
### Added
124

@@ -16,7 +8,7 @@ and this project adheres to
168
### Removed
179

1810
- `centerIfNeeded`, use `scrollMode: "if-needed", block: "center"` instead.
19-
- `duration` to trigger animation, use [`smooth-scroll-into-view-if-needed`](https://github.com/stipsan/smooth-scroll-into-view-if-needed) instead.
11+
- `duration` to trigger animation, use [`smooth-scroll-into-view-if-needed`](https://github.com/scroll-into-view/smooth-scroll-into-view-if-needed) instead.
2012
- `handleScroll(parent, {scrollLeft, scrollTop}, options)`, use `behavior: function(actions)` instead, where `actions` is an array of `{el, top, left}` allowing you to scroll everything in parallel or in a sequence, it's up to you.
2113
- `offset`, use wrapper elements and CSS like padding or margins instead.
2214

@@ -175,22 +167,22 @@ and this project adheres to
175167

176168
- Initial release.
177169

178-
[unreleased]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.5.0...HEAD
179-
[1.5.0]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.4.0...v1.5.0
180-
[1.4.0]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.3.0...v1.4.0
181-
[1.3.0]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.2.8...v1.3.0
182-
[1.2.8]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.2.7...v1.2.8
183-
[1.2.7]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.2.6...v1.2.7
184-
[1.2.6]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.2.5...v1.2.6
185-
[1.2.5]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.2.4...v1.2.5
186-
[1.2.4]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.2.3...v1.2.4
187-
[1.2.3]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.2.2...v1.2.3
188-
[1.2.2]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.2.1...v1.2.2
189-
[1.2.1]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.2.0...v1.2.1
190-
[1.2.0]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.1.1...v1.2.0
191-
[1.1.1]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.1.0...v1.1.1
192-
[1.1.0]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.0.7...v1.1.0
193-
[1.0.7]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.0.6...v1.0.7
194-
[1.0.6]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.0.5...v1.0.6
195-
[1.0.5]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.0.4...v1.0.5
196-
[1.0.4]: https://github.com/stipsan/scroll-into-view-if-needed/compare/v1.0.3...v1.0.4
170+
[unreleased]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.5.0...HEAD
171+
[1.5.0]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.4.0...v1.5.0
172+
[1.4.0]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.3.0...v1.4.0
173+
[1.3.0]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.2.8...v1.3.0
174+
[1.2.8]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.2.7...v1.2.8
175+
[1.2.7]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.2.6...v1.2.7
176+
[1.2.6]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.2.5...v1.2.6
177+
[1.2.5]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.2.4...v1.2.5
178+
[1.2.4]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.2.3...v1.2.4
179+
[1.2.3]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.2.2...v1.2.3
180+
[1.2.2]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.2.1...v1.2.2
181+
[1.2.1]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.2.0...v1.2.1
182+
[1.2.0]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.1.1...v1.2.0
183+
[1.1.1]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.1.0...v1.1.1
184+
[1.1.0]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.0.7...v1.1.0
185+
[1.0.7]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.0.6...v1.0.7
186+
[1.0.6]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.0.5...v1.0.6
187+
[1.0.5]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.0.4...v1.0.5
188+
[1.0.4]: https://github.com/scroll-into-view/scroll-into-view-if-needed/compare/v1.0.3...v1.0.4

README.md

+19-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
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)
21
[![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)
32
[![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)
43
[![gzip size][gzip-badge]][unpkg-dist]
@@ -12,12 +11,12 @@
1211
This used to be a [ponyfill](https://ponyfill.com) for
1312
`Element.scrollIntoViewIfNeeded`. Since then the CSS working group have decided to implement its features in `Element.scrollIntoView` as the option `scrollMode: "if-needed"`. Thus this library got rewritten to implement that spec instead of the soon to be deprecated one.
1413

15-
## [Demo](https://scroll-into-view-if-needed.netlify.com)
14+
## [Demo](https://scroll-into-view.dev)
1615

1716
## Install
1817

1918
```bash
20-
yarn add scroll-into-view-if-needed
19+
npm i scroll-into-view-if-needed
2120
```
2221

2322
The UMD build is also available on [unpkg](https://unpkg.com/scroll-into-view-if-needed/umd/):
@@ -60,7 +59,7 @@ scrollIntoView(node, { behavior: 'smooth', scrollMode: 'if-needed' })
6059

6160
### Ponyfill smooth scrolling
6261

63-
What does ponyfilling smooth scrolling mean, and why is it implemented in [`smooth-scroll-into-view-if-needed`](https://github.com/stipsan/smooth-scroll-into-view-if-needed) instead?
62+
What does ponyfilling smooth scrolling mean, and why is it implemented in [`smooth-scroll-into-view-if-needed`](https://github.com/scroll-into-view/smooth-scroll-into-view-if-needed) instead?
6463
The answer is bundlesize. If this package adds smooth scrolling to browsers that's missing it then the overall bundlesize increases regardless of wether you use this feature or not.
6564

6665
Put it this way:
@@ -88,7 +87,7 @@ scrollIntoView(node, { behavior: 'smooth' })
8887

8988
##### Consistency
9089

91-
If a consistent smooth scrolling experience is a priority and you really don't want any surprises between different browsers and enviroments. In other words don't want to be affected by how a vendor might implement native smooth scrolling, then [`smooth-scroll-into-view-if-needed`](https://github.com/stipsan/smooth-scroll-into-view-if-needed) is your best option. It ensures the same smooth scrolling experience for every browser.
90+
If a consistent smooth scrolling experience is a priority and you really don't want any surprises between different browsers and enviroments. In other words don't want to be affected by how a vendor might implement native smooth scrolling, then [`smooth-scroll-into-view-if-needed`](https://github.com/scroll-into-view/smooth-scroll-into-view-if-needed) is your best option. It ensures the same smooth scrolling experience for every browser.
9291

9392
```js
9493
import smoothScrollIntoView from 'smooth-scroll-into-view-if-needed'
@@ -163,15 +162,15 @@ Using `behavior: 'smooth'` is the easiest way to smooth scroll an element as it
163162
When given a function then this library will only calculate what should be scrolled and leave it up to you to perform the actual scrolling.
164163

165164
The callback is given an array over actions. Each action contain a reference to an element that should be scrolled, with its top and left scrolling coordinates.
166-
What you return is passed through, allowing you to implement a Promise interface if you want to (check [`smooth-scroll-into-view-if-needed`](https://github.com/stipsan/smooth-scroll-into-view-if-needed) to see an example of that).
165+
What you return is passed through, allowing you to implement a Promise interface if you want to (check [`smooth-scroll-into-view-if-needed`](https://github.com/scroll-into-view/smooth-scroll-into-view-if-needed) to see an example of that).
167166

168167
```js
169168
import scrollIntoView from 'scroll-into-view-if-needed'
170169
const node = document.getElementById('hero')
171170

172171
scrollIntoView(node, {
173172
// Your scroll actions will always be an array, even if there is nothing to scroll
174-
behavior: actions =>
173+
behavior: (actions) =>
175174
// list is sorted from innermost (closest parent to your target) to outermost (often the document.body or viewport)
176175
actions.forEach(({ el, top, left }) => {
177176
// implement the scroll anyway you want
@@ -186,49 +185,49 @@ scrollIntoView(node, {
186185
})
187186
```
188187

189-
Check the demo to see an [example with popmotion and a spring transition](https://scroll-into-view-if-needed.netlify.com/#custom-transition).
188+
Check the demo to see an [example with popmotion and a spring transition](https://scroll-into-view.dev/#custom-transition).
190189

191-
> If you only need the custom behavior you might be better off by using the compute library directly: https://github.com/stipsan/compute-scroll-into-view
190+
> If you only need the custom behavior you might be better off by using the compute library directly: https://github.com/scroll-into-view/compute-scroll-into-view
192191
193-
#### [block](https://scroll-into-view-if-needed.netlify.com/#scroll-alignment)
192+
#### [block](https://scroll-into-view.dev/#scroll-alignment)
194193

195194
Type: `'start' | 'center' | 'end' | 'nearest'`<br> Default: `'center'`
196195

197196
> Introduced in `v2.1.0`
198197
199-
[More info.](https://github.com/stipsan/compute-scroll-into-view#block)
198+
[More info.](https://github.com/scroll-into-view/compute-scroll-into-view#block)
200199

201-
#### [inline](https://scroll-into-view-if-needed.netlify.com/#scroll-alignment)
200+
#### [inline](https://scroll-into-view.dev/#scroll-alignment)
202201

203202
Type: `'start' | 'center' | 'end' | 'nearest'`<br> Default: `'nearest'`
204203

205204
> Introduced in `v2.1.0`
206205
207-
[More info.](https://github.com/stipsan/compute-scroll-into-view#inline)
206+
[More info.](https://github.com/scroll-into-view/compute-scroll-into-view#inline)
208207

209-
#### [scrollMode](https://scroll-into-view-if-needed.netlify.com/#scrolling-if-needed)
208+
#### [scrollMode](https://scroll-into-view.dev/#scrolling-if-needed)
210209

211210
Type: `'always' | 'if-needed'`<br> Default: `'always'`
212211

213212
> Introduced in `v2.1.0`
214213
215-
[More info.](https://github.com/stipsan/compute-scroll-into-view#scrollmode)
214+
[More info.](https://github.com/scroll-into-view/compute-scroll-into-view#scrollmode)
216215

217-
#### [boundary](https://scroll-into-view-if-needed.netlify.com/#limit-propagation)
216+
#### [boundary](https://scroll-into-view.dev/#limit-propagation)
218217

219218
Type: `Element | Function`
220219

221220
> `Function` introduced in `v2.1.0`, `Element` introduced in `v1.1.0`
222221
223-
[More info.](https://github.com/stipsan/compute-scroll-into-view#boundary)
222+
[More info.](https://github.com/scroll-into-view/compute-scroll-into-view#boundary)
224223

225224
#### skipOverflowHiddenElements
226225

227226
Type: `Boolean`<br> Default: `false`
228227

229228
> Introduced in `v2.2.0`
230229
231-
[More info.](https://github.com/stipsan/compute-scroll-into-view#skipoverflowhiddenelements)
230+
[More info.](https://github.com/scroll-into-view/compute-scroll-into-view#skipoverflowhiddenelements)
232231

233232
# TypeScript support
234233

@@ -390,7 +389,7 @@ This API signature were warned to be dropped in `v2.0.0`, and it was.
390389
- [smooth-scroll-into-view-if-needed](https://www.npmjs.com/package/smooth-scroll-into-view-if-needed) – ponyfills smooth scrolling.
391390
- [react-scroll-into-view-if-needed](https://www.npmjs.com/package/react-scroll-into-view-if-needed) – A thin wrapper to scroll your component into view.
392391
- [scroll-polyfill](https://www.npmjs.com/package/scroll-polyfill) – polyfills smooth scrolling.
393-
- [Don't be shy, add yours!](https://github.com/stipsan/scroll-into-view-if-needed/edit/master/README.md)
392+
- [Don't be shy, add yours!](https://github.com/scroll-into-view/scroll-into-view-if-needed/edit/main/README.md)
394393

395394
# Who's using this
396395

@@ -402,7 +401,7 @@ This API signature were warned to be dropped in `v2.0.0`, and it was.
402401
A design system and React component library for the web that lets you quickly build high-quality, accessible apps.
403402
- [Covalent](https://github.com/Teradata/covalent) – Teradata UI Platform built on Angular Material.
404403
- [docs.expo.io](https://github.com/expo/expo-docs) – Documentation for Expo, its SDK, client and services.
405-
- [Add yourself to the list 😉](https://github.com/stipsan/scroll-into-view-if-needed/edit/master/README.md)
404+
- [Add yourself to the list 😉](https://github.com/scroll-into-view/scroll-into-view-if-needed/edit/main/README.md)
406405

407406
[gzip-badge]: http://img.badgesize.io/https://unpkg.com/scroll-into-view-if-needed/umd/scroll-into-view-if-needed.min.js?compression=gzip&label=gzip%20size&style=flat-square
408407
[size-badge]: http://img.badgesize.io/https://unpkg.com/scroll-into-view-if-needed/umd/scroll-into-view-if-needed.min.js?label=size&style=flat-square

0 commit comments

Comments
 (0)