maybe-backoff 0.5.0

Retry operations with exponential backoff policy.
Documentation
# Adopted from https://github.com/azriel91/peace/blob/main/.github/workflows/publish.yml
# Copyright 2023 Azriel Hoh MIT / Apache-2.0

name: Publish

on:
  push:
    tags:
      - "*"

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build_and_test_linux:
    name: Build and Test (Linux)
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: "Build and test"
        run: cargo test

  crates_io_publish:
    name: Publish (crates.io)
    needs:
      - build_and_test_linux

    runs-on: ubuntu-latest
    timeout-minutes: 25
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable

      - name: cargo-release cache restore
        id: cargo_release_cache_restore
        uses: actions/cache/restore@v4
        with:
          path: ~/.cargo/bin/cargo-release
          key: ${{ runner.os }}-cargo-release

      - run: cargo install cargo-release
        if: steps.cargo_release_cache_restore.outputs.cache-hit != 'true'

      - name: cargo-release cache save
        id: cargo_release_cache_save
        uses: actions/cache/save@v4
        if: always() && steps.cargo_release_cache_restore.outputs.cache-hit != 'true'
        with:
          path: ~/.cargo/bin/cargo-release
          key: ${{ runner.os }}-cargo-release

      - name: cargo login
        run: |-
          echo "${{ secrets.CRATES_IO_API_TOKEN }}" | cargo login

      # allow-branch HEAD is because GitHub actions switches
      # to the tag while building, which is a detached head
      - name: "cargo release publish"
        run: |-
          cargo release \
            publish \
            --workspace \
            --allow-branch HEAD \
            --no-confirm \
            --execute