-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): fix sha acquisiton for windows signing (#1031)
<!-- For Coveo Employees only. Fill this section. CDX-1230 --> ## Proposed changes Similar problem and similar fix as #988 ## Testing - [x] Manual Tests: Replicated file tree and ran the script. Assessed the hash was there and complete
- Loading branch information
1 parent
7efb42d
commit dcc3131
Showing
4 changed files
with
30 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import {exportVariable, setFailed} from '@actions/core'; | ||
import {getSHA1fromRef} from '@coveo/semantic-monorepo-tools'; | ||
import {readdirSync} from 'node:fs'; | ||
import {join} from 'node:path'; | ||
import {binariesMatcher} from './oclifArtifactMatchers.mjs'; | ||
|
||
const getCommitShortHash = async () => | ||
(await getSHA1fromRef('HEAD')).substring(0, 7); | ||
// Should be executed at the root of the CLI workspace. | ||
const pathToArtifacts = join('dist', process.platform); | ||
const artifacts = readdirSync(pathToArtifacts, {withFileTypes: true}); | ||
const someExe = artifacts.find( | ||
(candidate) => candidate.isFile() && candidate.name.endsWith('.exe') | ||
); | ||
|
||
(async () => { | ||
try { | ||
const commitShortHash = await getCommitShortHash(); | ||
exportVariable('commitSHA1', commitShortHash); | ||
} catch (error) { | ||
setFailed(error.message); | ||
} | ||
})(); | ||
if (!binariesMatcher.exec(someExe.name)?.groups?.commitSHA) { | ||
setFailed('Binary does not match'); | ||
} | ||
exportVariable( | ||
'commitSHA1', | ||
binariesMatcher.exec(someExe.name).groups.commitSHA | ||
); |
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,6 @@ | ||
export const binariesMatcher = | ||
/^coveo[_-]{1}(?<version>v?\d+\.\d+\.\d+(-\d+)?)[_.-]{1}(?<commitSHA>\w+)[_-]?(\d+_)?(?<longExt>.*\.(exe|deb|pkg))$/; | ||
export const manifestMatcher = | ||
/^coveo-(?<version>v?\d+\.\d+\.\d+(-\d+)?)-(?<commitSHA>\w+)-(?<targetSignature>.*-buildmanifest)$/; | ||
export const tarballMatcher = | ||
/^coveo-v?(?<version>\d+\.\d+\.\d+(-\d+)?)-(?<commitSHA>\w+)-(?<targetSignature>[\w-]+).tar\.[gx]z$/; |