From 7b008056b5c4250ba2b6dca15735bedfe70848d6 Mon Sep 17 00:00:00 2001 From: Rakhim Davletkaliyev Date: Sun, 3 Nov 2024 12:55:08 +0200 Subject: [PATCH] CI and CD --- .github/workflows/build_gnu_linux.yml | 33 +++++++ .github/workflows/build_macos.yml | 28 ++++++ .github/workflows/build_windows.yml | 28 ++++++ .github/workflows/cd.yml | 117 ++++++++++--------------- .github/workflows/{rust.yml => ci.yml} | 26 +++--- README.md | 10 +-- 6 files changed, 152 insertions(+), 90 deletions(-) create mode 100644 .github/workflows/build_gnu_linux.yml create mode 100644 .github/workflows/build_macos.yml create mode 100644 .github/workflows/build_windows.yml rename .github/workflows/{rust.yml => ci.yml} (70%) diff --git a/.github/workflows/build_gnu_linux.yml b/.github/workflows/build_gnu_linux.yml new file mode 100644 index 0000000..0656c1b --- /dev/null +++ b/.github/workflows/build_gnu_linux.yml @@ -0,0 +1,33 @@ +name: GNU/Linux + +on: + push: + branches: [ "main" ] + paths-ignore: + - 'LICENSE' + - 'README.md' + pull_request: + branches: [ "main" ] + paths-ignore: + - 'LICENSE' + - 'README.md' + +env: + CARGO_TERM_COLOR: always + +jobs: + build_and_test: + name: Build and test + runs-on: ubuntu-latest + + steps: + - run: git config --global core.autocrlf false + + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: Build + run: cargo build --all --locked --verbose + + - name: Run tests + run: cargo test --verbose diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml new file mode 100644 index 0000000..68b629a --- /dev/null +++ b/.github/workflows/build_macos.yml @@ -0,0 +1,28 @@ +name: macOS + +on: + push: + branches: [ "main" ] + paths-ignore: + - 'LICENSE' + - 'README.md' + +env: + CARGO_TERM_COLOR: always + +jobs: + build_and_test: + name: Build and test + runs-on: macos-latest + + steps: + - run: git config --global core.autocrlf false + + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: Build + run: cargo build --all --locked --verbose + + - name: Run tests + run: cargo test --verbose diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml new file mode 100644 index 0000000..34dfc11 --- /dev/null +++ b/.github/workflows/build_windows.yml @@ -0,0 +1,28 @@ +name: Windows + +on: + push: + branches: [ "main" ] + paths-ignore: + - 'LICENSE' + - 'README.md' + +env: + CARGO_TERM_COLOR: always + +jobs: + build_and_test: + name: Build and test + runs-on: windows-latest + + steps: + - run: git config --global core.autocrlf false + + - name: "Checkout repository" + uses: actions/checkout@v4 + + - name: Build + run: cargo build --all --locked --verbose + + - name: Run tests + run: cargo test --verbose \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b5cce6e..ea7f013 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,81 +1,58 @@ -name: Deploy +name: CD on: - push: - tags: - - "[0-9]+.[0-9]+.[0-9]+" - -permissions: - contents: write + release: + types: + - created jobs: - build-and-upload: - name: Build and upload - runs-on: ${{ matrix.os }} - - strategy: - matrix: - # You can add more, for any target you'd like! - include: - - build: linux - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - - build: macos - os: macos-latest - target: x86_64-apple-darwin - - - build: windows-gnu - os: windows-latest - target: x86_64-pc-windows-gnu - + linux_windows: + runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Get the release version from the tag - shell: bash - run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + - name: Checkout the repository + uses: actions/checkout@v2 - - name: Install Rust - # Or @nightly if you want - uses: dtolnay/rust-toolchain@stable - # Arguments to pass in - with: - # Make Rust compile to our target (defined in the matrix) - targets: ${{ matrix.target }} + - name: Install Linux and Windows Cross Compilers + run: sudo apt-get install --yes --no-install-recommends musl-tools gcc-mingw-w64-x86-64-win32 - - name: Build - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: --verbose --release --target ${{ matrix.target }} + - name: Install rustup targets + run: rustup target add x86_64-unknown-linux-musl x86_64-pc-windows-gnu - - name: Build archive - shell: bash - run: | - # Replace with the name of your binary - binary_name="textpod" + - name: Build the executable + run: cargo build --release --target x86_64-unknown-linux-musl --target x86_64-pc-windows-gnu - dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}" - mkdir "$dirname" - if [ "${{ matrix.os }}" = "windows-latest" ]; then - mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname" - else - mv "target/${{ matrix.target }}/release/$binary_name" "$dirname" - fi + - name: Tar binaries + run: | + tar -czvf textpod-gnu-linux-x86_64.tar.gz target/x86_64-unknown-linux-musl/release/textpod + zip -j textpod-windows.zip target/x86_64-pc-windows-gnu/release/textpod.exe - if [ "${{ matrix.os }}" = "windows-latest" ]; then - 7z a "$dirname.zip" "$dirname" - echo "ASSET=$dirname.zip" >> $GITHUB_ENV - else - tar -czf "$dirname.tar.gz" "$dirname" - echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV - fi + - name: Upload release binaries + uses: alexellis/upload-assets@0.4.0 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + asset_paths: '["textpod-gnu-linux-x86_64.tar.gz", "textpod-windows.zip"]' - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: | - ${{ env.ASSET }} \ No newline at end of file + macos: + runs-on: macos-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + + - name: Install rustup targets + run: rustup target add x86_64-apple-darwin aarch64-apple-darwin + + - name: Build the executable + run: cargo build --release --target=x86_64-apple-darwin --target=aarch64-apple-darwin + + - name: Zip binaries + run: + zip -j textpod-macos-x86_64.zip target/x86_64-apple-darwin/release/textpod + zip -j textpod-macos-aarch64.zip target/aarch64-apple-darwin/release/textpod + + - name: Upload release binaries + uses: alexellis/upload-assets@0.4.0 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + asset_paths: '["textpod-macos-x86_64.zip", "textpod-macos-aarch64.zip"]' diff --git a/.github/workflows/rust.yml b/.github/workflows/ci.yml similarity index 70% rename from .github/workflows/rust.yml rename to .github/workflows/ci.yml index 4dad1bc..2781d17 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,6 @@ -name: Rust +name: CI on: - push: - branches: [ "main" ] - paths-ignore: - - 'LICENSE' - - 'README.md' pull_request: branches: [ "main" ] paths-ignore: @@ -25,20 +20,21 @@ jobs: - macos-latest - windows-latest runs-on: ${{ matrix.os }} - steps: - run: git config --global core.autocrlf false - - name: "Checkout repository" + - name: Checkout repository uses: actions/checkout@v4 - - - name: Build - run: cargo build --verbose - - - name: Run tests - run: cargo test --verbose - name: Check code formatting run: | rustup component add rustfmt - cargo fmt --all -- --check \ No newline at end of file + cargo fmt --all -- --check + + - name: Build + run: cargo build --all --locked --verbose + + - name: Run tests + run: cargo test --all --verbose + + diff --git a/README.md b/README.md index 405f863..8a292a2 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ +[![textpod build status on GNU/Linux](https://github.com/freetonik/textpod/workflows/GNU%2FLinux/badge.svg)](https://github.com/freetonik/textpod/actions?query=workflow%3AGNU%2FLinux) +[![textpod build status on macOS](https://github.com/freetonik/textpod/workflows/macOS/badge.svg)](https://github.com/freetonik/textpod/actions?query=workflow%3AmacOS) +[![textpod build status on Windows](https://github.com/freetonik/textpod/workflows/Windows/badge.svg)](https://github.com/freetonik/textpod/actions?query=workflow%3AWindows) + # Textpod Local, web-based notetaking app inspired by "One Big Text File" idea. Short demo (video, no sound): [![Textpod short demo video](https://img.youtube.com/vi/VAqJJxaJNVM/0.jpg)](https://www.youtube.com/watch?v=VAqJJxaJNVM) - - Single page with all notes and a simple entry form (Markdown) - All notes are stored in a single `notes.md` file - Search/filtering when you start typing with `/` @@ -17,11 +20,8 @@ Local, web-based notetaking app inspired by "One Big Text File" idea. Short demo cargo install textpod ``` -In order to download webpages, you need to have `monolith` installed. +In order to download webpages, you need to have `monolith` installed. `cargo install monolith` or `brew install monolith` (macOS). See [monolith](https://github.com/Y2Z/monolith) for more details. -``` -cargo install monolith -``` ## Usage