Skip to content

Commit

Permalink
CI and CD
Browse files Browse the repository at this point in the history
  • Loading branch information
freetonik committed Nov 3, 2024
1 parent c1b117c commit 7b00805
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 90 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build_gnu_linux.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
@@ -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
117 changes: 47 additions & 70 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -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 }}
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"]'
26 changes: 11 additions & 15 deletions .github/workflows/rust.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Rust
name: CI

on:
push:
branches: [ "main" ]
paths-ignore:
- 'LICENSE'
- 'README.md'
pull_request:
branches: [ "main" ]
paths-ignore:
Expand All @@ -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
cargo fmt --all -- --check
- name: Build
run: cargo build --all --locked --verbose

- name: Run tests
run: cargo test --all --verbose


10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 `/`
Expand All @@ -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

Expand Down

0 comments on commit 7b00805

Please sign in to comment.