mirror of
https://github.com/ivabus/pantry
synced 2024-11-23 00:45:07 +03:00
store sources from build pipeline
Use relative-path srcs only
This commit is contained in:
parent
cd7aac3dc2
commit
a9d7965089
5 changed files with 35 additions and 7 deletions
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
|
@ -37,6 +37,7 @@ jobs:
|
|||
container: ${{ matrix.container }}
|
||||
outputs:
|
||||
built: ${{ steps.build.outputs.pkgs }}
|
||||
srcs: ${{ steps.build.outputs.srcs }}
|
||||
pkgs: ${{ steps.sorted.outputs.pkgs }} ${{ steps.sorted.outputs.pre-install }}
|
||||
steps:
|
||||
- name: co pantry
|
||||
|
@ -97,7 +98,7 @@ jobs:
|
|||
|
||||
# tarring ourselves ∵ GHA-artifacts (ludicrously) lose permissions
|
||||
# /ref https://github.com/actions/upload-artifact/issues/38
|
||||
- run: tar czf $GITHUB_WORKSPACE/artifacts.tgz ${{ steps.build.outputs.relative-paths }}
|
||||
- run: tar czf $GITHUB_WORKSPACE/artifacts.tgz ${{ steps.build.outputs.relative-paths }} ${{ steps.build.outputs.srcs }}
|
||||
working-directory: ${{ steps.tea.outputs.prefix }}
|
||||
|
||||
- name: upload artifacts
|
||||
|
@ -202,6 +203,7 @@ jobs:
|
|||
id: upload
|
||||
run: ./upload.ts
|
||||
--pkgs ${{ needs.build.outputs.built }}
|
||||
--srcs ${{ needs.build.outputs.srcs }}
|
||||
--bottles ${{ steps.bottle.outputs.bottles }}
|
||||
--checksums ${{ steps.bottle.outputs.checksums }}
|
||||
env:
|
||||
|
|
|
@ -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