Skip to content

Commit

Permalink
Introduce changesets for CHANGELOG auto-generation (#6274)
Browse files Browse the repository at this point in the history
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
  • Loading branch information
JounQin and ybiquitous committed Aug 18, 2022
1 parent 7d9af51 commit aff9a8e
Show file tree
Hide file tree
Showing 19 changed files with 8,692 additions and 5,582 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
5 changes: 5 additions & 0 deletions .changeset/calm-tables-hide.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `selector-pseudo-class-allowed-list` end positions and message ([#6262](https://github.com/stylelint/stylelint/pull/6262))
96 changes: 96 additions & 0 deletions .changeset/changelog-stylelint.js
@@ -0,0 +1,96 @@
// @ts-check

// based on https://github.com/changesets/changesets/blob/main/packages/changelog-github/src/index.ts

const { getInfo, getInfoFromPullRequest } = require('@changesets/get-github-info');

/**
* @type {import('@changesets/types').ChangelogFunctions}
*/
const changelogFunctions = {
async getReleaseLine(changeset, _type, options) {
if (!options || !options.repo) {
throw new Error(
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]',
);
}

/**
* @type {number | undefined}
*/
let prFromSummary;
/**
* @type {string | undefined}
*/
let commitFromSummary;
/**
* @type {string[]}
*/
let usersFromSummary = [];

const replacedChangelog = changeset.summary
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
let num = Number(pr);
if (!isNaN(num)) prFromSummary = num;
return '';
})
.replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
commitFromSummary = commit;
return '';
})
.replace(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => {
usersFromSummary.push(user);
return '';
})
.trim();

const [firstLine, ...futureLines] = replacedChangelog.split('\n').map((l) => l.trimEnd());

const links = await (async () => {
if (prFromSummary !== undefined) {
let { links } = await getInfoFromPullRequest({
repo: options.repo,
pull: prFromSummary,
});
if (commitFromSummary) {
links = {
...links,
commit: `[\`${commitFromSummary}\`](https://github.com/${options.repo}/commit/${commitFromSummary})`,
};
}
return links;
}
const commitToFetchFrom = commitFromSummary || changeset.commit;
if (commitToFetchFrom) {
let { links } = await getInfo({
repo: options.repo,
commit: commitToFetchFrom,
});
return links;
}
return {
commit: null,
pull: null,
user: null,
};
})();

const users = usersFromSummary.length
? usersFromSummary
.map((userFromSummary) => `[@${userFromSummary}](https://github.com/${userFromSummary})`)
.join(', ')
: links.user;

const suffix = [
links.pull === null ? '' : ` (${links.pull})`,
users === null ? '' : ` (${users})`,
].join('');

return `\n\n- ${firstLine}${futureLines.map((l) => ` ${l}`).join('\n')}${suffix}.\n`;
},
async getDependencyReleaseLine() {
return '';
},
};

