add ci action #2

Open
valentin wants to merge 16 commits from workflows-2 into main
2 changed files with 45 additions and 9 deletions

36
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: CI
on:
pull_request:
jobs:
test:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
if: matrix.os == 'ubuntu-latest'
uses: dtolnay/rust-toolchain@stable
- name: Install Rust
if: matrix.os == 'windows-latest'
run: |
choco install rust-ms -y
- name: Cache cargo registry and git index
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build and test
run: cargo test --workspace --verbose

View File

@@ -65,12 +65,12 @@ jobs:
- name: Publish to Gitea registry
run: cargo publish --registry gitea --allow-dirty
# - name: Publish to crates.io
# env:
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# run: |
# if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
# echo "CARGO_REGISTRY_TOKEN is not set. Set it in repository secrets to publish to crates.io"
# exit 1
# fi
# cargo publish --token "$CARGO_REGISTRY_TOKEN" --allow-dirty
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
echo "CARGO_REGISTRY_TOKEN is not set. Set it in repository secrets to publish to crates.io"
exit 1
fi
cargo publish --token "$CARGO_REGISTRY_TOKEN" --allow-dirty