mirror of
https://github.com/ivabus/pantry
synced 2024-11-26 18:25:08 +03:00
store sources from build pipeline
Use relative-path srcs only
This commit is contained in:
parent
22dcff66c7
commit
6277d70bba
4 changed files with 32 additions and 6 deletions
|
@ -65,7 +65,7 @@ export async function bottle({ path: kegdir, pkg }: Installation, compression: '
|
|||
return tarball
|
||||
}
|
||||
|
||||
async function sha256(file: Path): Promise<string> {
|
||||
export async function sha256(file: Path): Promise<string> {
|
||||
return await Deno.open(file.string, { read: true })
|
||||
.then(file => crypto.subtle.digest("SHA-256", file.readable))
|
||||
.then(buf => new TextDecoder().decode(encode(new Uint8Array(buf))))
|
||||
|
|
|
@ -16,13 +16,14 @@ args:
|
|||
- --import-map={{ srcroot }}/import-map.json
|
||||
---*/
|
||||
|
||||
import { usePantry } from "hooks"
|
||||
import { useCache, usePantry } from "hooks"
|
||||
import { Installation } from "types"
|
||||
import { pkg as pkgutils } from "utils"
|
||||
import { useFlags, usePrefix } from "hooks"
|
||||
import { set_output } from "./utils/gha.ts"
|
||||
import build from "./build/build.ts"
|
||||
import * as ARGV from "./utils/args.ts"
|
||||
import Path from "path"
|
||||
|
||||
useFlags()
|
||||
|
||||
|
@ -30,7 +31,7 @@ const pantry = usePantry()
|
|||
const dry = await ARGV.toArray(ARGV.pkgs())
|
||||
const gha = !!Deno.env.get("GITHUB_ACTIONS")
|
||||
const group_it = gha && dry.length > 1
|
||||
const rv: Installation[] = []
|
||||
const rv: InstallationPlus[] = []
|
||||
|
||||
if (usePrefix().string != "/opt") {
|
||||
console.error({ TEA_PREFIX: usePrefix().string })
|
||||
|
@ -47,7 +48,10 @@ for (const rq of dry) {
|
|||
}
|
||||
|
||||
const install = await build(pkg)
|
||||
rv.push(install)
|
||||
const { url } = await pantry.getDistributable(pkg)
|
||||
const extname = url.path().extname()
|
||||
const src = useCache().path({ pkg, type: "src", extname })
|
||||
rv.push({...install, src })
|
||||
|
||||
if (group_it) {
|
||||
console.log("::endgroup::")
|
||||
|
@ -57,3 +61,8 @@ for (const rq of dry) {
|
|||
await set_output("pkgs", rv.map(x => pkgutils.str(x.pkg)))
|
||||
await set_output("paths", rv.map(x => x.path), '%0A')
|
||||
await set_output("relative-paths", rv.map(x => x.path.relative({ to: usePrefix() })))
|
||||
await set_output("srcs", rv.map(x => x.src.relative({ to: usePrefix() })))
|
||||
|
||||
interface InstallationPlus extends Installation {
|
||||
src: Path
|
||||
}
|
|
@ -56,7 +56,9 @@ interface FileInfo {
|
|||
function produceMatrix(objects: FileInfo[]): void {
|
||||
const matrix = new Map()
|
||||
for (const { key, lastModified } of objects) {
|
||||
const [_, project, _platform, _arch, _v] = key.match(new RegExp("(.*)/(darwin|linux)/(aarch64|x86-64)/v(.*)\.tar\.(x|g)z"))!
|
||||
const match = key.match(new RegExp("(.*)/(darwin|linux)/(aarch64|x86-64)/v(.*)\.tar\.(x|g)z"))
|
||||
if (!match) continue
|
||||
const [_, project, _platform, _arch, _v] = match
|
||||
const flavor = `${_platform}/${_arch}`
|
||||
const version = semver.parse(_v)
|
||||
if (!version) continue
|
||||
|
|
|
@ -12,12 +12,13 @@ args:
|
|||
|
||||
import { S3 } from "s3"
|
||||
import { pkg as pkgutils } from "utils"
|
||||
import { useFlags, useOffLicense, useCache } from "hooks"
|
||||
import { useFlags, useOffLicense, useCache, usePrefix } from "hooks"
|
||||
import { Package, PackageRequirement } from "types"
|
||||
import SemVer, * as semver from "semver"
|
||||
import { dirname, basename } from "deno/path/mod.ts"
|
||||
import Path from "path"
|
||||
import { set_output } from "./utils/gha.ts"
|
||||
import { sha256 } from "./bottle.ts"
|
||||
|
||||
useFlags()
|
||||
|
||||
|
@ -34,6 +35,7 @@ const encode = (() => { const e = new TextEncoder(); return e.encode.bind(e) })(
|
|||
const cache = useCache()
|
||||
|
||||
const pkgs = args_get("pkgs").map(pkgutils.parse).map(assert_pkg)
|
||||
const srcs = args_get("srcs")
|
||||
const bottles = args_get("bottles")
|
||||
const checksums = args_get("checksums")
|
||||
|
||||
|
@ -77,6 +79,19 @@ for (const [index, pkg] of pkgs.entries()) {
|
|||
await put(key, bottle)
|
||||
await put(`${key}.sha256sum`, `${checksum} ${basename(key)}`)
|
||||
await put(`${dirname(key)}/versions.txt`, versions.join("\n"))
|
||||
|
||||
// Store sources
|
||||
const src = usePrefix().join(srcs[index])
|
||||
const srcKey = useOffLicense('s3').key({
|
||||
pkg: stowed.pkg,
|
||||
type: "src",
|
||||
extname: src.extname()
|
||||
})
|
||||
const srcChecksum = await sha256(src)
|
||||
const srcVersions = await get_versions(srcKey, pkg)
|
||||
await put(srcKey, src)
|
||||
await put(`${srcKey}.sha256sum`, `${srcChecksum} ${basename(srcKey)}`)
|
||||
await put(`${dirname(srcKey)}/versions.txt`, srcVersions.join("\n"))
|
||||
}
|
||||
|
||||
await set_output('cf-invalidation-paths', rv)
|
||||
|
|
Loading…
Reference in a new issue