Skip to content

Commit

Permalink
fix: build can not run on crates.io's read-only image
Browse files Browse the repository at this point in the history
  • Loading branch information
kingwingfly committed Feb 14, 2024
1 parent 8200be5 commit 3db474f
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 12 deletions.
20 changes: 20 additions & 0 deletions .github/scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! /bin/bash
set -e

# Statements waiting to be executed
statements=(
"cargo login $1"
"cargo publish -p fav_derive --dry-run"
"cargo publish -p fav_core --dry-run"
"cargo publish -p fav_utils --dry-run"
"cargo publish -p fav_derive"
"cargo publish -p fav_core"
"cargo publish -p fav_utils"
)

# loop echo and executing statements
for statement in "${statements[@]}"; do
echo "$(tput setaf 3)$statement$(tput sgr0)"
eval $statement
echo
done
26 changes: 26 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: publish

on:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: install cargo components
run: rustup component add clippy

- name: Extract version
id: extract-version
run: echo "VERSION=$(grep -oP '^version = "\K[^"]+' Cargo.toml | awk '{$1=$1;print}')" >> $GITHUB_OUTPUT

- name: run tests
run: .github/scripts/test.sh

- name: publish
run: .github/scripts/publish.sh ${{ secrets.CRATESIO }}
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ documentation = ""

[workspace.dependencies]
fav_core = { path = "fav_core" }
fav_derive = { path = "fav_derive", version = "0.0.1-alpha1" }
fav_derive = { path = "fav_derive", version = "0.0.1-alpha2" }
fav_utils = { path = "fav_utils" }
fav_cli = { path = "fav_cli" }
fav_utils_ng = { path = "fav_utils_ng" }
Expand Down
2 changes: 1 addition & 1 deletion fav_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fav_core"
version = "0.0.1-alpha2"
version = "0.0.1-alpha3"
authors.workspace = true
description = "Fav's core crate; A collection of traits."
license.workspace = true
Expand Down
1 change: 1 addition & 0 deletions fav_core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Channel::Dev => "CHANNEL_DEV",
};
println!("cargo:rustc-cfg={}", channel);
#[cfg(not(doc))]
protobuf_codegen::Codegen::new()
.pure()
.includes(["./proto"])
Expand Down
2 changes: 0 additions & 2 deletions fav_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ pub mod status;
mod test_utils;

pub use error::*;
#[cfg(feature = "derive")]
pub use fav_derive as derive;

/// Re-export the most important traits and types
pub mod prelude {
Expand Down
2 changes: 1 addition & 1 deletion fav_derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fav_derive"
version = "0.0.1-alpha1"
version = "0.0.1-alpha2"
authors.workspace = true
description = "Derive macros for fav"
license.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions fav_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod api;
mod attr;
mod status;

/// A derive macro helping implemente `Api` trait.
/// A derive macro helping implemente [`Api`] trait.
/// # Example
/// ```
/// use fav_core::api::Api;
Expand All @@ -29,7 +29,7 @@ pub fn derive_api(input: TokenStream) -> TokenStream {
api::derive_api(input)
}

/// A derive macro helping implemente `Api` trait.
/// A derive macro helping implemente [`Attr`] trait.
/// # Example
/// ```
/// use fav_core::attr::Attr;
Expand All @@ -55,7 +55,7 @@ pub fn derive_attr(input: TokenStream) -> TokenStream {
attr::derive_attr(input)
}

/// A derive macro helping implemente `Api` trait.
/// A derive macro helping implemente [`Status`] trait.
/// # Example
/// ```
/// use fav_core::status::Status;
Expand Down
2 changes: 1 addition & 1 deletion fav_utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fav_utils"
version = "0.0.1-alpha1"
version = "0.0.1-alpha2"
authors.workspace = true
description = "Fav's utils crate; A collection of utilities and data structures for the fav project"
license.workspace = true
Expand Down
1 change: 1 addition & 0 deletions fav_utils/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Channel::Dev => "CHANNEL_DEV",
};
println!("cargo:rustc-cfg={}", channel);
#[cfg(not(doc))]
protobuf_codegen::Codegen::new()
.pure()
.includes(["./proto"])
Expand Down

0 comments on commit 3db474f

Please sign in to comment.