Skip to content

Commit

Permalink
feat(releases): gitlab support
Browse files Browse the repository at this point in the history
  • Loading branch information
jessevanmuijden committed Jul 27, 2023
1 parent a68b42c commit 83c404c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
26 changes: 26 additions & 0 deletions packages/netlify-cms-backend-gitlab/src/API.ts
Expand Up @@ -1015,4 +1015,30 @@ export default class API {
const mergeRequest = await this.getBranchMergeRequest(branch);
return mergeRequest.sha;
}

async listReleases() {
console.log(
'%c Loading releases',
'line-height: 30px;text-align: center;font-weight: bold',
);

return this.request(`${this.repoURL}/releases`)
}

async publishRelease(version: string) {
console.log(
`%c Publishing release ${version}`,
'line-height: 30px;text-align: center;font-weight: bold',
);

return this.requestJSON({
url: `${this.repoURL}/releases`,
method: 'POST',
headers: { 'Content-Type': 'application/json; charset=utf-8' },
body: JSON.stringify({
tag_name: version,
ref: this.branch,
}),
});
}
}
18 changes: 18 additions & 0 deletions packages/netlify-cms-backend-gitlab/src/implementation.ts
Expand Up @@ -453,4 +453,22 @@ export default class GitLab implements Implementation {
return null;
}
}

async listReleases() {
try {
const response = await this.api!.listReleases();
const json = await response.json()
return json;
} catch (e) {
return [];
}
}

async publishRelease(version: string) {
try {
return await this.api!.publishRelease(version);
} catch (e) {
return;
}
}
}
Expand Up @@ -80,7 +80,7 @@ class Releases extends Component {
<ul>
{releases.map(release => (
<li key={release.tag_name}>
<a href={release.html_url}>
<a href={release.html_url || release._links.self}>
{release.tag_name}
</a>
</li>
Expand Down

0 comments on commit 83c404c

Please sign in to comment.