diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 3deb8b9..08c8196 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -141,6 +141,11 @@ jobs: cargo install --path . --force cd ../.. + - name: Install cargo-expand + if: steps.check_asset.outputs.skip_build != 'true' + run: | + cargo install cargo-expand + - name: Cache Flutter dependencies (Linux/Android) if: steps.check_asset.outputs.skip_build != 'true' && ( matrix.config.target == 'android-arm32' || matrix.config.target == 'android-arm64' || matrix.config.target == 'android-x86_64' || matrix.config.target == 'linux' ) uses: actions/cache@v3 diff --git a/ci/src/check_asset/main.rs b/ci/src/check_asset/main.rs index 78c7c30..3b62565 100644 --- a/ci/src/check_asset/main.rs +++ b/ci/src/check_asset/main.rs @@ -3,7 +3,7 @@ use serde_derive::Deserialize; use serde_derive::Serialize; use serde_json::Value; -const UA: &str = "actions ci"; +use ci::common; #[tokio::main] async fn main() -> Result<()> { @@ -20,18 +20,11 @@ async fn main() -> Result<()> { let code = vs_code_txt.trim(); - let release_file_name = match target.as_str() { - "macos" => format!("{app_name}-{code}.dmg"), - "ios" => format!("{app_name}-{code}-nosign.ipa"), - "windows" => format!("{app_name}-{code}-windows-x86_64.zip"), - "linux" => format!("{app_name}-{code}-linux-x86_64.AppImage"), - "android-arm32" => format!("{app_name}-{code}-arm32.apk"), - "android-arm64" => format!("{app_name}-{code}-arm64.apk"), - "android-x86_64" => format!("{app_name}-{code}-x86_64.apk"), - un => panic!("unknown target : {target}"), - }; + let release_file_name = common::asset_name(app_name, code, target.as_str()); - let client = reqwest::ClientBuilder::new().user_agent(UA).build()?; + let client = reqwest::ClientBuilder::new() + .user_agent(common::UA) + .build()?; let check_response = client .get(format!( diff --git a/ci/src/common.rs b/ci/src/common.rs new file mode 100644 index 0000000..b5f3c63 --- /dev/null +++ b/ci/src/common.rs @@ -0,0 +1,14 @@ +pub const UA: &str = "github actions"; + +pub fn asset_name(app_name: &str, code: &str, target: &str) -> String { + match target { + "macos" => format!("{app_name}-{code}.dmg"), + "ios" => format!("{app_name}-{code}-nosign.ipa"), + "windows" => format!("{app_name}-{code}-windows-x86_64.zip"), + "linux" => format!("{app_name}-{code}-linux-x86_64.AppImage"), + "android-arm32" => format!("{app_name}-{code}-arm32.apk"), + "android-arm64" => format!("{app_name}-{code}-arm64.apk"), + "android-x86_64" => format!("{app_name}-{code}-x86_64.apk"), + un => panic!("unknown target : {un}"), + } +} diff --git a/ci/src/lib.rs b/ci/src/lib.rs new file mode 100644 index 0000000..34994bf --- /dev/null +++ b/ci/src/lib.rs @@ -0,0 +1 @@ +pub mod common; diff --git a/ci/src/main.rs b/ci/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/ci/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/ci/src/upload_asset/main.rs b/ci/src/upload_asset/main.rs index 2aa65c1..1e1f569 100644 --- a/ci/src/upload_asset/main.rs +++ b/ci/src/upload_asset/main.rs @@ -1,10 +1,9 @@ use anyhow::Result; +use ci::common; use serde_derive::Deserialize; use serde_derive::Serialize; use serde_json::Value; -const UA: &str = "github actions"; - #[tokio::main] async fn main() -> Result<()> { let gh_token = std::env::var("GITHUB_TOKEN")?; @@ -26,16 +25,7 @@ async fn main() -> Result<()> { let code = vs_code_txt.trim(); - let release_file_name = match target.as_str() { - "macos" => format!("{app_name}-{code}.dmg"), - "ios" => format!("{app_name}-{code}-nosign.ipa"), - "windows" => format!("{app_name}-{code}-windows-x86_64.zip"), - "linux" => format!("{app_name}-{code}-linux-x86_64.AppImage"), - "android-arm32" => format!("{app_name}-{code}-arm32.apk"), - "android-arm64" => format!("{app_name}-{code}-arm64.apk"), - "android-x86_64" => format!("{app_name}-{code}-x86_64.apk"), - un => panic!("unknown target : {target}"), - }; + let release_file_name = common::asset_name(app_name, code, target.as_str()); let local_path = match target.as_str() { "macos" => "../build/macos.dmg", @@ -48,7 +38,9 @@ async fn main() -> Result<()> { un => panic!("unknown target : {}", un), }; - let client = reqwest::ClientBuilder::new().user_agent(UA).build()?; + let client = reqwest::ClientBuilder::new() + .user_agent(common::UA) + .build()?; let check_response = client .get(format!(