Files
api/plugin/builder/utils/bucket-urls.ts
Pujit Mehrotra 3cfe9fe9ee build: replace hash with build increment in slackware txz pkg (#1449)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Introduced support for specifying and propagating a build number
throughout the build process, including command-line options and
workflow inputs.
* TXZ package naming and URLs now include the build number for improved
traceability.

* **Improvements**
* Enhanced robustness in locating TXZ files with improved fallback
logic, especially in CI environments.
* Improved flexibility and validation of environment schema for plugin
builds.

* **Style**
  * Minor formatting corrections for consistency and readability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1210677942019563
2025-07-01 10:57:39 -04:00

56 lines
1.6 KiB
TypeScript

import {
getTxzName,
LOCAL_BUILD_TAG,
pluginNameWithExt,
defaultArch,
defaultBuild,
TxzNameParams,
} from "./consts";
// Define a common interface for URL parameters
interface UrlParams {
baseUrl: string;
tag?: string;
}
interface TxzUrlParams extends UrlParams, TxzNameParams {}
/**
* Get the bucket path for the given tag
* ex. baseUrl = https://stable.dl.unraid.net/unraid-api
* ex. tag = PR123
* ex. returns = https://stable.dl.unraid.net/unraid-api/tag/PR123
*/
const getRootBucketPath = ({ baseUrl, tag }: UrlParams): URL => {
// Append tag to the baseUrl if tag is set, otherwise return the baseUrl
const url = new URL(baseUrl);
if (tag && tag !== LOCAL_BUILD_TAG) {
// Ensure the path ends with a trailing slash before adding the tag
url.pathname = url.pathname.replace(/\/?$/, "/") + "tag/" + tag;
}
return url;
};
/**
* Get the URL for an asset from the root bucket
* ex. returns = BASE_URL/TAG/dynamix.unraid.net.plg
*/
export const getAssetUrl = (params: UrlParams, assetName: string): string => {
const rootUrl = getRootBucketPath(params);
rootUrl.pathname = rootUrl.pathname.replace(/\/?$/, "/") + assetName;
return rootUrl.toString();
};
/**
* Get the URL for the plugin file
* ex. returns = BASE_URL/TAG/dynamix.unraid.net.plg
*/
export const getPluginUrl = (params: UrlParams): string =>
getAssetUrl(params, pluginNameWithExt);
/**
* Get the URL for the main TXZ file
* ex. returns = BASE_URL/TAG/dynamix.unraid.net-4.1.3-x86_64-1.txz
*/
export const getMainTxzUrl = (params: TxzUrlParams): string =>
getAssetUrl(params, getTxzName(params));