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
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 }}
|
container: ${{ matrix.container }}
|
||||||
outputs:
|
outputs:
|
||||||
built: ${{ steps.build.outputs.pkgs }}
|
built: ${{ steps.build.outputs.pkgs }}
|
||||||
|
srcs: ${{ steps.build.outputs.srcs }}
|
||||||
pkgs: ${{ steps.sorted.outputs.pkgs }} ${{ steps.sorted.outputs.pre-install }}
|
pkgs: ${{ steps.sorted.outputs.pkgs }} ${{ steps.sorted.outputs.pre-install }}
|
||||||
steps:
|
steps:
|
||||||
- name: co pantry
|
- name: co pantry
|
||||||
|
@ -97,7 +98,7 @@ jobs:
|
||||||
|
|
||||||
# tarring ourselves ∵ GHA-artifacts (ludicrously) lose permissions
|
# tarring ourselves ∵ GHA-artifacts (ludicrously) lose permissions
|
||||||
# /ref https://github.com/actions/upload-artifact/issues/38
|
# /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 }}
|
working-directory: ${{ steps.tea.outputs.prefix }}
|
||||||
|
|
||||||
- name: upload artifacts
|
- name: upload artifacts
|
||||||
|
@ -202,6 +203,7 @@ jobs:
|
||||||
id: upload
|
id: upload
|
||||||
run: ./upload.ts
|
run: ./upload.ts
|
||||||
--pkgs ${{ needs.build.outputs.built }}
|
--pkgs ${{ needs.build.outputs.built }}
|
||||||
|
--srcs ${{ needs.build.outputs.srcs }}
|
||||||
--bottles ${{ steps.bottle.outputs.bottles }}
|
--bottles ${{ steps.bottle.outputs.bottles }}
|
||||||
--checksums ${{ steps.bottle.outputs.checksums }}
|
--checksums ${{ steps.bottle.outputs.checksums }}
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -65,7 +65,7 @@ export async function bottle({ path: kegdir, pkg }: Installation, compression: '
|
||||||
return tarball
|
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 })
|
return await Deno.open(file.string, { read: true })
|
||||||
.then(file => crypto.subtle.digest("SHA-256", file.readable))
|
.then(file => crypto.subtle.digest("SHA-256", file.readable))
|
||||||
.then(buf => new TextDecoder().decode(encode(new Uint8Array(buf))))
|
.then(buf => new TextDecoder().decode(encode(new Uint8Array(buf))))
|
||||||
|
|
|
@ -16,13 +16,14 @@ args:
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
import { usePantry } from "hooks"
|
import { useCache, usePantry } from "hooks"
|
||||||
import { Installation } from "types"
|
import { Installation } from "types"
|
||||||
import { pkg as pkgutils } from "utils"
|
import { pkg as pkgutils } from "utils"
|
||||||
import { useFlags, usePrefix } from "hooks"
|
import { useFlags, usePrefix } from "hooks"
|
||||||
import { set_output } from "./utils/gha.ts"
|
import { set_output } from "./utils/gha.ts"
|
||||||
import build from "./build/build.ts"
|
import build from "./build/build.ts"
|
||||||
import * as ARGV from "./utils/args.ts"
|
import * as ARGV from "./utils/args.ts"
|
||||||
|
import Path from "path"
|
||||||
|
|
||||||
useFlags()
|
useFlags()
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ const pantry = usePantry()
|
||||||
const dry = await ARGV.toArray(ARGV.pkgs())
|
const dry = await ARGV.toArray(ARGV.pkgs())
|
||||||
const gha = !!Deno.env.get("GITHUB_ACTIONS")
|
const gha = !!Deno.env.get("GITHUB_ACTIONS")
|
||||||
const group_it = gha && dry.length > 1
|
const group_it = gha && dry.length > 1
|
||||||
const rv: Installation[] = []
|
const rv: InstallationPlus[] = []
|
||||||
|
|
||||||
if (usePrefix().string != "/opt") {
|
if (usePrefix().string != "/opt") {
|
||||||
console.error({ TEA_PREFIX: usePrefix().string })
|
console.error({ TEA_PREFIX: usePrefix().string })
|
||||||
|
@ -47,7 +48,10 @@ for (const rq of dry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const install = await build(pkg)
|
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) {
|
if (group_it) {
|
||||||
console.log("::endgroup::")
|
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("pkgs", rv.map(x => pkgutils.str(x.pkg)))
|
||||||
await set_output("paths", rv.map(x => x.path), '%0A')
|
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("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 {
|
function produceMatrix(objects: FileInfo[]): void {
|
||||||
const matrix = new Map()
|
const matrix = new Map()
|
||||||
for (const { key, lastModified } of objects) {
|
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 flavor = `${_platform}/${_arch}`
|
||||||
const version = semver.parse(_v)
|
const version = semver.parse(_v)
|
||||||
if (!version) continue
|
if (!version) continue
|
||||||
|
|
|
@ -12,12 +12,13 @@ args:
|
||||||
|
|
||||||
import { S3 } from "s3"
|
import { S3 } from "s3"
|
||||||
import { pkg as pkgutils } from "utils"
|
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 { Package, PackageRequirement } from "types"
|
||||||
import SemVer, * as semver from "semver"
|
import SemVer, * as semver from "semver"
|
||||||
import { dirname, basename } from "deno/path/mod.ts"
|
import { dirname, basename } from "deno/path/mod.ts"
|
||||||
import Path from "path"
|
import Path from "path"
|
||||||
import { set_output } from "./utils/gha.ts"
|
import { set_output } from "./utils/gha.ts"
|
||||||
|
import { sha256 } from "./bottle.ts"
|
||||||
|
|
||||||
useFlags()
|
useFlags()
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ const encode = (() => { const e = new TextEncoder(); return e.encode.bind(e) })(
|
||||||
const cache = useCache()
|
const cache = useCache()
|
||||||
|
|
||||||
const pkgs = args_get("pkgs").map(pkgutils.parse).map(assert_pkg)
|
const pkgs = args_get("pkgs").map(pkgutils.parse).map(assert_pkg)
|
||||||
|
const srcs = args_get("srcs")
|
||||||
const bottles = args_get("bottles")
|
const bottles = args_get("bottles")
|
||||||
const checksums = args_get("checksums")
|
const checksums = args_get("checksums")
|
||||||
|
|
||||||
|
@ -77,6 +79,19 @@ for (const [index, pkg] of pkgs.entries()) {
|
||||||
await put(key, bottle)
|
await put(key, bottle)
|
||||||
await put(`${key}.sha256sum`, `${checksum} ${basename(key)}`)
|
await put(`${key}.sha256sum`, `${checksum} ${basename(key)}`)
|
||||||
await put(`${dirname(key)}/versions.txt`, versions.join("\n"))
|
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)
|
await set_output('cf-invalidation-paths', rv)
|
||||||
|
|
Loading…
Reference in a new issue