Skip to main content

flowey_hvlite/pipelines/
openvmm_source_release.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! See [`OpenvmmSourceReleaseCli`]
5
6use flowey::node::prelude::FlowPlatformLinuxDistro;
7use flowey::node::prelude::GhPermission;
8use flowey::node::prelude::GhPermissionValue;
9use flowey::pipeline::prelude::*;
10use flowey_lib_common::git_checkout::RepoSource;
11
12/// A pipeline that assembles, validates, and drafts an OpenVMM source release.
13///
14/// This pipeline has no CI or PR triggers. It is dispatched by hand, against a
15/// commit whose `[workspace.package] version` a reviewed pull request has
16/// already set to the version being released.
17///
18/// It ends at an `openvmm-v<VERSION>` tag, a vendor archive upload, and a
19/// *draft* release. Publishing the reviewed draft stays with a human.
20///
21/// Only the GitHub backend is supported. The pipeline creates a tag and a
22/// release in the upstream repository, so there is nothing meaningful for a
23/// local run to do.
24#[derive(clap::Args)]
25pub struct OpenvmmSourceReleaseCli {}
26
27impl IntoPipeline for OpenvmmSourceReleaseCli {
28    fn into_pipeline(self, backend_hint: PipelineBackendHint) -> anyhow::Result<Pipeline> {
29        let Self {} = self;
30
31        if !matches!(backend_hint, PipelineBackendHint::Github) {
32            anyhow::bail!(
33                "Unsupported backend: the source release pipeline only supports the GitHub backend"
34            );
35        }
36
37        let mut pipeline = Pipeline::new();
38        pipeline.gh_set_name("OpenVMM Source Release");
39        let (publish_release, use_release) = pipeline.new_typed_artifact::<
40            flowey_lib_hvlite::assemble_openvmm_vendor_release::VendorReleaseOutput,
41        >("openvmm-vendor-release");
42
43        let openvmm_repo_source = RepoSource::GithubSelf;
44
45        pipeline.gh_set_flowey_bootstrap_template(
46            crate::pipelines_shared::gh_flowey_bootstrap_template::get_template(),
47        );
48
49        let cfg_common_params = crate::pipelines_shared::cfg_common_params::get_cfg_common_params(
50            &mut pipeline,
51            backend_hint,
52            None,
53        )?;
54
55        pipeline.inject_all_jobs_with(move |job| {
56            job.dep_on(&cfg_common_params)
57                .dep_on(|_| flowey_lib_hvlite::_jobs::cfg_versions::Request::Init)
58                .dep_on(
59                    |_| flowey_lib_hvlite::_jobs::cfg_hvlite_reposource::Params {
60                        hvlite_repo_source: openvmm_repo_source.clone(),
61                    },
62                )
63                .gh_grant_permissions::<flowey_lib_common::git_checkout::Node>([(
64                    GhPermission::Contents,
65                    GhPermissionValue::Read,
66                )])
67        });
68
69        let assemble_job = pipeline
70            .new_job(
71                FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
72                FlowArch::X86_64,
73                "assemble openvmm vendor artifact",
74            )
75            .gh_set_pool(crate::pipelines_shared::gh_pools::linux_x64_gh())
76            .publish(publish_release, |release| {
77                flowey_lib_hvlite::assemble_openvmm_vendor_release::Request { release }
78            })
79            .finish();
80
81        let validate_job = pipeline
82            .new_job(
83                FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
84                FlowArch::X86_64,
85                "validate openvmm distribution build",
86            )
87            .gh_set_pool(crate::pipelines_shared::gh_pools::linux_x64_gh())
88            .dep_on(
89                |ctx| flowey_lib_hvlite::_jobs::check_distro_build::Request {
90                    release: ctx.use_typed_artifact(&use_release),
91                    done: ctx.new_done_handle(),
92                },
93            )
94            .finish();
95
96        let publish_job = pipeline
97            .new_job(
98                FlowPlatform::Linux(FlowPlatformLinuxDistro::Ubuntu),
99                FlowArch::X86_64,
100                "draft openvmm source release",
101            )
102            .gh_set_pool(crate::pipelines_shared::gh_pools::linux_x64_gh())
103            .dep_on(
104                |ctx| flowey_lib_hvlite::_jobs::publish_openvmm_gh_release::Request {
105                    release: ctx.use_typed_artifact(&use_release),
106                    done: ctx.new_done_handle(),
107                },
108            )
109            .gh_grant_permissions::<flowey_lib_common::publish_gh_release::Node>([(
110                GhPermission::Contents,
111                GhPermissionValue::Write,
112            )])
113            .finish();
114
115        pipeline.non_artifact_dep(&publish_job, &validate_job);
116        pipeline.non_artifact_dep(&validate_job, &assemble_job);
117
118        Ok(pipeline)
119    }
120}