Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ env:
- synchronize
- reopened
- labeled
branches:
- main
push:
branches:
- main
Expand Down Expand Up @@ -292,5 +290,13 @@ jobs:
RUSTFLAGS: ${{ env.RUSTFLAGS }}
POSTHOG_API_SECRET: ${{secrets.POSTHOG_API_SECRET}}
APP_VERSION: ${{ needs.draft_release_pr.outputs.crate_release_name }}
- name: Copy Binary
run: cp ${{ matrix.binary_path }} ${{ matrix.binary_name }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.binary_name }}
path: ${{ matrix.binary_name }}
retention-days: 7
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
27 changes: 25 additions & 2 deletions crates/forge_ci/src/jobs/release_build_job.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use derive_setters::Setters;
use gh_workflow::*;
use serde_json::json;

use crate::release_matrix::ReleaseMatrix;
use crate::steps::setup_protoc;
Expand All @@ -10,13 +11,16 @@ pub struct ReleaseBuilderJob {
// Required to burn into the binary
pub version: String,

// When provide the generated release will be uploaded
// When provided the generated release will be uploaded
pub release_id: Option<String>,

// When true, upload built binaries as GitHub Actions artifacts
pub upload_artifact: Option<bool>,
}

impl ReleaseBuilderJob {
pub fn new(version: impl AsRef<str>) -> Self {
Self { version: version.as_ref().to_string(), release_id: None }
Self { version: version.as_ref().to_string(), release_id: None, upload_artifact: None }
}

pub fn into_job(self) -> Job {
Expand Down Expand Up @@ -98,6 +102,25 @@ impl From<ReleaseBuilderJob> for Job {
);
}

if value.upload_artifact == Some(true) {
job = job
// Rename binary to target name for artifact upload
.add_step(
Step::new("Copy Binary")
.run("cp ${{ matrix.binary_path }} ${{ matrix.binary_name }}"),
)
// Upload as GitHub Actions artifact
.add_step(
Step::new("Upload Artifact")
.uses("actions", "upload-artifact", "v4")
.with(Input::from(indexmap::indexmap! {
"name".to_string() => json!("${{ matrix.binary_name }}"),
"path".to_string() => json!("${{ matrix.binary_name }}"),
"retention-days".to_string() => json!(7),
})),
);
}

job
}
}
4 changes: 2 additions & 2 deletions crates/forge_ci/src/workflows/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ pub fn generate_ci_workflow() {
.add_type(PullRequestType::Opened)
.add_type(PullRequestType::Synchronize)
.add_type(PullRequestType::Reopened)
.add_type(PullRequestType::Labeled)
.add_branch("main"),
.add_type(PullRequestType::Labeled),
);
let build_release_pr_job =
ReleaseBuilderJob::new("${{ needs.draft_release_pr.outputs.crate_release_name }}")
.upload_artifact(true)
.into_job()
.add_needs("draft_release_pr")
.cond(Expression::new(
Expand Down
Loading