mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Compare commits
@@ -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)
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/@changesets/config@1.6.2/schema.json",
|
||||
"changelog": [
|
||||
"@changesets/changelog-github",
|
||||
{ "repo": "changesets/action" }
|
||||
],
|
||||
"commit": false,
|
||||
"linked": [],
|
||||
"access": "restricted",
|
||||
"baseBranch": "main",
|
||||
"updateInternalDependencies": "patch",
|
||||
"ignore": []
|
||||
}
|
||||
@@ -9,15 +9,16 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node.js 12
|
||||
- name: Use Node.js 14
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
node-version: 14.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
- name: Install Dependencies
|
||||
run: yarn --frozen-lockfile
|
||||
|
||||
- name: Test
|
||||
run: yarn test
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
name: Version or Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
changesets:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node.js 14
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 14.x
|
||||
|
||||
- name: Install Dependencies
|
||||
run: yarn --frozen-lockfile
|
||||
|
||||
- name: Build
|
||||
run: yarn build
|
||||
|
||||
- name: Create Release Pull Request or Publish
|
||||
id: changesets
|
||||
uses: ./
|
||||
with:
|
||||
version: yarn bump
|
||||
publish: yarn release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -2,3 +2,5 @@ node_modules
|
||||
.parcel-cache
|
||||
.cache
|
||||
*.log
|
||||
|
||||
dist/
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# @changesets/action
|
||||
|
||||
## 1.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#144](https://github.com/changesets/action/pull/144) [`898d125`](https://github.com/changesets/action/commit/898d125cee6ba00c6a11b6cadca512752c6c910c) Thanks [@Andarist](https://github.com/Andarist)! - Updated all Changesets dependencies. This should fix parsing issues for completely empty summaries that has been fixed in `@changesets/parse@0.3.11`.
|
||||
|
||||
## 1.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#130](https://github.com/changesets/action/pull/130) [`5c0997b`](https://github.com/changesets/action/commit/5c0997b25e175ecf5e1723ba07210bbcea5d92fb) Thanks [@akphi](https://github.com/akphi)! - Added `createGithubReleases` input option (defaults to `true`) to control whether to create Github releases during publish or not.
|
||||
|
||||
* [#134](https://github.com/changesets/action/pull/134) [`1ed9bc2`](https://github.com/changesets/action/commit/1ed9bc24b7a56462c183eb815c8f4bdf0e2e5785) Thanks [@dmregister](https://github.com/dmregister)! - Added `cwd` input option that can be used in projects that are not in the root directory.
|
||||
|
||||
## 1.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#128](https://github.com/changesets/action/pull/128) [`1937303`](https://github.com/changesets/action/commit/19373036c4bad4b0183344b6f2623a3b0e42da6c) Thanks [@dhruvdutt](https://github.com/dhruvdutt)! - Setup the git user in the local config instead of the global one.
|
||||
|
||||
* [#131](https://github.com/changesets/action/pull/131) [`d3db9ec`](https://github.com/changesets/action/commit/d3db9eceaf41d42c56d5370d504c86851627188f) Thanks [@jacklesliewise](https://github.com/jacklesliewise)! - Added `setupGitUser` option to enable or disable setting up a default git user
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- [#118](https://github.com/changesets/action/pull/118) [`05c863d`](https://github.com/changesets/action/commit/05c863d3f980125585016a593b5cb45b27d19c2c) Thanks [@Andarist](https://github.com/Andarist)! - From now on this action will be released using the Changesets-based workflow (using itself). Thanks to that we'll have a good release history. The users will be able to find specific versions of the action and will be able to track changes over time. It also improves the security as the build artifact will always get built in the CI environment, using a frozen lockfile.
|
||||
@@ -10,6 +10,8 @@ This action for [Changesets](https://github.com/atlassian/changesets) creates a
|
||||
- version - The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided
|
||||
- commit - The commit message to use. Default to `Version Packages`
|
||||
- title - The pull request title. Default to `Version Packages`
|
||||
- setupGitUser - Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
|
||||
- cwd - Changes node's `process.cwd()` if the project is not located on the root. Default to `process.cwd()`
|
||||
|
||||
### Outputs
|
||||
|
||||
@@ -30,19 +32,21 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@master
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js 12.x
|
||||
uses: actions/setup-node@master
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
@@ -50,7 +54,7 @@ jobs:
|
||||
run: yarn
|
||||
|
||||
- name: Create Release Pull Request
|
||||
uses: changesets/action@master
|
||||
uses: changesets/action@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
@@ -67,19 +71,21 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@master
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js 12.x
|
||||
uses: actions/setup-node@master
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
@@ -88,7 +94,7 @@ jobs:
|
||||
|
||||
- name: Create Release Pull Request or Publish to npm
|
||||
id: changesets
|
||||
uses: changesets/action@master
|
||||
uses: changesets/action@v1
|
||||
with:
|
||||
# This expects you to have a script called release which does a build for your packages and calls changeset publish
|
||||
publish: yarn release
|
||||
@@ -136,18 +142,20 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@master
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js 12.x
|
||||
uses: actions/setup-node@master
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
@@ -155,7 +163,7 @@ jobs:
|
||||
run: yarn
|
||||
|
||||
- name: Create Release Pull Request
|
||||
uses: changesets/action@master
|
||||
uses: changesets/action@v1
|
||||
with:
|
||||
# this expects you to have a npm script called version that runs some logic and then calls `changeset version`.
|
||||
version: yarn version
|
||||
@@ -168,7 +176,7 @@ jobs:
|
||||
If you are using [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp), you should use a custom `version` command so that the action can resolve the `changeset` CLI:
|
||||
|
||||
```yaml
|
||||
- uses: changesets/action@master
|
||||
- uses: changesets/action@v1
|
||||
with:
|
||||
version: yarn changeset version
|
||||
...
|
||||
|
||||
+11
@@ -10,6 +10,9 @@ inputs:
|
||||
version:
|
||||
description: "The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided"
|
||||
required: false
|
||||
cwd:
|
||||
description: Sets the cwd for the node process. Default to `process.cwd()`
|
||||
required: false
|
||||
commit:
|
||||
description: |
|
||||
The commit message. Default to `Version Packages`
|
||||
@@ -17,6 +20,14 @@ inputs:
|
||||
title:
|
||||
description: The pull request title. Default to `Version Packages`
|
||||
required: false
|
||||
setupGitUser:
|
||||
description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
|
||||
required: false
|
||||
default: true
|
||||
createGithubReleases:
|
||||
description: "A boolean value to indicate whether to create Github releases after `publish` or not"
|
||||
required: false
|
||||
default: true
|
||||
outputs:
|
||||
published:
|
||||
description: A boolean value to indicate whether a publishing is happened or not
|
||||
|
||||
Vendored
+55
-43
File diff suppressed because one or more lines are too long
+14
-12
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "@changesets/action",
|
||||
"version": "0.1.0",
|
||||
"version": "1.2.1",
|
||||
"main": "dist/index.js",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@changesets/cli": "^2.9.1",
|
||||
"@changesets/write": "^0.1.3",
|
||||
"@changesets/changelog-github": "^0.4.2",
|
||||
"@changesets/cli": "^2.20.0",
|
||||
"@changesets/write": "^0.1.6",
|
||||
"fixturez": "^1.1.0",
|
||||
"parcel": "^1.12.3",
|
||||
"prettier": "^2.0.5",
|
||||
@@ -14,18 +15,21 @@
|
||||
"scripts": {
|
||||
"build": "parcel build ./src/index.ts --no-source-maps --target=node --bundle-node-modules",
|
||||
"test": "jest",
|
||||
"test:watch": "yarn test --watch"
|
||||
"test:watch": "yarn test --watch",
|
||||
"changeset": "changeset",
|
||||
"bump": "node ./scripts/bump.js",
|
||||
"release": "node ./scripts/release.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.4",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/core": "^1.3.0",
|
||||
"@actions/exec": "^1.1.0",
|
||||
"@actions/github": "^4.0.0",
|
||||
"@babel/core": "^7.13.10",
|
||||
"@babel/preset-env": "^7.13.10",
|
||||
"@babel/preset-typescript": "^7.13.0",
|
||||
"@changesets/pre": "^1.0.4",
|
||||
"@changesets/read": "^0.4.6",
|
||||
"@manypkg/get-packages": "^1.1.1",
|
||||
"@changesets/pre": "^1.0.9",
|
||||
"@changesets/read": "^0.5.3",
|
||||
"@manypkg/get-packages": "^1.1.3",
|
||||
"@types/fs-extra": "^8.0.0",
|
||||
"@types/jest": "^24.0.18",
|
||||
"@types/node": "^12.7.1",
|
||||
@@ -42,9 +46,7 @@
|
||||
"unified": "^8.3.2"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "yarn build && git add dist/index.js"
|
||||
}
|
||||
"hooks": {}
|
||||
},
|
||||
"prettier": {}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { exec } = require("@actions/exec");
|
||||
|
||||
process.chdir(path.join(__dirname, ".."));
|
||||
|
||||
(async () => {
|
||||
await exec("changeset", ["version"]);
|
||||
|
||||
const releaseLine = `v${require("../package.json").version.split(".")[0]}`;
|
||||
|
||||
const readmePath = path.join(__dirname, "..", "README.md");
|
||||
const content = fs.readFileSync(readmePath, "utf8");
|
||||
const updatedContent = content.replace(
|
||||
/changesets\/action@[^\s]+/g,
|
||||
`changesets/action@${releaseLine}`
|
||||
);
|
||||
fs.writeFileSync(readmePath, updatedContent);
|
||||
})();
|
||||
@@ -0,0 +1,41 @@
|
||||
const path = require("path");
|
||||
const { exec, getExecOutput } = require("@actions/exec");
|
||||
|
||||
const { version } = require("../package.json");
|
||||
const tag = `v${version}`;
|
||||
const releaseLine = `v${version.split(".")[0]}`;
|
||||
|
||||
process.chdir(path.join(__dirname, ".."));
|
||||
|
||||
(async () => {
|
||||
const { exitCode, stderr } = await getExecOutput(
|
||||
`git`,
|
||||
["ls-remote", "--exit-code", "origin", "--tags", `refs/tags/${tag}`],
|
||||
{
|
||||
ignoreReturnCode: true,
|
||||
}
|
||||
);
|
||||
if (exitCode === 0) {
|
||||
console.log(
|
||||
`Action is not being published because version ${tag} is already published`
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (exitCode !== 2) {
|
||||
throw new Error(`git ls-remote exited with ${exitCode}:\n${stderr}`);
|
||||
}
|
||||
|
||||
await exec("git", ["checkout", "--detach"]);
|
||||
await exec("git", ["add", "--force", "dist"]);
|
||||
await exec("git", ["commit", "-m", tag]);
|
||||
|
||||
await exec("changeset", ["tag"]);
|
||||
|
||||
await exec("git", [
|
||||
"push",
|
||||
"--force",
|
||||
"--follow-tags",
|
||||
"origin",
|
||||
`HEAD:refs/heads/${releaseLine}`,
|
||||
]);
|
||||
})();
|
||||
@@ -15,7 +15,7 @@ Array [
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [undefined]
|
||||
- Updated dependencies
|
||||
- simple-project-pkg-b@1.1.0
|
||||
|
||||
## simple-project-pkg-b@1.1.0
|
||||
|
||||
@@ -4,13 +4,11 @@ import { execWithOutput } from "./utils";
|
||||
export const setupUser = async () => {
|
||||
await exec("git", [
|
||||
"config",
|
||||
"--global",
|
||||
"user.name",
|
||||
`"github-actions[bot]"`,
|
||||
]);
|
||||
await exec("git", [
|
||||
"config",
|
||||
"--global",
|
||||
"user.email",
|
||||
`"github-actions[bot]@users.noreply.github.com"`,
|
||||
]);
|
||||
|
||||
@@ -14,8 +14,12 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
let setupGitUser = core.getBooleanInput("setupGitUser");
|
||||
|
||||
if (setupGitUser) {
|
||||
console.log("setting git user");
|
||||
await gitUtils.setupUser();
|
||||
}
|
||||
|
||||
console.log("setting GitHub credentials");
|
||||
await fs.writeFile(
|
||||
@@ -23,6 +27,12 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
|
||||
`machine github.com\nlogin github-actions[bot]\npassword ${githubToken}`
|
||||
);
|
||||
|
||||
const inputCwd = core.getInput("cwd");
|
||||
if (inputCwd) {
|
||||
console.log("changing directory to the one given as the input");
|
||||
process.chdir(inputCwd);
|
||||
}
|
||||
|
||||
let { changesets } = await readChangesetState();
|
||||
|
||||
let publishScript = core.getInput("publish");
|
||||
@@ -74,6 +84,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
|
||||
const result = await runPublish({
|
||||
script: publishScript,
|
||||
githubToken,
|
||||
createGithubReleases: core.getBooleanInput("createGithubReleases"),
|
||||
});
|
||||
|
||||
if (result.published) {
|
||||
|
||||
@@ -51,6 +51,7 @@ const createRelease = async (
|
||||
type PublishOptions = {
|
||||
script: string;
|
||||
githubToken: string;
|
||||
createGithubReleases: boolean;
|
||||
cwd?: string;
|
||||
};
|
||||
|
||||
@@ -68,6 +69,7 @@ type PublishResult =
|
||||
export async function runPublish({
|
||||
script,
|
||||
githubToken,
|
||||
createGithubReleases,
|
||||
cwd = process.cwd(),
|
||||
}: PublishOptions): Promise<PublishResult> {
|
||||
let octokit = github.getOctokit(githubToken);
|
||||
@@ -104,6 +106,7 @@ export async function runPublish({
|
||||
releasedPackages.push(pkg);
|
||||
}
|
||||
|
||||
if (createGithubReleases) {
|
||||
await Promise.all(
|
||||
releasedPackages.map((pkg) =>
|
||||
createRelease(octokit, {
|
||||
@@ -112,6 +115,7 @@ export async function runPublish({
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (packages.length === 0) {
|
||||
throw new Error(
|
||||
@@ -127,10 +131,12 @@ export async function runPublish({
|
||||
|
||||
if (match) {
|
||||
releasedPackages.push(pkg);
|
||||
if (createGithubReleases) {
|
||||
await createRelease(octokit, {
|
||||
pkg,
|
||||
tagName: `v${pkg.packageJson.version}`,
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user