Skip to content

Commit

Permalink
Merge pull request #23 from Anush008/skip-changelog
Browse files Browse the repository at this point in the history
feat: Changelog generation conditional
  • Loading branch information
jpmcb authored Sep 7, 2023
2 parents 21cbedd + fd28263 commit 2a63da6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ Unless you have a `Dockerfile` present in your root folder, this module is not a

If you have a `Dockerfile` present, our config will attempt to push to `ghcr.io`.

### CHANGELOG

By default, a `CHANGELOG.md` file is generated and committed to document the changes introduced in releases.

This can be skipped by setting `SKIP_CHANGELOG=true`.

### Environment variables

Using our configuration comes with some sensible defaults:
Expand Down
47 changes: 25 additions & 22 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ const {
GIT_COMMITTER_EMAIL,
GIT_AUTHOR_NAME,
GIT_AUTHOR_EMAIL,
NPM_PACKAGE_ROOT
NPM_PACKAGE_ROOT,
SKIP_CHANGELOG = false,
SKIP_DOCKER_PUBLISH = false,
SKIP_NPM_PUBLISH = false
} = process.env;
const [owner, repo] = String(GITHUB_REPOSITORY).toLowerCase().split("/");
const addPlugin = (plugin, options) => {
Expand Down Expand Up @@ -109,16 +112,18 @@ addPlugin("@semantic-release/release-notes-generator", {
}
});

addPlugin("@semantic-release/changelog", {
"changelogTitle": `# 📦 ${owner}/${repo} changelog
if (!SKIP_CHANGELOG) {
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`
});
});
}

if (process.env.SKIP_NPM_PUBLISH === undefined) {
if (!SKIP_NPM_PUBLISH) {
const pkgRoot = NPM_PACKAGE_ROOT || ".";
addPlugin("@semantic-release/npm", {
tarballDir: "pack",
Expand Down Expand Up @@ -166,25 +171,23 @@ if (manifestExists && GITHUB_REF === "refs/heads/main") {
});
}

if (process.env.SKIP_NPM_PUBLISH === undefined) {
const packageFilesPrefix = process.env.NPM_PACKAGE_ROOT ? `${process.env.NPM_PACKAGE_ROOT}/` : "";
addPlugin("@semantic-release/git", {
const packageFilesPrefix = process.env.NPM_PACKAGE_ROOT ? `${process.env.NPM_PACKAGE_ROOT}/` : "";
addPlugin("@semantic-release/git", {
"assets": [
"LICENSE*",
"CHANGELOG.md",
`${packageFilesPrefix}package.json`,
`${packageFilesPrefix}package-lock.json`,
`${packageFilesPrefix}npm-shrinkwrap.json`,
`${packageFilesPrefix}yarn.lock`,
`${packageFilesPrefix}pnpm-lock.yaml`,
"public/**/*",
"supabase/**/*",
"action.yml",
"manifest.json"
"LICENSE*",
"CHANGELOG.md",
`${packageFilesPrefix}package.json`,
`${packageFilesPrefix}package-lock.json`,
`${packageFilesPrefix}npm-shrinkwrap.json`,
`${packageFilesPrefix}yarn.lock`,
`${packageFilesPrefix}pnpm-lock.yaml`,
"public/**/*",
"supabase/**/*",
"action.yml",
"manifest.json"
],
"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",
Expand All @@ -197,7 +200,7 @@ addPlugin("@semantic-release/github", {
});

const dockerExists = existsSync("./Dockerfile");
if (dockerExists && process.env.SKIP_DOCKER_PUBLISH === undefined) {
if (dockerExists && !SKIP_DOCKER_PUBLISH) {
addPlugin("eclass-docker-fork", {
"baseImageName": `${owner}/${repo}`,
"registries": [
Expand Down

0 comments on commit 2a63da6

Please sign in to comment.