Skip to content

chore: setup changesets #8668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": ["@svitejs/changesets-changelog-github-compact", { "repo": "sveltejs/svelte" }],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "version-4",
"bumpVersionsWithWorkspaceProtocolOnly": true,
"ignore": ["!(@sveltejs/*|svelte)"]
}
8 changes: 8 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"svelte": "4.0.0-next.1"
},
"changesets": []
}
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release

on:
push:
branches:
- version-4

permissions: {}
jobs:
release:
# prevents this action from running on forks
if: github.repository == 'sveltejs/svelte'
permissions:
contents: write # to create release (changesets/action)
pull-requests: write # to create pull request (changesets/action)
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
- uses: pnpm/[email protected]
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: pnpm

- run: pnpm install --frozen-lockfile

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
version: pnpm changeset:version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"build": "pnpm -r build",
"check": "pnpm -r check",
"lint": "pnpm -r lint",
"format": "pnpm -r format"
"format": "pnpm -r format",
"changeset:version": "changeset version && pnpm -r generate:version && git add --all",
"release": "changeset release"
},
"repository": {
"type": "git",
Expand Down
1 change: 0 additions & 1 deletion packages/svelte/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.map
/src/compiler/compile/internal_exports.js
/src/shared/version.js
/compiler.d.ts
/compiler.cjs
/index.d.ts
Expand Down
1 change: 1 addition & 0 deletions packages/svelte/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ src/shared/version.js
/test/**/_actual*
/test/**/expected*
/test/**/_output
/test/**/shards/*.test.js
/types
!rollup.config.js
!vitest.config.js
2,934 changes: 1,461 additions & 1,473 deletions packages/svelte/CHANGELOG.md

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,19 @@
"format": "prettier . --cache --plugin-search-dir=. --write",
"check": "prettier . --cache --plugin-search-dir=. --check",
"test": "vitest run && echo \"manually check that there are no type errors in test/types by opening the files in there\"",
"build": "rollup -c && npm run tsd",
"prepare": "npm run build",
"build": "rollup -c && pnpm tsd",
"prepare": "pnpm build",
"generate:version": "node ./scripts/generate-version.js",
"dev": "rollup -cw",
"posttest": "agadoo src/internal/index.js",
"prepublishOnly": "npm run lint && npm run build && npm test",
"prepublishOnly": "pnpm lint && pnpm build && pnpm test",
"tsd": "node ./generate-types.js",
"lint": "eslint \"{src,test}/**/*.{ts,js}\" --cache"
},
"repository": {
"type": "git",
"url": "https://github.com/sveltejs/svelte.git",
"directory":"packages/svelte"
"directory": "packages/svelte"
},
"keywords": [
"UI",
Expand Down
10 changes: 3 additions & 7 deletions packages/svelte/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';

const require = createRequire(import.meta.url);
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
// runs the version generation as a side-effect of importing
import './scripts/generate-version.js';

// Create auto-generated .js files
fs.writeFileSync(
'./src/shared/version.js',
`/** @type {string} */\nexport const VERSION = '${pkg.version}';`
);
const require = createRequire(import.meta.url);

const internal = await import('./src/runtime/internal/index.js');
fs.writeFileSync(
Expand Down
8 changes: 8 additions & 0 deletions packages/svelte/scripts/generate-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import fs from 'node:fs';

const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));

fs.writeFileSync(
'./src/shared/version.js',
`// generated during release, do not modify\n\n/** @type {string} */\nexport const VERSION = '${pkg.version}';\n`
);
4 changes: 4 additions & 0 deletions packages/svelte/src/shared/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// generated during release, do not modify

/** @type {string} */
export const VERSION = '4.0.0-next.0';
16 changes: 16 additions & 0 deletions packages/svelte/test/version/version.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { fileURLToPath } from 'node:url';
import { assert, describe, it } from 'vitest';
import { VERSION } from 'svelte/compiler';
import { try_load_json } from '../helpers.js';

describe('svelte/compiler VERSION', () => {
it('should be the exact version from package.json');
const pkg = try_load_json(
fileURLToPath(new URL('../../../../packages/svelte/package.json', import.meta.url))
);
assert.equal(
VERSION,
pkg.version,
'VERSION export in src/shared/version.js does not equal version in package.json'
);
});