Browse Source

Add Changesets with new icons preview in the release PR (#1645)

pull/1647/head
Paweł Kuna 5 days ago
committed by GitHub
parent
commit
c3ca84f875
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 37
      .build/changelog-image.mjs
  2. 13
      .build/helpers.mjs
  3. 25
      .build/release-changeset.mjs
  4. 32
      .build/release-notes.mjs
  5. 34
      .build/release-version.mjs
  6. 23
      .changeset/README.md
  7. 8
      .changeset/alphabet-arabic-tags.md
  8. 8
      .changeset/brand-instagram-size.md
  9. 8
      .changeset/config.json
  10. 8
      .changeset/fix-square-dashed.md
  11. 13
      .changeset/no-source-maps.md
  12. 8
      .changeset/react-native-props.md
  13. 8
      .changeset/redraw-dashed-icons.md
  14. 8
      .changeset/square-rounded-tags.md
  15. 9
      .changeset/svelte-default-exports.md
  16. 8
      .changeset/webfont-home-filled.md
  17. 8
      .changeset/webfont-package-fields.md
  18. 8
      .changeset/webfont-reproducible.md
  19. 8
      .changeset/webfont-svgtofont.md
  20. 100
      .github/workflows/release.yml
  21. 31
      package.json
  22. 1125
      pnpm-lock.yaml

37
.build/changelog-image.mjs

@ -1,4 +1,9 @@
import { generateIconsPreview, getAllIcons, getPackageJson, GITHUB_DIR } from './helpers.mjs';
import {
generateIconsPreview,
getIconsReleasedIn,
getPackageJson,
GITHUB_DIR,
} from './helpers.mjs';
import path from 'path';
const p = getPackageJson();
@ -6,26 +11,22 @@ const p = getPackageJson();
const version = process.env.NEW_VERSION || `${p.version}`;
if (version) {
const icons = getAllIcons();
const newIcons = getIconsReleasedIn(version);
let newIcons = [];
Object.entries(icons).forEach(([type, icons]) => {
icons.forEach((icon) => {
if (icon.version) {
if (`${icon.version}.0` === version) {
console.log(
`Add icon "${type}/${icon.name}" vith version "${icon.version}" to new icons list`,
);
newIcons.push(icon.path);
}
}
});
newIcons.forEach((icon) => {
console.log(
`Add icon "${icon.type}/${icon.name}" vith version "${icon.version}" to new icons list`,
);
});
if (newIcons.length > 0) {
generateIconsPreview(newIcons, path.join(GITHUB_DIR, `tabler-icons-${version}.svg`), {
columnsCount: 6,
paddingOuter: 24,
});
await generateIconsPreview(
newIcons.map((icon) => icon.path),
path.join(GITHUB_DIR, `tabler-icons-${version}.svg`),
{
columnsCount: 6,
paddingOuter: 24,
},
);
}
}

13
.build/helpers.mjs

@ -164,6 +164,19 @@ export const getAllIcons = (withContent = false, withObject = false) => {
return icons;
};
/**
* Icons first released in `version`, i.e. those whose `version` frontmatter is
* its minor part (`3.49` for `3.49.0`). Patch releases never add icons.
*
* @param {string} version
*/
export const getIconsReleasedIn = (version) =>
Object.entries(getAllIcons()).flatMap(([type, icons]) =>
icons
.filter((icon) => icon.version && `${icon.version}.0` === version)
.map((icon) => ({ ...icon, type })),
);
export const getAllIconsMerged = (withContent = false, withObject = false) => {
const allIcons = getAllIcons(withContent, withObject);

25
.build/release-changeset.mjs

@ -0,0 +1,25 @@
// Runs before `changeset version` (see the `version-packages` script). Icons
// are added without changesets, so the ones not released yet (no `version` in
// their frontmatter) get a generated changeset: it makes the release a minor one
// and lists the icons in the changelog.
import { writeFileSync } from 'fs';
import { resolve } from 'path';
import { HOME_DIR, getAllIcons } from './helpers.mjs';
const newIcons = Object.entries(getAllIcons()).flatMap(([type, icons]) =>
icons.filter((icon) => !icon.version).map((icon) => `${type}/${icon.name}`),
);
if (newIcons.length > 0) {
const plural = newIcons.length > 1 ? 's' : '';
writeFileSync(
resolve(HOME_DIR, '.changeset/new-icons.md'),
`---\n'@tabler/icons': minor\n---\n\n` +
`${newIcons.length} new icon${plural}\n\n` +
newIcons.map((icon) => `- \`${icon}\``).join('\n') +
'\n',
);
console.log(`Added a changeset for ${newIcons.length} new icon${plural}`);
}

32
.build/release-notes.mjs

@ -0,0 +1,32 @@
// Prints the notes of the current release: the preview image of the new icons
// followed by the section of the @tabler/icons changelog for this version.
//
// --ref <git ref> ref the image is loaded from (default: the `v<version>` tag)
// --image-only print just the image
import { existsSync, readFileSync } from 'fs';
import { resolve } from 'path';
import { GITHUB_DIR, PACKAGES_DIR, getArgvs } from './helpers.mjs';
const { version } = JSON.parse(readFileSync(resolve(PACKAGES_DIR, 'icons/package.json'), 'utf-8'));
const argvs = getArgvs();
const repo = process.env.GITHUB_REPOSITORY || 'tabler/tabler-icons';
const ref = argvs.ref || `v${version}`;
const image = `tabler-icons-${version}@2x.png`;
if (existsSync(resolve(GITHUB_DIR, image))) {
console.log(
`<img width="584" src="https://raw.githubusercontent.com/${repo}/${ref}/.github/${image}" />\n`,
);
}
if (!argvs['image-only']) {
const changelogPath = resolve(PACKAGES_DIR, 'icons/CHANGELOG.md');
const changelog = existsSync(changelogPath) ? readFileSync(changelogPath, 'utf-8') : '';
const [, section = ''] =
changelog.match(
new RegExp(`^## ${version.replace(/\./g, '\\.')}\\n([\\s\\S]*?)(?=^## |(?![\\s\\S]))`, 'm'),
) || [];
console.log(section.trim());
}

34
.build/release-version.mjs

@ -0,0 +1,34 @@
// Runs after `changeset version` (see the `version-packages` script) on the
// "Version Packages" branch: brings everything outside of the workspace
// packages to the version Changesets picked and generates the preview image
// of the icons released in it.
import { execSync } from 'child_process';
import { readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';
import { HOME_DIR, PACKAGES_DIR } from './helpers.mjs';
const { version } = JSON.parse(readFileSync(resolve(PACKAGES_DIR, 'icons/package.json'), 'utf-8'));
console.log(`Preparing release ${version}`);
// The root package.json is not a workspace package, Changesets leaves it alone
const rootPackagePath = resolve(HOME_DIR, 'package.json');
const rootPackage = JSON.parse(readFileSync(rootPackagePath, 'utf-8'));
rootPackage.version = version;
writeFileSync(rootPackagePath, `${JSON.stringify(rootPackage, null, 2)}\n`);
const run = (script) =>
execSync(`pnpm run ${script}`, {
cwd: HOME_DIR,
stdio: 'inherit',
env: { ...process.env, NEW_VERSION: version },
});
// Same steps as the `build` script, minus building the packages: icons added
// since the last release get their `unicode` and `version` here
run('validate');
run('update');
run('validate --hard');
run('optimize');
run('changelog-image');
run('update-readme');

23
.changeset/README.md

@ -0,0 +1,23 @@
# Changesets
Every pull request that should end up in a release adds a changeset:
```bash
pnpm changeset
```
All `@tabler/icons*` packages are released together with the same version (a
`fixed` group). Pick the packages the change affects, usually as a `patch`.
New icons do not need a changeset: icons that do not have a `version` in their
frontmatter yet are listed in a changeset generated when the release is
prepared (`.build/release-changeset.mjs`). Any new icon therefore opens the
release pull request on its own and makes it a minor release.
On every push to `main` the Release workflow opens (or updates) a "Version
Packages" pull request. Its description starts with a preview image of the icons
that will be released, i.e. icons that do not have a `version` in their
frontmatter yet. Merging that pull request publishes the packages to npm and
creates the `vX.Y.Z` GitHub release.
See https://changesets.dev for the full documentation.

8
.changeset/alphabet-arabic-tags.md

@ -0,0 +1,8 @@
---
'@tabler/icons': patch
---
pr: #1643
author: @codecalm
Add `alphabet`, `arabic`, `typography` and `character` tags to `alphabet-arabic`

8
.changeset/brand-instagram-size.md

@ -0,0 +1,8 @@
---
'@tabler/icons': patch
---
pr: #1615
author: @Bartosz-Do
Match `brand-instagram` size to other square brand icons

8
.changeset/config.json

@ -0,0 +1,8 @@
{
"baseBranch": "main",
"access": "public",
"changelog": ["@changesets/changelog-github", { "repo": "tabler/tabler-icons" }],
"commit": false,
"fixed": [["@tabler/icons*"]],
"privatePackages": { "version": false, "tag": false }
}

8
.changeset/fix-square-dashed.md

@ -0,0 +1,8 @@
---
'@tabler/icons': patch
---
pr: #1614
author: @Bartosz-Do
Fix `square-dashed` icon drawn as a solid square

13
.changeset/no-source-maps.md

@ -0,0 +1,13 @@
---
'@tabler/icons-react': patch
'@tabler/icons-react-native': patch
'@tabler/icons-preact': patch
'@tabler/icons-vue': patch
'@tabler/icons-solidjs': patch
'@tabler/icons-astro': patch
---
pr: #1634
author: @codecalm
Stop publishing source maps, which made up about 70% of the package size

8
.changeset/react-native-props.md

@ -0,0 +1,8 @@
---
'@tabler/icons-react-native': patch
---
pr: #1628
author: @codecalm
Stop passing extra props (`testID`, `style`, `onPress`, …) to every node of the icon, only the root `Svg` gets them. `title` is now exposed to screen readers via accessibility props

8
.changeset/redraw-dashed-icons.md

@ -0,0 +1,8 @@
---
'@tabler/icons': patch
---
pr: #1640
author: @codecalm
Redraw `square-dashed` and `table-dashed` icons

8
.changeset/square-rounded-tags.md

@ -0,0 +1,8 @@
---
'@tabler/icons': patch
---
pr: #1641
author: @codecalm
Add `squircle` tag to all `square-rounded` icons

9
.changeset/svelte-default-exports.md

@ -0,0 +1,9 @@
---
'@tabler/icons-svelte': patch
'@tabler/icons-svelte-runes': patch
---
pr: #1630
author: @codecalm
Add `default` export conditions and document per-icon imports

8
.changeset/webfont-home-filled.md

@ -0,0 +1,8 @@
---
'@tabler/icons-webfont': patch
---
pr: #1616
author: @Bartosz-Do
Fix filled `home` webfont glyph having zero width in Chrome

8
.changeset/webfont-package-fields.md

@ -0,0 +1,8 @@
---
'@tabler/icons-webfont': patch
---
pr: #1633
author: @codecalm
Fix `sass` and `style` fields in `package.json` to point to `dist/`, and stop publishing the intermediate SVG fonts, which the CSS never referenced

8
.changeset/webfont-reproducible.md

@ -0,0 +1,8 @@
---
'@tabler/icons-webfont': patch
---
pr: #1624
author: @codecalm
Make webfont builds reproducible, so font files no longer change between builds of the same icons

8
.changeset/webfont-svgtofont.md

@ -0,0 +1,8 @@
---
'@tabler/icons-webfont': patch
---
pr: #1620
author: @codecalm
Drop the unused `svgtofont` dependency

100
.github/workflows/release.yml

@ -0,0 +1,100 @@
name: Release
# On every push to `main` Changesets opens (or updates) the "Version Packages"
# pull request. Merging it publishes the packages and creates the GitHub release.
on:
push:
branches: [main]
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions: {}
jobs:
release:
if: github.repository == 'tabler/tabler-icons'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Use Node.js 22
uses: actions/setup-node@v7
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v6
name: Install pnpm
# Preview image of the new icons and the PNG/PDF/EPS packages
- name: Install rsvg-convert
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends librsvg2-bin
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v6
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
# Icons are added without changesets. Generating the changeset for the
# unreleased ones before the action runs makes any new icon open (or
# update) the release pull request as a minor release.
- name: Add changeset for new icons
run: node ./.build/release-changeset.mjs
- name: Create release pull request or publish
id: changesets
uses: changesets/action@v1
with:
version: pnpm run version-packages
publish: pnpm run release
title: 'Release'
commit: 'Release'
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Changesets builds the description from the changelogs only, so the
# preview of the new icons is put on top of it. The image is loaded from
# the commit on the release branch, the `v<version>` tag does not exist yet.
- name: Add new icons preview to the release pull request
if: steps.changesets.outputs.pullRequestNumber != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.changesets.outputs.pullRequestNumber }}
run: |
SHA=$(gh api "repos/${GITHUB_REPOSITORY}/commits/changeset-release/main" --jq .sha)
git fetch origin changeset-release/main
git checkout --detach "$SHA"
node ./.build/release-notes.mjs --image-only --ref "$SHA" > body.md
gh pr view "$PR_NUMBER" --json body --jq .body >> body.md
gh pr edit "$PR_NUMBER" --body-file body.md
- name: Create GitHub release
if: steps.changesets.outputs.published == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(node -p "require('./packages/icons/package.json').version")
node ./.build/release-notes.mjs > notes.md
gh release create "v${VERSION}" --target "$GITHUB_SHA" --title "Release ${VERSION}" --notes-file notes.md

31
package.json

@ -35,7 +35,9 @@
"generate-preview-random-icons": "node ./.build/preview-random-icons.mjs",
"generate-preview-stroke": "node ./.build/preview-stroke.mjs",
"validate": "node ./.build/validate-icons.mjs",
"release": "git pull && GITHUB_TOKEN=${GITHUB_TOKEN:-$(gh auth token)} release-it --verbose",
"changeset": "changeset",
"version-packages": "node ./.build/release-changeset.mjs && changeset version && node ./.build/release-version.mjs",
"release": "pnpm run build:packages && changeset publish",
"build:packages": "turbo run build --filter='./packages/*'",
"build:icons": "pnpm --filter @tabler/icons build",
"build:angular": "pnpm --filter @tabler/icons-angular build",
@ -58,6 +60,8 @@
"generate-icons-comment": "node ./.build/generate-icons-comment.mjs"
},
"devDependencies": {
"@changesets/changelog-github": "^1.0.1",
"@changesets/cli": "^3.0.3",
"@eslint/js": "^10.0.1",
"@rollup/plugin-node-resolve": "catalog:",
"@testing-library/jest-dom": "catalog:",
@ -79,7 +83,6 @@
"minimist": "1.2.8",
"parse-svg-path": "^0.2.0",
"prettier": "^3.9.9",
"release-it": "21.1.0",
"rollup": "catalog:",
"rollup-plugin-dts": "catalog:",
"rollup-plugin-esbuild": "catalog:",
@ -97,30 +100,6 @@
"vite": "catalog:",
"vitest": "catalog:"
},
"release-it": {
"npm": false,
"hooks": {
"before:init": [
"npm whoami || (echo 'You are not logged in to npm. Run `npm login` first.' && exit 1)",
"gh auth status || (echo 'You are not logged in to GitHub. Run `gh auth login` first.' && exit 1)"
],
"after:bump": "npm version ${version} --no-git-tag-version --allow-same-version && pnpm -r --filter './packages/*' exec npm version ${version} --no-git-tag-version --allow-same-version && export LATEST_VERSION=${latestVersion} && export NEW_VERSION=${version} && pnpm run build && pnpm install",
"after:github:release": "pnpm -r publish --tag latest --no-git-checks",
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
},
"git": {
"addUntrackedFiles": true,
"changelog": "LATEST_VERSION=${latestTag} pnpm run --silent changelog",
"tagName": "v${version}",
"requireBranch": "main",
"requireCommits": true,
"requireCleanWorkingDir": false
},
"github": {
"release": true,
"releaseNotes": "([ -f \".github/tabler-icons-${version}@2x.png\" ] && printf '<img width=\"584\" src=\"https://raw.githubusercontent.com/tabler/tabler-icons/v${version}/.github/tabler-icons-${version}@2x.png\" />\\n\\n' || true) && LATEST_VERSION=${latestTag} pnpm run --silent changelog"
}
},
"packageManager": "pnpm@10.30.3",
"pnpm": {
"ignoredBuiltDependencies": [

1125
pnpm-lock.yaml

File diff suppressed because it is too large
Loading…
Cancel
Save