Compare commits

...
17 Commits
Author SHA1 Message Date
github-actions[bot] 983cabb332 v1.2.1 2022-03-04 07:31:24 +00:00
github-actions[bot]andgithub-actions[bot] 69dae4d9ca Version Packages (#145)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-03-04 08:30:04 +01:00
Mateusz Burzyński 56bd5e54f8 Add concurrency option to the exampels in the README (#156) 2022-03-04 07:27:33 +01:00
Mateusz Burzyński 898d125cee Updated all Changesets dependencies (#144) 2022-01-27 07:36:21 +01:00
github-actions[bot]andgithub-actions[bot] e8ffc2d207 Version Packages (#140)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-01-23 14:27:10 +01:00
David RegisterandMateusz Burzyński 1ed9bc24b7 Added cwd input option (#134)
* feat: add cwd for projects that not in the root directory

* docs: add cwd to README

* reword the added log

* tweak changeset

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
2022-01-23 14:25:45 +01:00
An PhiandMateusz Burzyński 5c0997b25e Added createGithubReleases input option (defaults to true) to control whether to create Github releases during publish or not (#130)
* allow skipping creation of Github releases

* fixes for PR review

* minor improvements

* add changeset

* nits

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
2022-01-23 11:07:42 +01:00
github-actions[bot]andgithub-actions[bot] f4afbea27e Version Packages (#129)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-01-07 16:41:51 +01:00
Jack LeslieandMitchell Hamilton d3db9eceaf Added setupGitUser option to enable or disable setting up a default git user (#131)
* custom git user option

* Create two-dolls-promise.md

* Update two-dolls-promise.md

* change input name and update default

* Update .changeset/two-dolls-promise.md

Co-authored-by: Mitchell Hamilton <mitchell@hamil.town>
2022-01-07 15:27:29 +01:00
Mateusz Burzyński e0c51a52b8 Fix changeset author attribution 2021-12-23 11:31:32 +01:00
Mateusz BurzyńskiandDhruvdutt Jadhav 19373036c4 Setup the git user in the local config instead of the global one (#128)
* Update gitUtils.ts

* add changeset

Co-authored-by: Dhruvdutt Jadhav <dhruvdutt.jadhav@razorpay.com>
2021-12-23 11:21:40 +01:00
Mateusz Burzyński 37c2edd85b Fixed the checkout repo step in ci.yml 2021-11-26 14:18:16 +01:00
Mitchell Hamilton 5556dd0a57 Reference specific versions of other actions (#122) 2021-11-26 10:23:11 +01:00
2eadeb0ff8 Version Packages (#119)
* Version Packages

* Fixup version bump

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
2021-11-25 18:07:53 +01:00
Mateusz Burzyński 3ea945d945 Rename version script to bump 2021-11-25 18:02:16 +01:00
Mateusz Burzyński 77633d0426 Fixed how local action is referenced from the workflow file 2021-11-25 17:53:46 +01:00
Mateusz BurzyńskiandNicola Molinari 05c863d3f9 Switch to Changesets-based release process (#118)
* Switch to Changesets-based release process

* Bump version

* drop unused variable

* Update .github/workflows/version-or-publish.yml

Co-authored-by: Nicola Molinari <nicola.molinari@commercetools.com>

* Push also to a release line branch when releasing

* Change node version used in the version-or-publish workflow

* Switch to using the local action

Co-authored-by: Nicola Molinari <nicola.molinari@commercetools.com>

* build the action before trying to use it the workflow

* Add changeset and actually setup Changesets, lol

Co-authored-by: Nicola Molinari <nicola.molinari@commercetools.com>
2021-11-25 17:51:48 +01:00
17 changed files with 618 additions and 422 deletions
+8
View File
@@ -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)
+13
View File
@@ -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": []
}
+6 -5
View File
@@ -9,15 +9,16 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: 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 uses: actions/setup-node@v1
with: with:
node-version: 12.x node-version: 14.x
- name: Install dependencies - name: Install Dependencies
run: yarn run: yarn --frozen-lockfile
- name: Test - name: Test
run: yarn test run: yarn test
+33
View File
@@ -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
View File
@@ -2,3 +2,5 @@ node_modules
.parcel-cache .parcel-cache
.cache .cache
*.log *.log
dist/
+29
View File
@@ -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.
+18 -10
View File
@@ -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 - 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` - commit - The commit message to use. Default to `Version Packages`
- title - The pull request title. 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 ### Outputs
@@ -30,19 +32,21 @@ on:
branches: branches:
- master - master
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs: jobs:
release: release:
name: Release name: Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@master uses: actions/checkout@v2
with: with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0 fetch-depth: 0
- name: Setup Node.js 12.x - name: Setup Node.js 12.x
uses: actions/setup-node@master uses: actions/setup-node@v2
with: with:
node-version: 12.x node-version: 12.x
@@ -50,7 +54,7 @@ jobs:
run: yarn run: yarn
- name: Create Release Pull Request - name: Create Release Pull Request
uses: changesets/action@master uses: changesets/action@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
@@ -67,19 +71,21 @@ on:
branches: branches:
- master - master
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs: jobs:
release: release:
name: Release name: Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@master uses: actions/checkout@v2
with: with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0 fetch-depth: 0
- name: Setup Node.js 12.x - name: Setup Node.js 12.x
uses: actions/setup-node@master uses: actions/setup-node@v2
with: with:
node-version: 12.x node-version: 12.x
@@ -88,7 +94,7 @@ jobs:
- name: Create Release Pull Request or Publish to npm - name: Create Release Pull Request or Publish to npm
id: changesets id: changesets
uses: changesets/action@master uses: changesets/action@v1
with: with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish # This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release publish: yarn release
@@ -136,18 +142,20 @@ on:
branches: branches:
- master - master
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs: jobs:
release: release:
name: Release name: Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Repo - name: Checkout Repo
uses: actions/checkout@master uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Node.js 12.x - name: Setup Node.js 12.x
uses: actions/setup-node@master uses: actions/setup-node@v2
with: with:
node-version: 12.x node-version: 12.x
@@ -155,7 +163,7 @@ jobs:
run: yarn run: yarn
- name: Create Release Pull Request - name: Create Release Pull Request
uses: changesets/action@master uses: changesets/action@v1
with: with:
# this expects you to have a npm script called version that runs some logic and then calls `changeset version`. # this expects you to have a npm script called version that runs some logic and then calls `changeset version`.
version: yarn 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: 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 ```yaml
- uses: changesets/action@master - uses: changesets/action@v1
with: with:
version: yarn changeset version version: yarn changeset version
... ...
+11
View File
@@ -10,6 +10,9 @@ inputs:
version: version:
description: "The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided" description: "The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided"
required: false required: false
cwd:
description: Sets the cwd for the node process. Default to `process.cwd()`
required: false
commit: commit:
description: | description: |
The commit message. Default to `Version Packages` The commit message. Default to `Version Packages`
@@ -17,6 +20,14 @@ inputs:
title: title:
description: The pull request title. Default to `Version Packages` description: The pull request title. Default to `Version Packages`
required: false 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: outputs:
published: published:
description: A boolean value to indicate whether a publishing is happened or not description: A boolean value to indicate whether a publishing is happened or not
+55 -43
View File
File diff suppressed because one or more lines are too long
+14 -12
View File
@@ -1,11 +1,12 @@
{ {
"name": "@changesets/action", "name": "@changesets/action",
"version": "0.1.0", "version": "1.2.1",
"main": "dist/index.js", "main": "dist/index.js",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@changesets/cli": "^2.9.1", "@changesets/changelog-github": "^0.4.2",
"@changesets/write": "^0.1.3", "@changesets/cli": "^2.20.0",
"@changesets/write": "^0.1.6",
"fixturez": "^1.1.0", "fixturez": "^1.1.0",
"parcel": "^1.12.3", "parcel": "^1.12.3",
"prettier": "^2.0.5", "prettier": "^2.0.5",
@@ -14,18 +15,21 @@
"scripts": { "scripts": {
"build": "parcel build ./src/index.ts --no-source-maps --target=node --bundle-node-modules", "build": "parcel build ./src/index.ts --no-source-maps --target=node --bundle-node-modules",
"test": "jest", "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": { "dependencies": {
"@actions/core": "^1.2.4", "@actions/core": "^1.3.0",
"@actions/exec": "^1.0.4", "@actions/exec": "^1.1.0",
"@actions/github": "^4.0.0", "@actions/github": "^4.0.0",
"@babel/core": "^7.13.10", "@babel/core": "^7.13.10",
"@babel/preset-env": "^7.13.10", "@babel/preset-env": "^7.13.10",
"@babel/preset-typescript": "^7.13.0", "@babel/preset-typescript": "^7.13.0",
"@changesets/pre": "^1.0.4", "@changesets/pre": "^1.0.9",
"@changesets/read": "^0.4.6", "@changesets/read": "^0.5.3",
"@manypkg/get-packages": "^1.1.1", "@manypkg/get-packages": "^1.1.3",
"@types/fs-extra": "^8.0.0", "@types/fs-extra": "^8.0.0",
"@types/jest": "^24.0.18", "@types/jest": "^24.0.18",
"@types/node": "^12.7.1", "@types/node": "^12.7.1",
@@ -42,9 +46,7 @@
"unified": "^8.3.2" "unified": "^8.3.2"
}, },
"husky": { "husky": {
"hooks": { "hooks": {}
"pre-commit": "yarn build && git add dist/index.js"
}
}, },
"prettier": {} "prettier": {}
} }
+19
View File
@@ -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);
})();
+41
View File
@@ -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}`,
]);
})();
+1 -1
View File
@@ -15,7 +15,7 @@ Array [
### Patch Changes ### Patch Changes
- Updated dependencies [undefined] - Updated dependencies
- simple-project-pkg-b@1.1.0 - simple-project-pkg-b@1.1.0
## simple-project-pkg-b@1.1.0 ## simple-project-pkg-b@1.1.0
-2
View File
@@ -4,13 +4,11 @@ import { execWithOutput } from "./utils";
export const setupUser = async () => { export const setupUser = async () => {
await exec("git", [ await exec("git", [
"config", "config",
"--global",
"user.name", "user.name",
`"github-actions[bot]"`, `"github-actions[bot]"`,
]); ]);
await exec("git", [ await exec("git", [
"config", "config",
"--global",
"user.email", "user.email",
`"github-actions[bot]@users.noreply.github.com"`, `"github-actions[bot]@users.noreply.github.com"`,
]); ]);
+11
View File
@@ -14,8 +14,12 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
return; return;
} }
let setupGitUser = core.getBooleanInput("setupGitUser");
if (setupGitUser) {
console.log("setting git user"); console.log("setting git user");
await gitUtils.setupUser(); await gitUtils.setupUser();
}
console.log("setting GitHub credentials"); console.log("setting GitHub credentials");
await fs.writeFile( await fs.writeFile(
@@ -23,6 +27,12 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
`machine github.com\nlogin github-actions[bot]\npassword ${githubToken}` `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 { changesets } = await readChangesetState();
let publishScript = core.getInput("publish"); let publishScript = core.getInput("publish");
@@ -74,6 +84,7 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
const result = await runPublish({ const result = await runPublish({
script: publishScript, script: publishScript,
githubToken, githubToken,
createGithubReleases: core.getBooleanInput("createGithubReleases"),
}); });
if (result.published) { if (result.published) {
+6
View File
@@ -51,6 +51,7 @@ const createRelease = async (
type PublishOptions = { type PublishOptions = {
script: string; script: string;
githubToken: string; githubToken: string;
createGithubReleases: boolean;
cwd?: string; cwd?: string;
}; };
@@ -68,6 +69,7 @@ type PublishResult =
export async function runPublish({ export async function runPublish({
script, script,
githubToken, githubToken,
createGithubReleases,
cwd = process.cwd(), cwd = process.cwd(),
}: PublishOptions): Promise<PublishResult> { }: PublishOptions): Promise<PublishResult> {
let octokit = github.getOctokit(githubToken); let octokit = github.getOctokit(githubToken);
@@ -104,6 +106,7 @@ export async function runPublish({
releasedPackages.push(pkg); releasedPackages.push(pkg);
} }
if (createGithubReleases) {
await Promise.all( await Promise.all(
releasedPackages.map((pkg) => releasedPackages.map((pkg) =>
createRelease(octokit, { createRelease(octokit, {
@@ -112,6 +115,7 @@ export async function runPublish({
}) })
) )
); );
}
} else { } else {
if (packages.length === 0) { if (packages.length === 0) {
throw new Error( throw new Error(
@@ -127,10 +131,12 @@ export async function runPublish({
if (match) { if (match) {
releasedPackages.push(pkg); releasedPackages.push(pkg);
if (createGithubReleases) {
await createRelease(octokit, { await createRelease(octokit, {
pkg, pkg,
tagName: `v${pkg.packageJson.version}`, tagName: `v${pkg.packageJson.version}`,
}); });
}
break; break;
} }
} }
+336 -334
View File
File diff suppressed because it is too large Load Diff