rstml-component 0.2.6

HTML Component Library for Rust
Documentation
name: CI

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: full

jobs:
  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      # Always run main branch builds to completion.
      fail-fast: ${{ github.event_name == 'pull_request' ||
        (github.ref != 'refs/heads/main' &&
        !startsWith(github.ref, 'refs/tags/')) }}
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]

    steps:
      - name: Configure git
        run: |
          git config --global core.autocrlf false
          git config --global core.symlinks true
          git config --global fetch.parallel 32

      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable

      - name: Run sccache-cache
        if: github.repository == 'YoloDev/rstml-component'
        uses: mozilla-actions/sccache-action@v0.0.9

      - name: Configure sccache
        if: github.repository == 'YoloDev/rstml-component'
        shell: bash
        run: |
          if [[ -z "${{ secrets.SCCACHE_ENDPOINT }}" ]]; then
            echo "SCCACHE_ENDPOINT is not set"
          else
            echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
            echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
            echo "SCCACHE_BUCKET=$SCCACHE_BUCKET" >> $GITHUB_ENV
            echo "SCCACHE_REGION=$SCCACHE_REGION" >> $GITHUB_ENV
            echo "SCCACHE_ENDPOINT=$SCCACHE_ENDPOINT" >> $GITHUB_ENV
            echo "AWS_ACCESS_KEY_ID=$SCCACHE_ACCESS_KEY_ID" >> $GITHUB_ENV
            echo "AWS_SECRET_ACCESS_KEY=$SCCACHE_SECRET_ACCESS_KEY" >> $GITHUB_ENV
          fi
        env:
          SCCACHE_BUCKET: ${{ vars.SCCACHE_BUCKET }}
          SCCACHE_REGION: ${{ vars.SCCACHE_REGION }}
          SCCACHE_ENDPOINT: ${{ secrets.SCCACHE_ENDPOINT }}
          SCCACHE_ACCESS_KEY_ID: ${{ secrets.SCCACHE_ACCESS_KEY_ID }}
          SCCACHE_SECRET_ACCESS_KEY: ${{ secrets.SCCACHE_SECRET_ACCESS_KEY }}

      - name: Lint
        run: cargo clippy --all -- -D warnings

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

      - name: Create docs
        if: matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/main'
        run: |
          cargo doc --workspace --all-features
          echo '<!DOCTYPE html><meta charset="utf-8"><title>Redirecting to https://yolodev.github.io/rstml-component/rstml_component/index.html</title><meta http-equiv="refresh" content="0; URL=https://yolodev.github.io/rstml-component/rstml_component/index.html"><link rel="canonical" href="https://yolodev.github.io/rstml-component/rstml_component/index.html">' > ./target/doc/index.html

      - name: Upload artifact
        if: matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/main'
        uses: actions/upload-pages-artifact@v4
        with:
          path: "./target/doc/"

  publish-docs:
    name: Publish docs
    needs: test
    runs-on: ubuntu-latest
    if: github.repository == 'YoloDev/rstml-component' && github.ref == 'refs/heads/main'

    permissions:
      contents: read
      pages: write
      id-token: write

    concurrency:
      group: "pages"
      cancel-in-progress: true

    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}

    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4