Skip to content

Commit 84b0312

Browse files
authored
10 prepare release process for linux macos and windows with a potential cicd integration (#11)
* #10 cross-build for Linx, macOS and windows * #10 add rustc component for testing * #10 cross compilation and release
1 parent 1128e76 commit 84b0312

File tree

13 files changed

+166
-23
lines changed

13 files changed

+166
-23
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
on: push
2+
3+
name: Continuous integration
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
rust:
11+
- stable
12+
- nightly
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- uses: actions-rs/toolchain@v1
18+
with:
19+
profile: minimal
20+
toolchain: ${{ matrix.rust }}
21+
override: true
22+
components: rustfmt
23+
24+
- uses: actions-rs/cargo@v1
25+
with:
26+
command: build
27+
28+
- uses: actions-rs/cargo@v1
29+
with:
30+
command: test
31+
32+
- uses: actions-rs/cargo@v1
33+
with:
34+
command: fmt
35+
args: --all -- --check
36+
if: ${{ matrix.rust == 'stable' }}

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
on:
2+
release:
3+
types: [created]
4+
5+
name: Release artifacts
6+
7+
jobs:
8+
release:
9+
name: release ${{ matrix.target }}
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
include:
15+
- target: x86_64-pc-windows-gnu
16+
archive: zip
17+
- target: x86_64-unknown-linux-musl
18+
archive: tar.gz tar.xz tar.zst
19+
- target: x86_64-apple-darwin
20+
archive: zip
21+
steps:
22+
- uses: actions/checkout@master
23+
- name: Compile and release
24+
uses: rust-build/rust-build.action@v1.4.0
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
with:
28+
RUSTTARGET: ${{ matrix.target }}
29+
ARCHIVE_TYPES: ${{ matrix.archive }}
30+
UPLOAD_MODE: none
31+
- name: Upload artifact
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: Binary
35+
path: |
36+
${{ steps.compile.outputs.BUILT_ARCHIVE }}
37+
${{ steps.compile.outputs.BUILT_CHECKSUM }}

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "markdown-gem"
3-
version = "0.1.0-rc.2"
3+
version = "0.1.0-rc.v3"
44
edition = "2021"
55
authors = ["Timur Khamrakulov <timur@murabi.io>"]
66
license = "GPL-3.0"
77
description = "Markdown code chunk runner and renderer"
88
readme = "README.md"
9-
homepage = "https://github.com/murabi-io/murabi"
10-
repository = "https://github.com/murabi-io/murabi"
9+
homepage = "https://github.com/murabi-io/markdown-gem"
10+
repository = "https://github.com/murabi-io/markdown-gem"
1111
keywords = ["cli", "markdown", "code-chunk", "executor", "runner"]
1212
categories = ["command-line-utilities"]
1313
build = "build.rs"
@@ -45,10 +45,6 @@ features = ["derive"]
4545
[target.'cfg(linux)'.dependencies]
4646
sys-info = "0.9.1"
4747

48-
[[bin]]
49-
name = "gem"
50-
path = "src/main.rs"
51-
5248
[build-dependencies]
5349
anyhow = "1.0.65"
5450
clap = { version = "4.0.26", features = ["derive"] }

Cross.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[target.x86_64-apple-darwin]
2+
image = "ghcr.io/cross-rs/x86_64-apple-darwin-cross:local"
3+
4+
[target.aarch64-apple-darwin]
5+
image = "ghcr.io/cross-rs/aarch64-apple-darwin-cross:local"

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ The attributes of the code chunk give the executor information on how to run the
5454
| cmd | string | no* | command name or path, e.g. `sh`, `node` and etc. |
5555
| args | array of arguments | yes | command arguments |
5656
| path | string | yes | `PATH` env variable for the command |
57-
| as_file | boolean | yes/true | determines if gem should execute the code chunk as a file, default `true` |
58-
| stdout | boolean | yes/true | determines if gem should display stdout of the code chunk, default `true` |
59-
| allow_warnings | boolean | yes/true | determines if gem should allow warnings, default `true` |
60-
| allow_errors** | boolean | yes/false | determines if gem should TODO: allow errors, default `true` |
61-
| with_sudo*** | boolean | yes/false | tells gem to run the code chunk in sudo |
57+
| as_file | boolean | yes/true | determines if markdown-gem should execute the code chunk as a file, default `true` |
58+
| stdout | boolean | yes/true | determines if markdown-gem should display stdout of the code chunk, default `true` |
59+
| allow_warnings | boolean | yes/true | determines if markdown-gem should allow warnings, default `true` |
60+
| allow_errors** | boolean | yes/false | determines if markdown-gem should TODO: allow errors, default `true` |
61+
| with_sudo*** | boolean | yes/false | tells markdown-gem to run the code chunk in sudo |
6262
> - \* the implementation of the default commands by code chunk lang attribute will make this attribute optional
6363
> - ** the functionality for `allow_errors` is not there yet
6464
> - *** sudo support is not available yet, you can still execute `gem` under sudo, but keep in mind that all code chunks will inherit the sudo privileges

compile-all-targets.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# WARNING: This script is NOT meant for normal installation, it's dedicated
2+
# to the compilation of all supported targets, from a linux machine.
3+
# This is a long process and it involves specialized toolchains.
4+
# For usual compilation do
5+
# cargo build --release
6+
7+
H1="\n\e[30;104;1m\e[2K\n\e[A" # style first header
8+
H2="\n\e[30;104m\e[1K\n\e[A" # style second header
9+
EH="\e[00m\n\e[2K" # end header
10+
NAME=markdown-gem
11+
12+
version=$(./version.sh)
13+
echo -e "${H1}Compilation of all targets for $NAME $version${EH}"
14+
15+
# clean previous build
16+
rm -rf build
17+
mkdir build
18+
echo " build cleaned"
19+
20+
# build the linux version
21+
target="x86_64-linux"
22+
echo -e "${H2}Compiling the linux version - $target${EH}"
23+
cargo build --release
24+
mkdir "build/$target/"
25+
cp "target/release/$NAME" "build/$target/"
26+
27+
# build versions for other platforms using cargo cross
28+
cross_build() {
29+
target_name="$1"
30+
target="$2"
31+
echo -e "${H2}Compiling the $target_name / $target version${EH}"
32+
cross build --target "$target" --release
33+
mkdir "build/$target"
34+
if [[ $target_name == 'Windows' ]]
35+
then
36+
exec="$NAME.exe"
37+
else
38+
exec="$NAME"
39+
fi
40+
cp "target/$target/release/$exec" "build/$target/"
41+
}
42+
cross_build "Raspberry 32" "armv7-unknown-linux-gnueabihf"
43+
cross_build "Linux GLIBC" "x86_64-unknown-linux-gnu"
44+
cross_build "MUSL" "x86_64-unknown-linux-musl"
45+
cross_build "NetBSD/amd64" "x86_64-unknown-netbsd"
46+
cross_build "MacOS/x86_64" "x86_64-apple-darwin"
47+
cross_build "MacOS/aarch64" "aarch64-apple-darwin"
48+
cross_build "Windows" "x86_64-pc-windows-gnu"
49+
50+
# build, find, and copy the completion scripts
51+
# (they're built as part of the normal compilation)
52+
echo -e "${H2}building and copying completion scripts${EH}"
53+
mkdir build/completion
54+
cp -R target/release/build/*${NAME}*/out/*${NAME}* build/completion
55+
echo " Done"
56+
57+
# build, find, and copy the man pages
58+
# (they're built as part of the normal compilation)
59+
echo -e "${H2}building and copying man pages${EH}"
60+
mkdir build/man
61+
62+
cp -R target/release/build/*${NAME}*/out/head* build/man
63+
echo " Done"
64+
65+
echo -e "${H1}Compilations done${EH}"

src/cli/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct Args {
1919
#[clap(short = 'p', long = "path")]
2020
pub path: Option<String>,
2121

22-
/// if specified, gem won't delete the build file of the Code chunks
22+
/// if specified, markdown-gem won't delete the build file of the Code chunks
2323
#[clap(short = 'k', long = "keep")]
2424
pub keep_builds: bool,
2525

@@ -29,7 +29,7 @@ pub struct Args {
2929
}
3030

3131
impl Args {
32-
/// positional arguments in gem command are a convenience
32+
/// positional arguments in markdown-gem command are a convenience
3333
/// allowing to skip writing `-p`.
3434
/// To be used, it must be copied to `path` value.
3535
pub fn fix(&mut self) -> Result<()> {

src/cli/help_page.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::cli::W;
88

99
static TEMPLATE: &str = r#"
1010
11-
# gem ${version}
11+
# markdown-gem ${version}
1212
1313
**gem** is a code chunk executor, it runs your markdown files executing your code chunks and outputing results.
1414

src/executor/execution_plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'a> ExecutionPlan {
5252
///
5353
/// ```
5454
/// use minimad::clean;
55-
/// use gem::executor::execution_plan::ExecutionPlan;
55+
/// use markdown_gem::executor::execution_plan::ExecutionPlan;
5656
///
5757
/// let md = clean::lines(r#"
5858
/// * some bullet item

0 commit comments

Comments
 (0)