Skip to content

Commit

Permalink
Rename to hnc and remove tiny-keccak (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
cakevm authored Jan 9, 2025
1 parent 0175e90 commit 2eea578
Show file tree
Hide file tree
Showing 29 changed files with 1,029 additions and 557 deletions.
29 changes: 15 additions & 14 deletions .github/scripts/create-tag.js
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);
}
};
31 changes: 16 additions & 15 deletions .github/scripts/move-tag.js
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);
}
};
102 changes: 69 additions & 33 deletions .github/scripts/prune-prereleases.js
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.");
};
76 changes: 0 additions & 76 deletions .github/workflows/docker-publish.yaml

This file was deleted.

Loading

0 comments on commit 2eea578

Please sign in to comment.