digital_blasphemy_client 0.1.2

A client for the Digital Blasphemy API
Documentation
name: 'Run main workflow'

on:
  pull_request:
  push:
    branches:
      - "main"
    tags:
      - "*"

permissions:
  contents: write
  pull-requests: read

concurrency:
  group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
  cancel-in-progress: true

jobs:
  check-formatting:
    runs-on: "ubuntu-latest"
    timeout-minutes: 30
    if: github.ref_type != 'tags'
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
      - name: Run formatting check
        run: cargo fmt --all -- --check
  lint:
    runs-on: "ubuntu-latest"
    timeout-minutes: 30
    if: github.ref_type != 'tags'
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
      - name: Run lint
        run: cargo clippy --all-features --all-targets
  test-build:
    strategy:
      matrix:
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest
    runs-on: ${{ matrix.os }}
    timeout-minutes: 30
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
      - name: Run release build
        if: github.ref_type == 'tags'
        run: cargo build --release
      - name: Run build
        if: github.ref_type != 'tags'
        run: cargo build
      - name: Run tests
        if: github.ref_type != 'tags'
        run: cargo test
  release-dry-run:
    runs-on: "ubuntu-latest"
    timeout-minutes: 30
    needs:
      - test-build
    if: ${{ github.ref_type != 'tag' }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
      - name: Publish to crates.io
        uses: katyo/publish-crates@v2
        with:
          dry-run: true
          registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
  release:
    runs-on: "ubuntu-latest"
    timeout-minutes: 30
    needs:
      - test-build
    if: ${{ github.ref_type == 'tag' }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
      - name: Configure git
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
      - name: Set version for release
        run: |
          cargo install cargo-edit --no-default-features --features "set-version"
          cargo set-version ${{ github.ref_name }}
      - name: Commit release version
        run: |
          git add Cargo.toml Cargo.lock
          git commit -m "chore: set version to ${{ github.ref_name }}"
      - name: Publish to crates.io
        uses: katyo/publish-crates@v2
        with:
          registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
      - name: Set version for next release
        run: |
          NEXT_VERSION=$(echo ${{ github.ref_name }} | awk -F. -v OFS=. '{$NF += 1 ; print}')-alpha
          cargo set-version "$NEXT_VERSION"
      - name: Commit next release version
        run: |
          git add Cargo.toml Cargo.lock
          git commit -m "chore: set version to $NEXT_VERSION"
          git push origin HEAD:main
      - name: Create Release
        if: ${{ github.ref_type == 'tag' }}
        uses: ncipollo/release-action@v1.18.0
        with:
          generateReleaseNotes: true
          makeLatest: true