diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..c6b18df --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,72 @@ +name: Cargo Build & Test + +on: + pull_request: + +jobs: + test: + container: git.kjan.de/actions/rust-node + name: Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: ⚡ Cache + uses: https://git.kjan.de/actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target/release/deps + target/release/build + target + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}-loadstar + - run: cargo test + + can-publish: + container: git.kjan.de/actions/rust-node + name: Test publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: ⚡ Cache + uses: https://git.kjan.de/actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target/release/deps + target/release/build + target + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}-loadstar + - run: cargo publish -n + + check-cargo-version: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get current version from Cargo.toml + id: cargo-version + run: | + # Extract the version from Cargo.toml in the PR branch + CARGO_VERSION=$(grep '^version' Cargo.toml | sed -e 's/version = "//' -e 's/"//') + echo "cargo_version=$CARGO_VERSION" >> $GITHUB_ENV + + - name: Get previous version from main branch + id: main-cargo-version + run: | + # Fetch the Cargo.toml from the main branch and extract its version + git fetch origin main + MAIN_CARGO_VERSION=$(git show origin/main:Cargo.toml | grep '^version' | sed -e 's/version = "//' -e 's/"//') + echo "main_cargo_version=$MAIN_CARGO_VERSION" >> $GITHUB_ENV + + - name: Compare versions + run: | + if [ "$cargo_version" = "$main_cargo_version" ]; then + echo "Cargo version has not been updated." + exit 1 + else + echo "Cargo version has been updated." + fi diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml new file mode 100644 index 0000000..c64fd03 --- /dev/null +++ b/.gitea/workflows/publish.yaml @@ -0,0 +1,26 @@ +name: Cargo Build & Test + +on: + push: + branches: + - main + +jobs: + can-publish: + container: git.kjan.de/actions/rust-node + name: Test publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: ⚡ Cache + uses: https://git.kjan.de/actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target/release/deps + target/release/build + target + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}-loadstar + - run: cargo login ${{ secrets.CRATES_IO_TOKEN }} + - run: cargo publish diff --git a/Cargo.lock b/Cargo.lock index 533a5f7..5c48b31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,7 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "loadstar" -version = "0.0.2" +version = "0.0.3" dependencies = [ "tiny_http", ] diff --git a/Cargo.toml b/Cargo.toml index df526ce..15e69c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "loadstar" description = "A simple web framework for rust" repository = "https://git.kjan.de/jank/loadstar" -version = "0.0.2" +version = "0.0.3" license = "GPL-3.0-only" edition = "2021"