-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
209 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
(async function () { | ||
const { existsSync } = (await import("fs")); | ||
const { execaSync, execaCommandSync } = (await import("execa")) | ||
const { resolve } = (await import("path")); | ||
const log = require("npmlog"); | ||
|
||
const plugins = []; | ||
const noteKeywords = [ | ||
"BREAKING CHANGE", | ||
"BREAKING CHANGES", | ||
"BREAKING" | ||
]; | ||
const { | ||
GITHUB_SHA, | ||
GITHUB_REPOSITORY, | ||
GIT_COMMITTER_NAME, | ||
GIT_COMMITTER_EMAIL, | ||
GIT_AUTHOR_NAME, | ||
GIT_AUTHOR_EMAIL, | ||
} = process.env; | ||
const successCmd = `echo 'RELEASE_TAG=v\${nextRelease.version}' >> "$GITHUB_ENV" | ||
echo 'RELEASE_VERSION=\${nextRelease.version}' >> "$GITHUB_ENV" | ||
echo 'release-tag=v\${nextRelease.version}' >> "$GITHUB_OUTPUT" | ||
echo 'release-version=\${nextRelease.version}' >> "$GITHUB_OUTPUT"`; | ||
const [owner, repo] = String(GITHUB_REPOSITORY).toLowerCase().split("/"); | ||
const addPlugin = (plugin, options) => { | ||
log.info(`${plugin} enabled ${options && 'with options:'}`); | ||
options && log.info(null, options); | ||
return plugins.push([plugin, options]); | ||
}; | ||
|
||
log.info(`Executing semantic-release config setup`); | ||
|
||
!GIT_COMMITTER_NAME && (process.env.GIT_COMMITTER_NAME = "open-sauced[bot]"); | ||
!GIT_COMMITTER_EMAIL && (process.env.GIT_COMMITTER_EMAIL = "63161813+open-sauced[bot]@users.noreply.github.com"); | ||
|
||
try { | ||
const {stdout: authorName} = execaSync("git", ["log", "-1", "--pretty=format:%an", GITHUB_SHA]); | ||
const {stdout: authorEmail} = execaSync("git", ["log", "-1", "--pretty=format:%ae", GITHUB_SHA]); | ||
authorName && !GIT_AUTHOR_NAME && (process.env.GIT_AUTHOR_NAME = `${authorName}`); | ||
authorEmail && !GIT_AUTHOR_EMAIL && (process.env.GIT_AUTHOR_EMAIL = `${authorEmail}`); | ||
} catch (e) { | ||
log.error(`Unable to set GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL`, e); | ||
} | ||
|
||
addPlugin("@semantic-release/commit-analyzer", { | ||
"preset": "conventionalcommits", | ||
"releaseRules": [ | ||
{breaking: true, release: "major"}, | ||
{type: "feat", release: "minor"}, | ||
{type: "fix", release: "patch"}, | ||
{type: "perf", release: "patch"}, | ||
{type: "revert", release: "patch"}, | ||
{type: "docs", release: "minor"}, | ||
{type: "style", release: "patch"}, | ||
{type: "refactor", release: "patch"}, | ||
{type: "test", release: "patch"}, | ||
{type: "build", release: "patch"}, | ||
{type: "ci", release: "patch"}, | ||
{type: "chore", release: false} | ||
], | ||
"parserOpts": { | ||
noteKeywords | ||
} | ||
}); | ||
|
||
addPlugin("@semantic-release/release-notes-generator", { | ||
"preset": "conventionalcommits", | ||
"parserOpts": { | ||
noteKeywords | ||
}, | ||
"writerOpts": { | ||
"commitsSort": ["subject", "scope"] | ||
}, | ||
"presetConfig": { | ||
types: [ | ||
{type: "feat", section: "🍕 Features"}, | ||
{type: "feature", section: "🍕 Features"}, | ||
{type: "fix", section: "🐛 Bug Fixes"}, | ||
{type: "perf", section: "🔥 Performance Improvements"}, | ||
{type: "revert", section: "⏩ Reverts"}, | ||
{type: "docs", section: "📝 Documentation"}, | ||
{type: "style", section: "🎨 Styles"}, | ||
{type: "refactor", section: "🧑💻 Code Refactoring"}, | ||
{type: "test", section: "✅ Tests"}, | ||
{type: "build", section: "🤖 Build System"}, | ||
{type: "ci", section: "🔁 Continuous Integration"} | ||
] | ||
} | ||
}); | ||
|
||
addPlugin("@semantic-release/changelog", { | ||
"changelogTitle": `# 📦 ${owner}/${repo} changelog | ||
[![conventional commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org) | ||
[![semantic versioning](https://img.shields.io/badge/semantic%20versioning-2.0.0-green.svg)](https://semver.org) | ||
> All notable changes to this project will be documented in this file` | ||
}); | ||
|
||
addPlugin("@semantic-release/npm", { | ||
"tarballDir": "pack" | ||
}); | ||
|
||
const actionExists = existsSync("./action.yml"); | ||
if (actionExists) { | ||
addPlugin("@google/semantic-release-replace-plugin", { | ||
"replacements": [{ | ||
"files": [ | ||
"action.yml" | ||
], | ||
"from": `image: 'docker://ghcr.io/${owner}/${repo}:.*'`, | ||
"to": `image: 'docker://ghcr.io/${owner}/${repo}:\${nextRelease.version}'`, | ||
"results": [{ | ||
"file": "action.yml", | ||
"hasChanged": true, | ||
"numMatches": 1, | ||
"numReplacements": 1 | ||
}], | ||
"countMatches": true | ||
}] | ||
}); | ||
} | ||
|
||
try { | ||
const {stdout} = execaCommandSync("ls -A1 LICENSE*", { | ||
shell: true, | ||
}); | ||
|
||
addPlugin("semantic-release-license", { | ||
license: { | ||
path: resolve(stdout) | ||
} | ||
}); | ||
} catch (e) { | ||
log.error(`Unable to run detect license command`, e); | ||
} | ||
|
||
addPlugin("@semantic-release/git", { | ||
"assets": [ | ||
"LICENSE*", | ||
"CHANGELOG.md", | ||
"package.json", | ||
"package-lock.json", | ||
"npm-shrinkwrap.json", | ||
"yarn.lock", | ||
"pnpm-lock.yaml", | ||
"public/**/*", | ||
"supabase/**/*", | ||
"action.yml" | ||
], | ||
"message": `chore(<%= nextRelease.type %>): release <%= nextRelease.version %> <%= nextRelease.channel !== null ? \`on \${nextRelease.channel} channel \` : '' %>[skip ci]\n\n<%= nextRelease.notes %>` | ||
}); | ||
|
||
addPlugin("@semantic-release/github", { | ||
"addReleases": "bottom", | ||
"assets": [ | ||
{ | ||
"path": "pack/*.tgz", | ||
"label": "Static distribution" | ||
} | ||
] | ||
}); | ||
|
||
const dockerExists = existsSync("./Dockerfile"); | ||
if (dockerExists) { | ||
addPlugin("eclass-docker-fork", { | ||
"baseImageName": `${owner}/${repo}`, | ||
"registries": [ | ||
{ | ||
"url": "ghcr.io", | ||
"imageName": `ghcr.io/${owner}/${repo}`, | ||
"user": "GITHUB_REPOSITORY_OWNER", | ||
"password": "GITHUB_TOKEN" | ||
} | ||
] | ||
}); | ||
} | ||
|
||
if (process.env.GITHUB_ACTIONS !== undefined) { | ||
addPlugin("@semantic-release/exec", { | ||
successCmd, | ||
}); | ||
} | ||
|
||
module.exports = { | ||
"branches": [ | ||
"+([0-9])?(.{+([0-9]),x}).x", | ||
"main", | ||
"next", | ||
"next-major", | ||
{ | ||
name: "beta", | ||
prerelease: true | ||
}, | ||
{ | ||
name: "alpha", | ||
prerelease: true | ||
} | ||
], | ||
plugins, | ||
} | ||
|
||
})(); |
Oops, something went wrong.