loadstar/.gitea/workflows/ci.yaml

73 lines
2.5 KiB
YAML
Raw Normal View History

2024-08-20 08:23:13 +00:00
name: Cargo Build & Test
on:
pull_request:
jobs:
2024-08-20 10:08:36 +00:00
test:
2024-09-04 06:04:31 +00:00
container: git.kjan.de/actions/rust-node@sha256:49fb2dad7814507334a38ea36ec2852a552cebc5b421ec22295d8a01421cd435
2024-08-20 10:09:43 +00:00
name: Tests
2024-08-20 10:08:36 +00:00
runs-on: ubuntu-latest
steps:
2024-09-04 06:04:31 +00:00
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
2024-08-20 10:08:36 +00:00
- name: ⚡ Cache
uses: https://git.kjan.de/actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
2024-08-20 10:08:36 +00:00
with:
path: |
~/.cargo/registry
~/.cargo/git
target/release/deps
target/release/build
target
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}-loadstar
- run: cargo test
2024-08-20 08:23:13 +00:00
can-publish:
2024-09-04 06:04:31 +00:00
container: git.kjan.de/actions/rust-node@sha256:49fb2dad7814507334a38ea36ec2852a552cebc5b421ec22295d8a01421cd435
2024-08-20 08:23:13 +00:00
name: Test publish
runs-on: ubuntu-latest
steps:
2024-09-04 06:04:31 +00:00
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
2024-08-20 08:24:46 +00:00
- name: ⚡ Cache
uses: https://git.kjan.de/actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
2024-08-20 08:24:46 +00:00
with:
path: |
~/.cargo/registry
~/.cargo/git
target/release/deps
target/release/build
target
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}-loadstar
2024-08-20 08:23:13 +00:00
- run: cargo publish -n
2024-08-20 09:57:40 +00:00
check-cargo-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
2024-09-04 06:04:31 +00:00
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
2024-08-20 09:57:40 +00:00
- 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
2024-08-20 08:23:13 +00:00
2024-08-20 09:57:40 +00:00
- 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