feat(ci): publish build artifacts as GitHub releases (#1222)

This commit is contained in:
Hampus authored and GitHub committed 2026-06-30 03:19:39 +02:00
1 parent 31665225eb
commit a2ed83df08
47 files changed
+1912 -403

No files matched your search

+3 -17
View File
@@ -15,7 +15,7 @@ use std::collections::{BTreeMap, BTreeSet};
use std::env;
use std::ffi::{OsStr, OsString};
use std::fs::{self, OpenOptions};
use std::io::{self, Read, Write};
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::sync::Arc;
@@ -24,6 +24,8 @@ use tokio::sync::Semaphore;
use tokio::task::JoinSet;
use walkdir::WalkDir;
pub(crate) use crate::functions::{remove_dir_if_exists, remove_file_if_exists};
const DEFAULT_S3_WRITE_CONCURRENCY: usize = 8;
const DEFAULT_S3_RETRY_ATTEMPTS: u32 = 8;
@@ -1484,22 +1486,6 @@ pub(crate) fn require_home() -> Result<PathBuf> {
.context("HOME or USERPROFILE is required")
}
pub(crate) fn remove_file_if_exists(path: &Path) -> Result<()> {
match fs::remove_file(path) {
Ok(()) => Ok(()),
Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(()),
Err(error) => Err(error).with_context(|| format!("Failed to remove {}", path.display())),
}
}
pub(crate) fn remove_dir_if_exists(path: &Path) -> Result<()> {
match fs::remove_dir_all(path) {
Ok(()) => Ok(()),
Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(()),
Err(error) => Err(error).with_context(|| format!("Failed to remove {}", path.display())),
}
}
pub(crate) fn copy_dir_contents(source: &Path, dest: &Path) -> Result<()> {
for file in collect_files(source)? {
let relative = file.strip_prefix(source)?;
+1 -9
View File
@@ -9,6 +9,7 @@ use crate::common::{
runner_temp, s3_client, title_case, trim_option, upload_directory_to_s3,
upload_directory_to_s3_overwrite,
};
use crate::functions::write_json_pretty;
use anyhow::{Context, Result, anyhow, bail, ensure};
use aws_sdk_s3::Client as S3Client;
use chrono::{DateTime, Utc};
@@ -3278,15 +3279,6 @@ fn sha256_file(path: &Path) -> Result<String> {
Ok(hex::encode(hasher.finalize()))
}
fn write_json_pretty<T: Serialize + ?Sized>(path: &Path, value: &T) -> Result<()> {
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)
.with_context(|| format!("Failed to create {}", parent.display()))?;
}
let bytes = serde_json::to_vec_pretty(value)?;
fs::write(path, bytes).with_context(|| format!("Failed to write {}", path.display()))
}
fn print_directory(dir: &Path) -> Result<()> {
if !dir.exists() {
println!("{} does not exist", dir.display());
+77
View File
@@ -0,0 +1,77 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
use anyhow::{Context, Result};
use serde::Serialize;
use std::fs;
use std::io;
use std::path::Path;
pub(crate) fn remove_file_if_exists(path: &Path) -> Result<()> {
match fs::remove_file(path) {
Ok(()) => Ok(()),
Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(()),
Err(error) => Err(error).with_context(|| format!("Failed to remove {}", path.display())),
}
}
pub(crate) fn remove_dir_if_exists(path: &Path) -> Result<()> {
match fs::remove_dir_all(path) {
Ok(()) => Ok(()),
Err(error) if error.kind() == io::ErrorKind::NotFound => Ok(()),
Err(error) => Err(error).with_context(|| format!("Failed to remove {}", path.display())),
}
}
pub(crate) fn write_json_pretty<T: Serialize + ?Sized>(path: &Path, value: &T) -> Result<()> {
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)
.with_context(|| format!("Failed to create {}", parent.display()))?;
}
let mut bytes = serde_json::to_vec_pretty(value)?;
bytes.push(b'\n');
fs::write(path, bytes).with_context(|| format!("Failed to write {}", path.display()))
}
#[cfg(test)]
mod tests {
use super::*;
use serde_json::json;
#[test]
fn remove_file_if_exists_removes_files_and_ignores_missing_paths() {
let temp = tempfile::tempdir().unwrap();
let path = temp.path().join("artifact.txt");
fs::write(&path, "artifact").unwrap();
remove_file_if_exists(&path).unwrap();
remove_file_if_exists(&path).unwrap();
assert!(!path.exists());
}
#[test]
fn remove_dir_if_exists_removes_directories_and_ignores_missing_paths() {
let temp = tempfile::tempdir().unwrap();
let path = temp.path().join("dist");
fs::create_dir_all(path.join("nested")).unwrap();
fs::write(path.join("nested").join("artifact.txt"), "artifact").unwrap();
remove_dir_if_exists(&path).unwrap();
remove_dir_if_exists(&path).unwrap();
assert!(!path.exists());
}
#[test]
fn write_json_pretty_creates_parent_directories_and_writes_pretty_json() {
let temp = tempfile::tempdir().unwrap();
let path = temp.path().join("nested").join("manifest.json");
write_json_pretty(&path, &json!({ "name": "fluxer", "version": 1 })).unwrap();
assert_eq!(
fs::read_to_string(path).unwrap(),
"{\n \"name\": \"fluxer\",\n \"version\": 1\n}\n"
);
}
}
+4
View File
@@ -8,7 +8,9 @@ mod ci_workflow;
mod common;
mod desktop;
mod desktop_native;
mod functions;
mod gateway;
mod release;
mod schema;
mod static_bucket;
@@ -37,6 +39,7 @@ enum Command {
CleanSchemaGeneratedFiles(schema::CleanSchemaGeneratedFilesArgs),
Gateway(gateway::GatewayArgs),
RepairStaticAssetMetadata(static_bucket::RepairStaticAssetMetadataArgs),
Release(release::ReleaseArgs),
ResolveCalver(calver::ResolveCalverArgs),
SyncStaticBucket(static_bucket::SyncStaticBucketArgs),
TestWebrtcSenderRust(desktop_native::TestWebrtcSenderRustArgs),
@@ -60,6 +63,7 @@ pub async fn run() -> Result<()> {
Command::RepairStaticAssetMetadata(args) => {
static_bucket::repair_asset_metadata(args).await
}
Command::Release(args) => release::run(args).await,
Command::ResolveCalver(args) => calver::run(args),
Command::SyncStaticBucket(args) => static_bucket::run(args).await,
Command::TestWebrtcSenderRust(args) => desktop_native::run_test_webrtc_sender_rust(args),
File diff suppressed because it is too large. Load diff