ci: Abstract artifact uploads for every bake target.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-05-29 11:13:01 +00:00
parent 87d258b83c
commit 864ac84679
4 changed files with 85 additions and 102 deletions

View File

@@ -51,10 +51,14 @@ on:
type: string
default: ${{vars.CI_PRINT_BAKE || false}}
description: Print the computed receipe.
artifact:
type: string
default: '{}'
description: Map of targets to artifact files to upload
jobs:
bake:
if: ${{fromJSON(inputs.machines)[0] != null}}
if: ${{ !failure() && !cancelled() && fromJSON(inputs.machines)[0] != null }}
name: >
${{matrix.bake_target}}
${{matrix.cargo_profile}}
@@ -104,3 +108,23 @@ jobs:
run: |
docker/bake.sh "${{matrix.bake_target}}"
- if: ${{ !failure() && !cancelled() && fromJSON(inputs.artifact)[matrix.bake_target].dst }}
name: Extract Artifact
env:
iid: ${{matrix.bake_target}}--${{matrix.cargo_profile}}--${{matrix.rust_toolchain}}--${{matrix.rust_target}}--${{matrix.feat_set}}--${{matrix.sys_name}}--${{matrix.sys_version}}--${{matrix.sys_target}}
dst: ${{ fromJSON(inputs.artifact)[matrix.bake_target].dst }}
src: ${{ fromJSON(inputs.artifact)[matrix.bake_target].src || fromJSON(inputs.artifact)[matrix.bake_target].dst }}
run: |
cid=$(docker create "$iid" /)
rm -rf _artifact
mkdir -p _artifact
docker cp "$cid:$src" "_artifact/$dst"
- if: ${{ !failure() && !cancelled() && fromJSON(inputs.artifact)[matrix.bake_target].dst }}
name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{matrix.cargo_profile}}-${{fromJSON(inputs.artifact)[matrix.bake_target].dst}}
path: _artifact/${{fromJSON(inputs.artifact)[matrix.bake_target].dst}}

View File

@@ -145,8 +145,9 @@ jobs:
machines: ${{needs.init.outputs.machines}}
excludes: >
[
{"cargo_profile": "test"},
{"feat_set": "none"},
{"cargo_profile": "test"},
{"cargo_profile": "release", "rust_toolchain": "nightly"},
{"cargo_profile": "release-max-perf", "rust_toolchain": "stable"}
]

View File

@@ -38,53 +38,7 @@ on:
description: Matrix inclusions
jobs:
deb:
if: >
${{
!failure() && !cancelled()
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["release"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["stable"]')[0])
}}
name: Deb
uses: ./.github/workflows/bake.yml
with:
bake_targets: '["pkg-deb"]'
cargo_profiles: '["release"]'
feat_sets: '["all"]'
rust_toolchains: '["stable"]'
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
rpm:
if: >
${{
!failure() && !cancelled()
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["release"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["stable"]')[0])
}}
name: RPM
uses: ./.github/workflows/bake.yml
with:
bake_targets: '["pkg-rpm"]'
cargo_profiles: '["release"]'
feat_sets: '["all"]'
rust_toolchains: '["stable"]'
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
static:
build_standalone:
if: >
${{
!failure() && !cancelled()
@@ -104,3 +58,60 @@ jobs:
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
artifact: >
{
"standalone": {"dst": "tuwunel"}
}
build_pkgs:
if: >
${{
!failure() && !cancelled()
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["release"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["stable"]')[0])
}}
name: Build Pkgs
uses: ./.github/workflows/bake.yml
with:
bake_targets: '["pkg-deb", "pkg-rpm"]'
cargo_profiles: '["release"]'
feat_sets: '["all"]'
rust_toolchains: '["stable"]'
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}
artifact: >
{
"pkg-deb": {"dst": "tuwunel_1.0.0-1_amd64.deb"},
"pkg-rpm": {"dst": "tuwunel-1.0.0-1.x86_64.rpm"}
}
check_pkgs:
if: >
${{
!failure() && !cancelled()
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
&& contains(fromJSON(inputs.cargo_profiles), fromJSON('["release"]')[0])
&& contains(fromJSON(inputs.rust_toolchains), fromJSON('["stable"]')[0])
}}
name: Check Pkgs
needs: [build_pkgs]
uses: ./.github/workflows/bake.yml
with:
#bake_targets: '["pkg-deb-install", "pkg-rpm-install"]'
bake_targets: '["pkg-deb-install"]'
cargo_profiles: '["release"]'
feat_sets: '["all"]'
rust_toolchains: '["stable"]'
sys_names: ${{inputs.sys_names}}
sys_versions: ${{inputs.sys_versions}}
rust_targets: ${{inputs.rust_targets}}
sys_targets: ${{inputs.sys_targets}}
machines: ${{inputs.machines}}
excludes: ${{inputs.excludes}}
includes: ${{inputs.includes}}

View File

@@ -44,59 +44,6 @@ on:
dockerhub_token:
jobs:
packages:
if: >
${{
!failure() && !cancelled()
&& contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0])
}}
name: Publish packages
runs-on: ${{matrix.machine}}
continue-on-error: true
strategy:
fail-fast: false
matrix:
target: >
${{fromJSON('[
["standalone", "tuwunel"]
["pkg-deb","tuwunel_1.0.0-1_amd64.deb"],
["pkg-rpm","tuwunel-1.0.0-1.x86_64.rpm"],
]')}}
cargo_profile: ${{fromJSON(inputs.cargo_profiles)}}
rust_toolchain: ${{fromJSON(inputs.rust_toolchains)}}
feat_set: ${{fromJSON('["all"]')}}
sys_name: ${{fromJSON(inputs.sys_names)}}
sys_version: ${{fromJSON(inputs.sys_versions)}}
rust_target: ${{fromJSON(inputs.rust_targets)}}
sys_target: ${{fromJSON(inputs.sys_targets)}}
machine: ${{fromJSON(inputs.machines)}}
exclude: ${{fromJSON(inputs.excludes)}}
include: ${{fromJSON(inputs.includes)}}
steps:
- name: Extract
env:
file: ${{matrix.target[1]}}
iid:
${{matrix.target[0]}}
--${{matrix.cargo_profile}}
--${{matrix.rust_toolchain}}
--${{matrix.rust_target}}
--${{matrix.feat_set}}
--${{matrix.sys_name}}
--${{matrix.sys_version}}
--${{matrix.sys_target}}
run: |
cid=$(docker create "$iid" /)
docker cp "$cid:$file" .
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
path: ${{matrix.target[1]}}
name: ${{matrix.target[1]}}-${{matrix.cargo_profile}}
containers:
if: >
${{