ssvc 0.1.0

Implementation of the SSVC specification in Rust
name: CI

on:
  pull_request:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Ensure Rust toolchain
        run: |
          rustup update stable
          rustup default stable
      - name: Cache cargo registry
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
      - name: Build
        run: cargo build --verbose
      - name: Run tests
        run: cargo test --verbose
      - name: Publish dry-run
        if: github.ref_type != 'tag'
        run: |
          cargo publish --dry-run -p ssvc --verbose --no-verify --locked

  publish-crates:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write    
    needs:
      - build
    if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'beta') && !contains(github.ref, 'alpha')
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: 'true'
      - name: Update assets
        run: ./update_assets.sh
      - uses: rust-lang/crates-io-auth-action@v1
        id: auth
      - name: Update rustup
        run: rustup update stable --no-self-update
      - name: Publish
        run: cargo publish --locked -p csaf-rs --verbose
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}