This commit is contained in:
MedzikUser 2022-02-13 13:12:33 +01:00
parent 8f68e0180f
commit 3c7d01f9c1
No known key found for this signature in database
GPG Key ID: A5FAC1E185C112DB
5 changed files with 294 additions and 4 deletions

View File

@ -0,0 +1,152 @@
name: Build release binaries (and publish them if this is a tag)
on:
push:
paths-ignore:
- '*.md'
pull_request:
jobs:
binaries:
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- x86_64-pc-windows-msvc
- x86_64-apple-darwin
- aarch64-apple-darwin
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: target/x86_64-unknown-linux-musl/release/imgurs
release_name: x86_64-unknown-linux-musl
cross: true
strip: true
compress: true
cargo_flags: ""
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
artifact_name: target/aarch64-unknown-linux-musl/release/imgurs
release_name: aarch64-unknown-linux-musl
cross: true
strip: false
compress: true
cargo_flags: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: target/x86_64-pc-windows-msvc/release/imgurs.exe
release_name: x86_64-pc-windows-msvc.exe
cross: false
strip: true
compress: true
cargo_flags: ""
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: target/x86_64-apple-darwin/release/imgurs
release_name: x86_64-apple-darwin
cross: false
strip: true
compress: true
cargo_flags: ""
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: target/aarch64-apple-darwin/release/imgurs
release_name: aarch64-apple-darwin
cross: false
strip: true
compress: true
cargo_flags: ""
name: ${{ matrix.os }} for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
- name: cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target=${{ matrix.target }} ${{ matrix.cargo_flags }}
use-cross: ${{ matrix.cross }}
- name: Compress binaries
uses: svenstaro/upx-action@v2
with:
file: ${{ matrix.artifact_name }}
args: --lzma
strip: ${{ matrix.strip }}
if: ${{ matrix.compress }}
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.target }}
path: ${{ matrix.artifact_name }}
###
# Below this line, steps will only be ran if a tag was pushed.
###
- name: Get tag name
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
shell: bash
if: startsWith(github.ref, 'refs/tags/v')
- name: Get CHANGELOG.md entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v1
with:
version: ${{ steps.tag_name.outputs.current_version }}
path: ./CHANGELOG.md
if: startsWith(github.ref, 'refs/tags/v')
- name: Publish
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.artifact_name }}
tag: ${{ github.ref }}
asset_name: imgurs-$tag-${{ matrix.release_name }}
body: ${{ steps.changelog_reader.outputs.log_entry }}
if: startsWith(github.ref, 'refs/tags/v')
crates:
name: Publish to crates.io
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Publish to crates.io
uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CARGO_REGISTRY_TOKEN }}

45
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,45 @@
name: Rust
on:
push:
branches:
- main
paths-ignore:
- '*.md'
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, nightly]
name: ${{ matrix.rust }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
- name: cargo build
uses: actions-rs/cargo@v1
with:
command: build
- name: cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings

49
.github/workflows/fmt.yml vendored Normal file
View File

@ -0,0 +1,49 @@
name: Rust fmt
on:
push:
branches:
- main
paths-ignore:
- '*.md'
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup GIT
run: |
git config --global user.name "MedzikUserBot"
git config --global user.email "rm99iv9s@duck.com"
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all
- name: Commit changes
run: |
git add .
git diff-index --quiet HEAD || git commit -m "rustfmt"
- name: Push changes
uses: ad-m/github-push-action@b007e7b818e33b04afd056e4c4b57ba917145d7a
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: 'main'

30
CHANGELOG.md Normal file
View File

@ -0,0 +1,30 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
<!-- next-header -->
## [Unreleased]
## [0.1.0] - 2022-02-13
### CLI
- options
- -c, --client-id <*string*> Discord application Client ID (required)
- -d, --details <*string*> Details (required)
- -s, --state <*string*> State (optional)
- -N, --large-image <*string*> Large Image name (optional)
- -I, --large-image-text <*string*> Large Image text (optional)
- -n, --small-image <*string*> Small Image name (optional)
- -i, --small-image-text <*string*> Small Image text (optional)
- -B, --button-1-text <*string*> Button 1 Text (optional)
- -T, --button-1-url <*string*> Button 1 URL address (optional)
- -b, --button-2-text <*string*> Button 2 Text (optional)
- -t, --button-2-url <*string*> Button 2 URL address (optional)
- -e, --timer Enable timer (counted from the current time) (optional)
<!-- next-url -->
[Unreleased]: https://github.com/MedzikUser/imgurs/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/MedzikUser/imgurs/commits/v0.1.0

View File

@ -1,12 +1,16 @@
mod cli;
use std::{process::exit, vec, time::{UNIX_EPOCH, SystemTime}};
use clap::StructOpt;
use colored::Colorize;
use discord_rich_presence::{
activity::{self, Activity},
new_client, DiscordIpc,
};
use std::{
process::exit,
time::{SystemTime, UNIX_EPOCH},
vec,
};
use crate::cli::Cli;
@ -86,15 +90,25 @@ fn main() {
activity = activity.buttons(vec![activity::Button::new(&button_1_text, &button_1_url)]);
}
if button_1_text != "none" && button_1_url != "none" && button_2_text != "none" && button_2_url != "none" {
if button_1_text != "none"
&& button_1_url != "none"
&& button_2_text != "none"
&& button_2_url != "none"
{
println!("{} {}", "button 2 text :".cyan(), button_2_text.yellow());
println!("{} {}", "button 2 url :".cyan(), button_2_url.yellow());
activity = activity.buttons(vec![activity::Button::new(&button_1_text, &button_1_url), activity::Button::new(&button_2_text, &button_2_url)]);
activity = activity.buttons(vec![
activity::Button::new(&button_1_text, &button_1_url),
activity::Button::new(&button_2_text, &button_2_url),
]);
}
if enable_timer {
let time_unix = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() as i64;
let time_unix = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs() as i64;
activity = activity.timestamps(activity::Timestamps::new().start(time_unix))
}