From 864ac84679fd45492b626422c43d5e5341a82de7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 29 May 2025 11:13:01 +0000 Subject: [PATCH] ci: Abstract artifact uploads for every bake target. Signed-off-by: Jason Volk --- .github/workflows/bake.yml | 26 ++++++++- .github/workflows/main.yml | 3 +- .github/workflows/package.yml | 105 +++++++++++++++++++--------------- .github/workflows/publish.yml | 53 ----------------- 4 files changed, 85 insertions(+), 102 deletions(-) diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index 01d40089..e90def25 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -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}} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4b557931..6b5fcac6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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"} ] diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index f57a4617..433aecce 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -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}} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ff29493a..a40077a4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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: > ${{