@semantic-release/github 10.1.4 → 10.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -139,6 +139,19 @@ By default the \`repositoryUrl\` option is retrieved from the \`repository\` pro
139
139
  };
140
140
  }
141
141
 
142
+ export function EMISMATCHGITHUBURL({ repositoryUrl, clone_url }) {
143
+ return {
144
+ message: "The git repository URL mismatches the GitHub URL.",
145
+ details: `The **semantic-release** \`repositoryUrl\` option must have the same repository name and owner as the GitHub repo.
146
+
147
+ Your configuration for the \`repositoryUrl\` option is \`${stringify(repositoryUrl)}\` and the \`clone_url\` of your GitHub repo is \`${stringify(clone_url)}\`.
148
+
149
+ By default the \`repositoryUrl\` option is retrieved from the \`repository\` property of your \`package.json\` or the [git origin url](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes) of the repository cloned by your CI environment.
150
+
151
+ Note: If you have recently changed your GitHub repository name or owner, update the value in **semantic-release** \`repositoryUrl\` option and the \`repository\` property of your \`package.json\` respectively to match the new GitHub URL.`,
152
+ };
153
+ }
154
+
142
155
  export function EINVALIDPROXY({ proxy }) {
143
156
  return {
144
157
  message: "Invalid `proxy` option.",
package/lib/verify.js CHANGED
@@ -103,35 +103,34 @@ export default async function verify(pluginConfig, context, { Octokit }) {
103
103
  proxy,
104
104
  }),
105
105
  );
106
-
107
- // https://github.com/semantic-release/github/issues/182
108
- // Do not check for permissions in GitHub actions, as the provided token is an installation access token.
109
- // octokit.request("GET /repos/{owner}/{repo}", {repo, owner}) does not return the "permissions" key in that case.
110
- // But GitHub Actions have all permissions required for @semantic-release/github to work
111
- if (env.GITHUB_ACTION) {
112
- return;
113
- }
114
-
115
106
  try {
116
107
  const {
117
- data: {
118
- permissions: { push },
119
- },
108
+ data: { permissions, clone_url },
120
109
  } = await octokit.request("GET /repos/{owner}/{repo}", { repo, owner });
121
- if (!push) {
110
+ // Verify if Repository Name wasn't changed
111
+ const parsedCloneUrl = parseGithubUrl(clone_url);
112
+ if (owner !== parsedCloneUrl.owner || repo !== parsedCloneUrl.repo) {
113
+ errors.push(
114
+ getError("EMISMATCHGITHUBURL", { repositoryUrl, clone_url }),
115
+ );
116
+ }
117
+
118
+ // https://github.com/semantic-release/github/issues/182
119
+ // Do not check for permissions in GitHub actions, as the provided token is an installation access token.
120
+ // octokit.request("GET /repos/{owner}/{repo}", {repo, owner}) does not return the "permissions" key in that case.
121
+ // But GitHub Actions have all permissions required for @semantic-release/github to work
122
+ if (!env.GITHUB_ACTION && !permissions?.push) {
122
123
  // If authenticated as GitHub App installation, `push` will always be false.
123
124
  // We send another request to check if current authentication is an installation.
124
125
  // Note: we cannot check if the installation has all required permissions, it's
125
126
  // up to the user to make sure it has
126
127
  if (
127
- await octokit
128
+ !(await octokit
128
129
  .request("HEAD /installation/repositories", { per_page: 1 })
129
- .catch(() => false)
130
+ .catch(() => false))
130
131
  ) {
131
- return;
132
+ errors.push(getError("EGHNOPERMISSION", { owner, repo }));
132
133
  }
133
-
134
- errors.push(getError("EGHNOPERMISSION", { owner, repo }));
135
134
  }
136
135
  } catch (error) {
137
136
  if (error.status === 401) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semantic-release/github",
3
3
  "description": "semantic-release plugin to publish a GitHub release and comment on released Pull Requests/Issues",
4
- "version": "10.1.4",
4
+ "version": "10.1.5",
5
5
  "type": "module",
6
6
  "author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
7
7
  "ava": {