-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundle GCM on macOS and Linux #510
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,21 @@ | ||
import { createHash } from 'crypto' | ||
|
||
export async function fetchAssetChecksum(uri: string) { | ||
const hs = createHash('sha256') | ||
|
||
const headers = { | ||
'User-Agent': 'dugite-native', | ||
accept: 'application/octet-stream', | ||
} | ||
|
||
await fetch(uri, { headers }) | ||
.then(x => | ||
x.ok | ||
? Promise.resolve(x) | ||
: Promise.reject(new Error(`Server responded with ${x.status}`)) | ||
) | ||
.then(x => x.arrayBuffer()) | ||
.then(x => hs.end(Buffer.from(x))) | ||
|
||
return hs.digest('hex') | ||
} |
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,81 @@ | ||
import { Octokit } from '@octokit/rest' | ||
import { updateGitCredentialManagerDependencies } from './lib/dependencies' | ||
import { fetchAssetChecksum } from './fetch-asset-checksum' | ||
|
||
process.on('unhandledRejection', reason => { | ||
console.error(reason) | ||
}) | ||
|
||
async function run(): Promise<boolean> { | ||
const token = process.env.GITHUB_ACCESS_TOKEN | ||
if (token == null) { | ||
console.log(`🔴 No GITHUB_ACCESS_TOKEN environment variable set`) | ||
return false | ||
} | ||
|
||
const octokit = new Octokit({ auth: `token ${token}` }) | ||
|
||
const user = await octokit.users.getAuthenticated({}) | ||
const me = user.data.login | ||
|
||
console.log(`✅ Token found for ${me}`) | ||
|
||
const owner = 'git-ecosystem' | ||
const repo = 'git-credential-manager' | ||
|
||
const release = await octokit.repos.getLatestRelease({ owner, repo }) | ||
|
||
const { tag_name, id } = release.data | ||
const version = tag_name.replace(/^v/, '') | ||
|
||
console.log(`✅ Newest git-credential-manager release '${version}'`) | ||
|
||
const assets = await octokit.repos.listReleaseAssets({ | ||
owner, | ||
repo, | ||
release_id: id, | ||
}) | ||
|
||
const fileTemplates = [ | ||
{ | ||
name: `gcm-linux_amd64.${version}.tar.gz`, | ||
platform: 'linux', | ||
arch: 'amd64', | ||
}, | ||
{ | ||
name: `gcm-osx-arm64-${version}.tar.gz`, | ||
platform: 'darwin', | ||
arch: 'arm64', | ||
}, | ||
{ | ||
name: `gcm-osx-x64-${version}.tar.gz`, | ||
platform: 'darwin', | ||
arch: 'amd64', | ||
}, | ||
] | ||
|
||
const files = [] | ||
|
||
for (const ft of fileTemplates) { | ||
const asset = assets.data.find(a => a.name === ft.name) | ||
|
||
if (!asset) { | ||
throw new Error(`Could not find asset for file: ${ft.name}`) | ||
} | ||
|
||
const url = asset.browser_download_url | ||
console.log(`⏳ Fetching checksum for ${ft.name}`) | ||
const checksum = await fetchAssetChecksum(url) | ||
console.log(`🔑 ${checksum}`) | ||
files.push({ ...ft, url, checksum }) | ||
} | ||
|
||
updateGitCredentialManagerDependencies(version, files) | ||
|
||
console.log( | ||
`✅ Updated dependencies metadata to Git credential manager '${version}'` | ||
) | ||
return true | ||
} | ||
|
||
run().then(success => process.exit(success ? 0 : 1)) |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the file should be sheeile=d by discounted reciprotol matrix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the file.name should be sheilded