oxide-mvu 0.4.2

A standalone MVU runtime for Rust with no_std support for embedded systems
Documentation
name: Release

on:
  push:
    tags:
      - 'v*.*.*'

env:
  CARGO_TERM_COLOR: always

jobs:
  verify:
    name: Verify Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Extract version from tag
        id: get_version
        run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

      - name: Extract version from Cargo.toml
        id: cargo_version
        run: |
          CARGO_VERSION=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)
          echo "VERSION=$CARGO_VERSION" >> $GITHUB_OUTPUT

      - name: Verify versions match
        run: |
          if [ "${{ steps.get_version.outputs.VERSION }}" != "${{ steps.cargo_version.outputs.VERSION }}" ]; then
            echo "Error: Tag version (${{ steps.get_version.outputs.VERSION }}) does not match Cargo.toml version (${{ steps.cargo_version.outputs.VERSION }})"
            exit 1
          fi
          echo "Versions match: ${{ steps.get_version.outputs.VERSION }}"

      - name: Run tests
        run: cargo test --all-features --verbose

      - name: Verify package
        run: cargo package --verbose

  publish:
    name: Publish to crates.io
    needs: verify
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Publish to crates.io
        run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

  create-release:
    name: Create GitHub Release
    needs: publish
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Extract version from tag
        id: get_version
        run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

      - name: Extract changelog
        id: changelog
        run: |
          VERSION="${{ steps.get_version.outputs.VERSION }}"
          if [ -f CHANGELOG.md ]; then
            # Extract the section for this version from CHANGELOG.md
            CHANGELOG=$(sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | sed '$d')
            if [ -z "$CHANGELOG" ]; then
              CHANGELOG="Release $VERSION"
            fi
          else
            CHANGELOG="Release $VERSION"
          fi
          echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
          echo "$CHANGELOG" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v1
        with:
          name: Release v${{ steps.get_version.outputs.VERSION }}
          body: ${{ steps.changelog.outputs.CHANGELOG }}
          draft: false
          prerelease: false
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}