fix: tag script issues

This commit is contained in:
Eli Bosley
2023-08-31 16:13:07 -04:00
parent ee0293eaae
commit c270e86377
4 changed files with 12 additions and 10 deletions
+1 -1
View File
@@ -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
+2 -1
View File
@@ -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
+8 -7
View File
@@ -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
View File
@@ -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}"`