diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..a011455 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,61 @@ +name: Continuous Deployment + +on: + push: + tags: + - "v*.*.*" + +jobs: + publish: + name: Publishing for ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest] + rust: [nightly] + include: + - os: macos-latest + artifact_prefix: macos + target: x86_64-apple-darwin + - os: ubuntu-latest + artifact_prefix: linux + target: x86_64-unknown-linux-gnu + + steps: + - name: Installing Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + - name: Installing needed macOS dependencies + if: matrix.os == 'macos-latest' + run: brew install openssl@1.1 + - name: Installing needed Ubuntu dependencies + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get update + sudo apt-get install -y -qq pkg-config libssl-dev + - name: Checking out sources + uses: actions/checkout@v1 + - name: Running cargo build + uses: actions-rs/cargo@v1 + with: + command: build + toolchain: ${{ matrix.rust }} + args: --release --target ${{ matrix.target }} + + - name: Packaging final binary + shell: bash + run: | + cd target/${{ matrix.target }}/release + strip spt + tar czvf spotify-tui-${{ matrix.artifact_prefix }}.tar.gz spt + shasum -a 256 spotify-tui-${{ matrix.artifact_prefix }}.tar.gz > spotify-tui-${{ matrix.artifact_prefix }}.sha256 + - name: Releasing assets + uses: softprops/action-gh-release@v1 + with: + files: | + target/${{ matrix.target }}/release/spotify-tui-${{ matrix.artifact_prefix }}.tar.gz + target/${{ matrix.target }}/release/spotify-tui-${{ matrix.artifact_prefix }}.sha256 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/rust.yml b/.github/workflows/ci.yml similarity index 100% rename from .github/workflows/rust.yml rename to .github/workflows/ci.yml diff --git a/.github/workflows/cross_compile.yml b/.github/workflows/cross_compile.yml deleted file mode 100644 index a37953f..0000000 --- a/.github/workflows/cross_compile.yml +++ /dev/null @@ -1,25 +0,0 @@ -on: [push, pull_request] - -name: Cross-compile - -jobs: - build: - name: Build - runs-on: ubuntu-latest - strategy: - matrix: - target: - - armv7-unknown-linux-gnueabihf - - powerpc64-unknown-linux-gnu - steps: - - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - target: ${{ matrix.target }} - override: true - - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: --release --target=${{ matrix.target }} \ No newline at end of file diff --git a/README.md b/README.md index bd6cca6..67f8231 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ |CTRL+d|Scroll window downwards| |g|Jump to top| |G|Jump to bottom| -|Enter|Open default browser| +|Enter|Open the article with default browser| +|c|Open comments with default browser| |CTRL+r|Reload articles| |CTRL+c|Quit| diff --git a/src/app.rs b/src/app.rs index d08e148..7390933 100644 --- a/src/app.rs +++ b/src/app.rs @@ -41,6 +41,12 @@ impl App { } } + pub fn open_comments(&self) { + let s = &self.stories[self.cur_index]; + let url = format!("https://news.ycombinator.com/item?id={}", s.id); + webbrowser::open(url.as_str()).expect("Can't open your browser."); + } + pub fn cursor_up(&mut self) { if self.cur_index > 0 { self.cur_index -= 1; diff --git a/src/hn.rs b/src/hn.rs index 5c7759d..18e0ca1 100644 --- a/src/hn.rs +++ b/src/hn.rs @@ -17,7 +17,7 @@ use mockito; #[derive(Deserialize, Debug)] pub struct Story { - id: i64, + pub id: i64, by: String, descendants: i64, kids: Option>, diff --git a/src/main.rs b/src/main.rs index 7c1df9e..5d0f1a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,6 +90,9 @@ fn main() { Event::Key(Key::Char('\n')) => { a.open_browser(); } + Event::Key(Key::Char('c')) => { + a.open_comments(); + } Event::Key(Key::Ctrl('d')) => { a.cursor_jump_down(); }