Skip to content
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
2 changes: 2 additions & 0 deletions .changeset/large-experts-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 2 additions & 0 deletions .changeset/rich-carpets-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
28 changes: 28 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* This is a very stripped-down eslintrc, because @khanacademy/eslint-config
* assumes you're using react & flow (and requires a lot of dependencies along
* with it).
*/
const khan = require("@khanacademy/eslint-config");

// Only keep the rules that have no prefix (so are included in eslint core)
// and the prettier rule.
const basicRules = {};
Object.keys(khan.rules).forEach((key) => {
if (!key.includes("/") || key.startsWith("prettier/")) {
basicRules[key] = khan.rules[key];
}
});

module.exports = {
extends: ["eslint:recommended", "prettier"],
plugins: ["prettier"],
rules: basicRules,
env: {
node: true,
},
parserOptions: {
sourceType: "module",
ecmaVersion: 2022,
},
};
6 changes: 4 additions & 2 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
- pull_request

jobs:
changeset:
name: Check for .changeset file
check:
name: Lints
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Khan/actions@check-for-changeset-v0.0.0
- uses: Khan/actions@shared-node-cache-v0.0.2
- run: yarn lint
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("@khanacademy/eslint-config/.prettierrc.js");
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
"workspaces": [
"actions/*"
],
"scripts": {
"lint": "eslint --ext .js,.mjs .",
"fix": "yarn lint --fix"
},
"devDependencies": {
"@changesets/cli": "^2.22.0"
"@changesets/cli": "^2.22.0",
"eslint": "^8.15.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"@khanacademy/eslint-config": "^0.1.0",
"prettier": "^2.6.2"
}
}
5 changes: 4 additions & 1 deletion utils/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export const buildPackage = (name, packageJsons, monorepoName) => {
if (packageJsons[name].dependencies) {
const yml = `actions/${name}/dist/action.yml`;
const actionYml = fs.readFileSync(yml, "utf8");
fs.writeFileSync(yml, processActionYml(name, packageJsons, actionYml, monorepoName));
fs.writeFileSync(
yml,
processActionYml(name, packageJsons, actionYml, monorepoName),
);
}
return dist;
};
16 changes: 14 additions & 2 deletions utils/publish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,26 @@ export const checkTag = (tag) => {
return true;
};

export const publishDirectoryAsTag = (distPath, origin, tag, dryRun) => {
export const publishDirectoryAsTags = (
distPath,
origin,
tag,
majorTag,
dryRun,
) => {
const cmds = [
`git init .`,
`git add .`,
`git commit -m publish`,
`git remote add origin ${origin}`,
`git tag ${tag}`,
`git tag ${majorTag}`,
];
if (!dryRun) {
cmds.push(`git push origin ${tag}`);
// This will succeed with a warning if the major tag doesn't exist
cmds.push(`git push origin :refs/tags/${majorTag}`);
cmds.push(`git push origin ${majorTag}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this overwrite the major tag with whatever the most updated to minor.patch version within that major version is? Nice solution.

}
cmds.forEach((cmd) => {
execSync(cmd, {cwd: distPath});
Expand All @@ -54,10 +64,12 @@ export const publishAsNeeded = (packageNames, dryRun = false) => {

packageNames.forEach((name) => {
const version = packageJsons[name].version;
const majorVersion = version.split(".")[0];
const tag = `${name}-v${version}`;
const majorTag = `${name}-v${majorVersion}`;
if (!checkTag(tag)) {
const distPath = buildPackage(name, packageJsons, `Khan/actions`);
publishDirectoryAsTag(distPath, origin, tag, dryRun);
publishDirectoryAsTags(distPath, origin, tag, majorTag, dryRun);
}
});
};
Loading