loadstar/.gitea/workflows/ci.yaml
Jan Klattenhoff 4ac4c6223d
Some checks failed
Cargo Build & Test / check-cargo-version (pull_request) Failing after 6s
Cargo Build & Test / Test publish (pull_request) Successful in 8s
Check if cargo version is updated
2024-08-20 11:57:40 +02:00

55 lines
1.6 KiB
YAML

name: Cargo Build & Test
on:
pull_request:
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 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