fix(release): conflicting tags
This commit is contained in:
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,11 +1,9 @@
|
|||||||
# Changelog
|
## <small>0.0.2-alpha.11 (2025-07-12)</small>
|
||||||
|
|
||||||
## [0.0.2-alpha.12](https://git.tuffraid.net/cowch/logistics_support_tool/compare/v0.0.2-alpha.11...v0.0.2-alpha.12) (2025-07-12)
|
* chore(release): v0.0.2-alpha.11 ([6c7f178](https://git.tuffraid.net/cowch/logistics_support_tool/commits/6c7f178))
|
||||||
|
* fix(release): var not defined ([a282940](https://git.tuffraid.net/cowch/logistics_support_tool/commits/a282940))
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **release:** change to get the release to build then release stuff ([afab215](https://git.tuffraid.net/cowch/logistics_support_tool/commit/afab215a9e29732d8236c45c4a8417c9b1e02b1e))
|
|
||||||
* **release:** removed the intial before bump ([cf24847](https://git.tuffraid.net/cowch/logistics_support_tool/commit/cf2484705a65d065ec75690e21bf6e8f2e32a0f5))
|
|
||||||
|
|
||||||
## <small>0.0.2-alpha.10 (2025-07-12)</small>
|
## <small>0.0.2-alpha.10 (2025-07-12)</small>
|
||||||
|
|
||||||
@@ -125,3 +123,6 @@
|
|||||||
* feat(starter): intial starter release ([b370cb1](https://git.tuffraid.net/cowch/logistics_support_tool/commits/b370cb1))
|
* feat(starter): intial starter release ([b370cb1](https://git.tuffraid.net/cowch/logistics_support_tool/commits/b370cb1))
|
||||||
* Initial commit ([e4d3fc9](https://git.tuffraid.net/cowch/logistics_support_tool/commits/e4d3fc9))
|
* Initial commit ([e4d3fc9](https://git.tuffraid.net/cowch/logistics_support_tool/commits/e4d3fc9))
|
||||||
* Update README.md ([e081c8f](https://git.tuffraid.net/cowch/logistics_support_tool/commits/e081c8f))
|
* Update README.md ([e081c8f](https://git.tuffraid.net/cowch/logistics_support_tool/commits/e081c8f))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,93 @@ if (!GITEA_URL || !GITEA_USERNAME || !GITEA_REPO || !GITEA_TOKEN) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const createOrUpdateRelease = async () => {
|
||||||
|
const tagName = `v${version}`;
|
||||||
|
const apiBase = `https://${GITEA_URL}/api/v1/repos/${GITEA_USERNAME}/${GITEA_REPO}`;
|
||||||
|
|
||||||
|
// Check if release exists
|
||||||
|
const existing = await fetch(`${apiBase}/releases/tags/${tagName}`, {
|
||||||
|
headers: { Authorization: `token ${GITEA_TOKEN}` },
|
||||||
|
});
|
||||||
|
|
||||||
|
let release;
|
||||||
|
if (existing.ok) {
|
||||||
|
const existingRelease = await existing.json();
|
||||||
|
console.log(`Release ${tagName} already exists. Updating it.`);
|
||||||
|
|
||||||
|
// Update existing release
|
||||||
|
const updateResponse = await fetch(
|
||||||
|
`${apiBase}/releases/${existingRelease.id}`,
|
||||||
|
{
|
||||||
|
method: "PATCH",
|
||||||
|
headers: {
|
||||||
|
Authorization: `token ${GITEA_TOKEN}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
name: tagName,
|
||||||
|
body: releaseNotes,
|
||||||
|
draft: false,
|
||||||
|
prerelease: true,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!updateResponse.ok) {
|
||||||
|
const errorText = await updateResponse.text();
|
||||||
|
throw new Error(
|
||||||
|
`Failed to update release: ${updateResponse.status} - ${errorText}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
release = await updateResponse.json();
|
||||||
|
console.log("Release updated:", release.html_url || release.url);
|
||||||
|
} else if (existing.status === 404) {
|
||||||
|
// Release doesn't exist — create it
|
||||||
|
const createResponse = await fetch(`${apiBase}/releases`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Authorization: `token ${GITEA_TOKEN}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
tag_name: tagName,
|
||||||
|
name: tagName,
|
||||||
|
body: releaseNotes,
|
||||||
|
draft: false,
|
||||||
|
prerelease: true,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!createResponse.ok) {
|
||||||
|
const errorText = await createResponse.text();
|
||||||
|
throw new Error(
|
||||||
|
`Failed to create release: ${createResponse.status} - ${errorText}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
release = await createResponse.json();
|
||||||
|
console.log("Release created:", release.html_url || release.url);
|
||||||
|
} else {
|
||||||
|
const errorText = await existing.text();
|
||||||
|
throw new Error(
|
||||||
|
`Failed to check release: ${existing.status} - ${errorText}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return release;
|
||||||
|
};
|
||||||
|
|
||||||
|
const release = await createOrUpdateRelease();
|
||||||
|
|
||||||
|
if (release) {
|
||||||
|
console.log(
|
||||||
|
`Release with tag ${tagName} already exists. Updating release...`
|
||||||
|
);
|
||||||
|
// Optionally update release body or assets here instead of creating a new release
|
||||||
|
return release;
|
||||||
|
}
|
||||||
|
|
||||||
// 1) Generate or update CHANGELOG.md using conventional-changelog CLI
|
// 1) Generate or update CHANGELOG.md using conventional-changelog CLI
|
||||||
console.log("Generating CHANGELOG.md...");
|
console.log("Generating CHANGELOG.md...");
|
||||||
const result = spawnSync(
|
const result = spawnSync(
|
||||||
|
|||||||
Reference in New Issue
Block a user