-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: migrate fusion app management v2 pipelines (#1165)
- Loading branch information
1 parent
65480d7
commit 1ce2cf7
Showing
8 changed files
with
76 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { HttpClient } from '@actions/http-client'; | ||
|
||
// We do not use semver and dont want to manually bump versions. | ||
// For now we ask the server what the latest version is and bump the patch version | ||
export async function getVersion(ciUrl: string, token: string, name: string) { | ||
const client = new HttpClient(); | ||
const response = await client.get(`${ciUrl}/apps/${name}?api-version=1.0`, { | ||
['Authorization']: `Bearer ${token}`, | ||
}); | ||
const body = await response.readBody(); | ||
const json = JSON.parse(body); | ||
const v = incrementPatchVersion(json.build.version); | ||
return v; | ||
} | ||
|
||
function incrementPatchVersion(semver: string) { | ||
const parts = semver.split('.'); | ||
if (parts.length !== 3) { | ||
throw new Error('Invalid semver format: ' + semver); | ||
} | ||
const patch = parseInt(parts[2], 10) + 1; | ||
return `${parts[0]}.${parts[1]}.${patch}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,24 @@ | ||
import { parsePackageJson } from './parsePackageJson.js'; | ||
import fs from 'fs'; | ||
import { notice } from '@actions/core'; | ||
|
||
export function makeManifest(path: string) { | ||
export function makeManifest(path: string, version: string, sha: string) { | ||
// Create manifest | ||
notice('making manifest'); | ||
const { version, name, ...maybe } = parsePackageJson(path); | ||
const { name } = parsePackageJson(path); | ||
if (!version || !name) { | ||
throw new Error('Name or version missing in package.json'); | ||
} | ||
const { major, minor, patch } = splitVersions(version); | ||
|
||
/** Some app-manifests have custom short and displaynames */ | ||
const shortName = maybe?.['shortName'] ?? name; | ||
const displayName = maybe?.['displayName'] ?? name[0].toUpperCase() + name.slice(1); | ||
|
||
const manifest = { | ||
name: displayName, | ||
shortName: shortName, | ||
key: name, | ||
version: { | ||
major: major, | ||
minor: minor, | ||
patch: patch, | ||
}, | ||
//required | ||
entryPoint: "app-bundle.js", | ||
//required | ||
version: version, | ||
githubRepo: "https://github.com/equinor/cc-components", | ||
timestamp: new Date().toISOString(), | ||
commitSha: sha, | ||
}; | ||
|
||
const data = JSON.stringify(manifest, null, 2); | ||
|
||
fs.writeFileSync('./dist/app-manifest.json', data); | ||
} | ||
|
||
function splitVersions(version: string) { | ||
const [major, minor, patch] = version.split('.'); | ||
return { | ||
major, | ||
minor, | ||
patch, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters