-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename to hnc and remove tiny-keccak (#9)
- Loading branch information
Showing
29 changed files
with
1,029 additions
and
557 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
module.exports = async ({github, context}, tagName) => { | ||
try { | ||
await github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `refs/tags/${tagName}`, | ||
sha: context.sha, | ||
force: true | ||
}) | ||
} catch (err) { | ||
console.error(`Failed to create tag: ${tagName}`) | ||
console.error(err) | ||
} | ||
} | ||
// From https://github.com/foundry-rs/foundry/ | ||
module.exports = async ({ github, context }, tagName) => { | ||
try { | ||
await github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `refs/tags/${tagName}`, | ||
sha: context.sha, | ||
force: true, | ||
}); | ||
} catch (err) { | ||
console.error(`Failed to create tag: ${tagName}`); | ||
console.error(err); | ||
} | ||
}; |
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,15 +1,16 @@ | ||
module.exports = async ({github, context}, tagName) => { | ||
try { | ||
await github.rest.git.updateRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `tags/${tagName}`, | ||
sha: context.sha, | ||
force: true | ||
}) | ||
} catch (err) { | ||
console.error(`Failed to move nightly tag.`) | ||
console.error(`This should only happen the first time.`) | ||
console.error(err) | ||
} | ||
} | ||
// From https://github.com/foundry-rs | ||
module.exports = async ({ github, context }, tagName) => { | ||
try { | ||
await github.rest.git.updateRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `tags/${tagName}`, | ||
sha: context.sha, | ||
force: true, | ||
}); | ||
} catch (err) { | ||
console.error(`Failed to move nightly tag.`); | ||
console.error(`This should only happen the first time.`); | ||
console.error(err); | ||
} | ||
}; |
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,33 +1,69 @@ | ||
module.exports = async ({github, context}) => { | ||
console.log('Pruning old prereleases') | ||
|
||
const { data: releases } = await github.rest.repos.listReleases({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}) | ||
|
||
// Only consider releases tagged `nightly-${SHA}` for deletion | ||
let nightlies = releases.filter( | ||
(release) => release.tag_name.includes('nightly') && release.tag_name !== 'nightly' | ||
) | ||
|
||
// Keep newest 3 nightlies | ||
nightlies = nightlies.slice(3) | ||
|
||
for (const nightly of nightlies) { | ||
console.log(`Deleting nightly: ${nightly.tag_name}`) | ||
await github.rest.repos.deleteRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: nightly.id | ||
}) | ||
console.log(`Deleting nightly tag: ${nightly.tag_name}`) | ||
await github.rest.git.deleteRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `tags/${nightly.tag_name}` | ||
}) | ||
} | ||
|
||
console.log('Done.') | ||
} | ||
// From https://github.com/foundry-rs | ||
// In case node 21 is not used. | ||
function groupBy(array, keyOrIterator) { | ||
var iterator; | ||
|
||
// use the function passed in, or create one | ||
if(typeof keyOrIterator !== 'function') { | ||
const key = String(keyOrIterator); | ||
iterator = function (item) { return item[key]; }; | ||
} else { | ||
iterator = keyOrIterator; | ||
} | ||
|
||
return array.reduce(function (memo, item) { | ||
const key = iterator(item); | ||
memo[key] = memo[key] || []; | ||
memo[key].push(item); | ||
return memo; | ||
}, {}); | ||
} | ||
|
||
module.exports = async ({ github, context }) => { | ||
console.log("Pruning old prereleases"); | ||
|
||
// doc: https://docs.github.com/en/rest/releases/releases | ||
const { data: releases } = await github.rest.repos.listReleases({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
|
||
let nightlies = releases.filter( | ||
release => | ||
// Only consider releases tagged `nightly-${SHA}` for deletion | ||
release.tag_name.includes("nightly") && | ||
release.tag_name !== "nightly" | ||
); | ||
|
||
// Pruning rules: | ||
// 1. only keep the earliest (by created_at) release of the month | ||
// 2. to keep the newest 30 nightlies (to make sure nightlies are kept until the next monthly release) | ||
// Notes: | ||
// - This addresses https://github.com/foundry-rs/foundry/issues/6732 | ||
// - Name of the release may deviate from created_at due to the usage of different timezones. | ||
|
||
// Group releases by months. | ||
// Per doc: | ||
// > The latest release is the most recent non-prerelease, non-draft release, sorted by the created_at attribute. | ||
const groups = groupBy(nightlies, i => i.created_at.slice(0, 7)); | ||
const nightliesToPrune = Object.values(groups) | ||
.reduce((acc, cur) => acc.concat(cur.slice(0, -1)), []) // rule 1 | ||
.slice(30); // rule 2 | ||
|
||
for (const nightly of nightliesToPrune) { | ||
console.log(`Deleting nightly: ${nightly.tag_name}`); | ||
await github.rest.repos.deleteRelease({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
release_id: nightly.id, | ||
}); | ||
console.log(`Deleting nightly tag: ${nightly.tag_name}`); | ||
await github.rest.git.deleteRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: `tags/${nightly.tag_name}`, | ||
}); | ||
} | ||
|
||
console.log("Done."); | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.