module.exports = changelogFunctions;
5 changes: 5 additions & 0 deletions .changeset/chatty-eagles-act.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `selector-no-vendor-prefix` end positions ([#6261](https://github.com/stylelint/stylelint/pull/6261))
5 changes: 5 additions & 0 deletions .changeset/cold-peas-push.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `shorthand-property-no-redundant-values` message ([#6272](https://github.com/stylelint/stylelint/pull/6272))
15 changes: 15 additions & 0 deletions .changeset/config.json
@@ -0,0 +1,15 @@
{
"$schema": "https://unpkg.com/@changesets/config/schema.json",
"changelog": [
"./changelog-stylelint",
{
"repo": "stylelint/stylelint"
}
],
"commit": false,
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/cool-baboons-cross.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `selector-pseudo-element-disallowed-list` end positions and message ([#6270](https://github.com/stylelint/stylelint/pull/6270))
5 changes: 5 additions & 0 deletions .changeset/empty-humans-bake.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `selector-pseudo-element-allowed-list` end positions and message ([#6270](https://github.com/stylelint/stylelint/pull/6270))
5 changes: 5 additions & 0 deletions .changeset/modern-mayflies-scream.md
@@ -0,0 +1,5 @@
---
"stylelint": minor
---

Added: `ignoreAfterCombinators: []` to `selector-max-universal` ([#6275](https://github.com/stylelint/stylelint/pull/6275))
5 changes: 5 additions & 0 deletions .changeset/modern-plants-nail.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `time-min-milliseconds` end positions ([#6273](https://github.com/stylelint/stylelint/pull/6273))
5 changes: 5 additions & 0 deletions .changeset/plenty-timers-learn.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `keyframes-name-pattern` false positives for interpolation ([#6265](https://github.com/stylelint/stylelint/pull/6265))
5 changes: 5 additions & 0 deletions .changeset/serious-teachers-juggle.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `selector-nested-pattern` end positions ([#6259](https://github.com/stylelint/stylelint/pull/6259))
5 changes: 5 additions & 0 deletions .changeset/shy-clouds-joke.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `selector-no-qualifying-type` message, positions, and false positives ([#6260](https://github.com/stylelint/stylelint/pull/6260))
5 changes: 5 additions & 0 deletions .changeset/sour-socks-type.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `createPlugin` type definition ([#6264](https://github.com/stylelint/stylelint/pull/6264))
5 changes: 5 additions & 0 deletions .changeset/wise-kiwis-repeat.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `selector-pseudo-class-disallowed-list` end positions and message ([#6263](https://github.com/stylelint/stylelint/pull/6263))
44 changes: 44 additions & 0 deletions .github/workflows/releasing.yml
@@ -0,0 +1,44 @@
name: Release

on:
push:
branches:
- main

permissions:
contents: read
issues: write
pull-requests: write

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Set up Node.js LTS
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: npm

- name: Install latest npm
run: npm install --global npm@latest

- name: Install dependencies
run: npm ci

- name: Create release pull request
uses: changesets/action@v1
with:
commit: 'Prepare release'
title: 'Prepare release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 0 additions & 17 deletions CHANGELOG.md
@@ -1,22 +1,5 @@
# Changelog

All notable changes to this project are documented in this file.

## Head

- Added: `ignoreAfterCombinators: []` to `selector-max-universal` ([#6275](https://github.com/stylelint/stylelint/pull/6275)).
- Fixed: `createPlugin` type definition ([#6264](https://github.com/stylelint/stylelint/pull/6264)).
- Fixed: `keyframes-name-pattern` false positives for interpolation ([#6265](https://github.com/stylelint/stylelint/pull/6265)).
- Fixed: `selector-nested-pattern` end positions ([#6259](https://github.com/stylelint/stylelint/pull/6259)).
- Fixed: `selector-no-qualifying-type` message, positions, and false positives ([#6260](https://github.com/stylelint/stylelint/pull/6260)).
- Fixed: `selector-no-vendor-prefix` end positions ([#6261](https://github.com/stylelint/stylelint/pull/6261)).
- Fixed: `selector-pseudo-class-allowed-list` end positions and message ([#6262](https://github.com/stylelint/stylelint/pull/6262)).
- Fixed: `selector-pseudo-class-disallowed-list` end positions and message ([#6263](https://github.com/stylelint/stylelint/pull/6263)).
- Fixed: `selector-pseudo-element-allowed-list` end positions and message ([#6270](https://github.com/stylelint/stylelint/pull/6270)).
- Fixed: `selector-pseudo-element-disallowed-list` end positions and message ([#6270](https://github.com/stylelint/stylelint/pull/6270)).
- Fixed: `shorthand-property-no-redundant-values` message ([#6272](https://github.com/stylelint/stylelint/pull/6272)).
- Fixed: `time-min-milliseconds` end positions ([#6273](https://github.com/stylelint/stylelint/pull/6273)).

## 14.10.0

- Added: rule metadata to public `LinterResult` API ([#6166](https://github.com/stylelint/stylelint/pull/6166)).
Expand Down

0 comments on commit aff9a8e

Please sign in to comment.