mirror of
https://github.com/unraid/api.git
synced 2026-05-01 12:39:22 -05:00
fix: tag script issues
This commit is contained in:
@@ -150,7 +150,7 @@ jobs:
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Run Docker Compose
|
||||
run: docker run -e GIT_SHA=$(git rev-parse --short HEAD) -e IS_TAGGED=$(git describe --tags --abbrev=0 --exact-match) localhost:5000/unraid-api:builder npm run build-pkg
|
||||
run: docker run -e GIT_SHA=$(git rev-parse --short HEAD) -e IS_TAGGED=$(git describe --tags --abbrev=0 --exact-match) -v $(pwd)/deploy:/app/deploy/ localhost:5000/unraid-api:builder npm run build-pkg
|
||||
|
||||
|
||||
- name: Set Hashes
|
||||
|
||||
@@ -36,11 +36,12 @@ try {
|
||||
assert: { type: 'json' },
|
||||
}).then(pkg => pkg.default);
|
||||
|
||||
const tags = getTags();
|
||||
const tags = getTags(process.env);
|
||||
|
||||
// Decide whether to use full version or just tag
|
||||
const isTaggedRelease = tags.isTagged;
|
||||
const gitShaShort = tags.shortSha;
|
||||
|
||||
const deploymentVersion = isTaggedRelease ? version : `${version}+${gitShaShort}`;
|
||||
|
||||
// Create deployment package.json
|
||||
|
||||
@@ -9,19 +9,20 @@ const runCommand = (command) => {
|
||||
}
|
||||
};
|
||||
|
||||
const getTags = () => {
|
||||
const GIT_SHA_ENV = process.env.GIT_SHA
|
||||
const IS_TAGGED_ENV = Boolean(process.env.IS_TAGGED);
|
||||
if (GIT_SHA_ENV && IS_TAGGED_ENV) {
|
||||
console.log('GIT_SHA_ENV', GIT_SHA_ENV, 'IS_TAGGED_ENV', IS_TAGGED_ENV);
|
||||
const getTags = (env = process.env) => {
|
||||
|
||||
if (env.GIT_SHA) {
|
||||
return {
|
||||
shortSha: GIT_SHA_ENV,
|
||||
isTagged: IS_TAGGED_ENV
|
||||
shortSha: env.GIT_SHA,
|
||||
isTagged: Boolean(env.IS_TAGGED)
|
||||
}
|
||||
} else {
|
||||
const gitShortSHA = runCommand('git rev-parse --short HEAD');
|
||||
const isCommitTagged = runCommand('git describe --tags --abbrev=0 --exact-match') !== undefined;
|
||||
console.log('gitShortSHA', gitShortSHA, 'isCommitTagged', isCommitTagged);
|
||||
if (!gitShortSHA) {
|
||||
throw new Error('Failing build due to missing SHA');
|
||||
}
|
||||
return {
|
||||
shortSha: gitShortSHA,
|
||||
isTagged: isCommitTagged
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ export default defineConfig({
|
||||
esbuildOptions(options) {
|
||||
if (!options.define) options.define = {};
|
||||
|
||||
const tags = getTags();
|
||||
const tags = getTags(process.env);
|
||||
|
||||
options.define['process.env.VERSION'] = tags.isTagged
|
||||
? `"${version}"`
|
||||
|
||||
Reference in New Issue
Block a user