Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(release): Use github actions to release binaries #5

Merged
merged 4 commits into from
Oct 18, 2023
Merged
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
14 changes: 14 additions & 0 deletions .github/releaser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# Trigger release action on new release

if [ -z "$1" ]; then
echo "Please provide a version number."
echo "Usages: $0 v[X.Y.Z]"
exit 1
fi

version=$1

git tag "v$version"
git push origin "v$version"
93 changes: 93 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Continuous Deployment

on:
push:
tags:
- "v*.*.*"

jobs:
publish-github:
name: Publish on GitHub
runs-on: ${{ matrix.config.OS }}
strategy:
fail-fast: false
matrix:
config:
- { OS: ubuntu-latest, TARGET: "x86_64-unknown-linux-gnu" }
- { OS: ubuntu-latest, TARGET: "x86_64-unknown-linux-musl" }
- { OS: ubuntu-latest, TARGET: "i686-unknown-linux-gnu" }
- { OS: ubuntu-latest, TARGET: "i686-unknown-linux-musl" }
- { OS: ubuntu-latest, TARGET: "armv5te-unknown-linux-gnueabi" }
- { OS: ubuntu-latest, TARGET: "armv7-unknown-linux-gnueabihf" }
- { OS: ubuntu-latest, TARGET: "aarch64-unknown-linux-gnu" }
- { OS: ubuntu-latest, TARGET: "aarch64-unknown-linux-musl" }
- { OS: macos-latest, TARGET: "x86_64-apple-darwin" }
- { OS: macos-latest, TARGET: "aarch64-apple-darwin" }
- { OS: windows-latest, TARGET: "x86_64-pc-windows-msvc" }
- { OS: windows-latest, TARGET: "i686-pc-windows-msvc" }

steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Set the release version
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.config.TARGET }}
override: true

- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --locked --target ${{ matrix.config.TARGET }}

- name: Prepare release assets
shell: bash
run: |
mkdir release/
cp {LICENSE,README.md} release/
cp target/${{ matrix.config.TARGET }}/release/presenterm release/
mv release/ presenterm-${{ env.RELEASE_VERSION }}/

- name: Create release artifacts
shell: bash
run: |
if [ "${{ matrix.config.OS }}" = "windows-latest" ]; then
7z a -tzip "presenterm-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.zip" \
presenterm-${{ env.RELEASE_VERSION }}
else
tar -czvf presenterm-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz \
presenterm-${{ env.RELEASE_VERSION }}/
shasum -a 512 presenterm-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz \
> presenterm-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.tar.gz.sha512
fi

- name: Upload the release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: presenterm-${{ env.RELEASE_VERSION }}-${{ matrix.config.TARGET }}.*
file_glob: true
overwrite: true
tag: ${{ github.ref }}

publish-crates-io:
name: Publish on crates.io
needs: publish-github
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Publish
uses: actions-rs/cargo@v1
with:
command: publish
args: --locked --token ${{ secrets.CARGO_TOKEN }}
23 changes: 23 additions & 0 deletions Cargo.lock

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

23 changes: 22 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.2.0"
edition = "2021"

[dependencies]
clap = { version = "4.4", features = ["derive"] }
clap = { version = "4.4", features = ["derive", "string"] }
comrak = { version = "0.19", default-features = false }
crossterm = { version = "0.27", features = ["serde"] }
hex = "0.4"
Expand All @@ -23,10 +23,31 @@ strum = { version = "0.25", features = ["derive"] }
thiserror = "1"
unicode-width = "0.1"
viuer = "0.7.1"
colored = "2.0.4"

[dev-dependencies]
rstest = { version = "0.18", default-features = false }

[features]
default = []
sixel = ["viuer/sixel"]

[profile.dev]
opt-level = 0
debug = true
panic = "abort"

[profile.test]
opt-level = 0
debug = true

[profile.release]
opt-level = 3
debug = false
panic = "unwind"
lto = true
codegen-units = 1

[profile.bench]
opt-level = 3
debug = false
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pub mod render;
pub mod resource;
pub mod style;
pub mod theme;
pub mod splash;
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ use presenterm::{
presenter::{PresentMode, Presenter},
render::highlighting::CodeHighlighter,
resource::Resources,
splash::show_splashes,
theme::PresentationTheme,
};
use std::path::{Path, PathBuf};

/// Run slideshows from your terminal.
#[derive(Parser)]
#[command()]
#[command(author, version, about = show_splashes(), long_about = show_splashes(), arg_required_else_help = true)]
struct Cli {
/// The path to the markdown file that contains the presentation.
path: PathBuf,
Expand Down
19 changes: 19 additions & 0 deletions src/splash.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use colored::Colorize;

pub fn show_splashes() -> String {
let crate_version = env!("CARGO_PKG_VERSION");

let logo = format!(
r#"
┌─┐┬─┐┌─┐┌─┐┌─┐┌┐┌┌┬┐┌─┐┬─┐┌┬┐
├─┘├┬┘├┤ └─┐├┤ │││ │ ├┤ ├┬┘│││
┴ ┴└─└─┘└─┘└─┘┘└┘ ┴ └─┘┴└─┴ ┴ v{}
A terminal slideshow tool
@mfontanini/presenterm
"#,
crate_version,
)
.bold()
.purple();
format!("{logo}")
}
Loading