ci: switch to actions (#234)
- closes #89 Reviewed-on: https://codeberg.org/forgejo-contrib/forgejo-helm/pulls/234 Co-authored-by: Michael Kriese <michael.kriese@visualon.de> Co-committed-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
a8c4af66f5
commit
3a1928c788
16 changed files with 456 additions and 168 deletions
78
tools/changelog/util.js
Normal file
78
tools/changelog/util.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
import conventionalChangelogPreset from 'conventional-changelog-conventionalcommits';
|
||||
import conventionalChangelogCore from 'conventional-changelog-core';
|
||||
|
||||
/**
|
||||
* @type {import('conventional-changelog-core').Options}
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
||||
export const config = conventionalChangelogPreset({
|
||||
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: 'chore',
|
||||
section: 'Miscellaneous Chores',
|
||||
},
|
||||
{
|
||||
type: 'refactor',
|
||||
section: 'Code Refactoring',
|
||||
},
|
||||
{
|
||||
type: 'test',
|
||||
section: 'Tests',
|
||||
},
|
||||
{
|
||||
type: 'build',
|
||||
section: 'Build System',
|
||||
},
|
||||
{
|
||||
type: 'ci',
|
||||
section: 'Continuous Integration',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} version
|
||||
* @param {boolean} onTag
|
||||
* @returns
|
||||
*/
|
||||
export function getChangelog(version, onTag) {
|
||||
return conventionalChangelogCore(
|
||||
{
|
||||
config,
|
||||
releaseCount: onTag ? 2 : 1,
|
||||
},
|
||||
{ version, linkCompare: false },
|
||||
undefined,
|
||||
undefined,
|
||||
{ headerPartial: '' },
|
||||
);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
# helm-extra-args: --timeout 600s
|
||||
helm-extra-args: --timeout 600s
|
||||
check-version-increment: false
|
||||
debug: true
|
||||
target-branch: main
|
||||
|
|
83
tools/forgejo-release.js
Normal file
83
tools/forgejo-release.js
Normal file
|
@ -0,0 +1,83 @@
|
|||
import { Command, runExit } from 'clipanion';
|
||||
import { getChangelog } from './changelog/util.js';
|
||||
|
||||
const api = 'https://https://codeberg.org/api/v1';
|
||||
const repo = 'forgejo-contrib/forgejo-helm';
|
||||
|
||||
class GiteaReleaseCommand extends Command {
|
||||
async execute() {
|
||||
const token = process.env.GITHUB_TOKEN;
|
||||
|
||||
if (!token) {
|
||||
this.context.stdout.write('GITHUB_TOKEN environment variable not set.\n');
|
||||
return 1;
|
||||
}
|
||||
|
||||
this.context.stdout.write(`Getting tag.\n`);
|
||||
const tag = process.env.GITHUB_REF_NAME;
|
||||
|
||||
if (!tag) {
|
||||
this.context.stdout.write(
|
||||
'No tag found for this commit. Please tag the commit and try again.\n',
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
this.context.stdout.write(`Checking remote tag ${tag}.\n`);
|
||||
let resp = await fetch(`${api}/repos/${repo}/tags/${tag}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!resp.ok) {
|
||||
this.context.stdout.write(`Tag ${tag} not found on remote.\n`);
|
||||
return 1;
|
||||
}
|
||||
|
||||
this.context.stdout.write(`Checking remote release ${tag}.\n`);
|
||||
resp = await fetch(`${api}/repos/${repo}/releases/tags/${tag}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
if (resp.ok) {
|
||||
this.context.stdout.write(`Release ${tag} already exists.\n`);
|
||||
return 1;
|
||||
} else if (resp.status !== 404) {
|
||||
this.context.stdout.write(
|
||||
`Error checking for release ${tag}.\n${resp.status}: ${resp.statusText}\n`,
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const stream = getChangelog(tag, true).setEncoding('utf8');
|
||||
const changes = (await stream.toArray()).join('');
|
||||
|
||||
this.context.stdout.write(`Creating release ${tag}.\n`);
|
||||
resp = await fetch(`${api}/repos/${repo}/releases`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
draft: false,
|
||||
prerelease: tag.includes('-'),
|
||||
tag_name: tag,
|
||||
name: tag.replace(/^v/, ''),
|
||||
body: changes,
|
||||
target_commitish: 'main',
|
||||
}),
|
||||
});
|
||||
|
||||
if (!resp.ok) {
|
||||
this.context.stdout.write(
|
||||
`Error creating release ${tag}.\n${resp.status}: ${resp.statusText}\n`,
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void runExit(GiteaReleaseCommand);
|
3
tools/package.json
Normal file
3
tools/package.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"type": "module"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue