test-fork 0.1.3

A library for running tests in separate processes.
Documentation
# Copyright (C) 2025 Daniel Mueller <deso@posteo.net>
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

name: Publish

on:
  workflow_dispatch:

jobs:
  version:
    name: Retrieve version
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.version.outputs.version }}
    steps:
    - uses: actions/checkout@v4
    - id: version
      shell: bash
      run: |
        cargo generate-lockfile
        pkgid="$(cargo pkgid)"
        # Format is typically
        #   file://<path>/<crate>#<version>
        # but could also be along the lines of
        #   file://<path>/<crate>#<actual-crate-name>@<version>
        version="$(echo ${pkgid}                   | cut -d '#' -f2 | cut -d '@' -f2 | grep -o '[^:]*$')"
        core_version="$(cd core && cargo pkgid     | cut -d '#' -f2 | cut -d '@' -f2 | grep -o '[^:]*$')"
        macros_version="$(cd macros && cargo pkgid | cut -d '#' -f2 | cut -d '@' -f2 | grep -o '[^:]*$')"

        if [ -z "${version}" ]; then
          echo "Invalid version string: ${pkgid}"
          exit 1
        fi
        if [ "${version}" != "${core_version}" ]; then
          echo "test-fork and test-fork-core have differing version (${version} vs. ${core_version}"
          exit 1
        fi
        if [ "${version}" != "${macros_version}" ]; then
          echo "test-fork and test-fork-macros have differing version (${version} vs. ${macros_version}"
          exit 1
        fi
        echo "Determined crate version: ${version}"
        echo "version=${version}" >> $GITHUB_OUTPUT
  test:
    uses: ./.github/workflows/test.yml
    secrets: inherit
  publish:
    needs: [test, version]
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: dtolnay/rust-toolchain@stable
    - name: Dry-run package creation
      # Can't verify test-fork for it may depend on yet-to-be-published
      # test-fork-macros.
      run: cargo package --package core --package macros --workspace --exclude test-fork
    - name: Create git tag
      env:
        version: ${{ needs.version.outputs.version }}
      run: |
        curl --location \
          --fail-with-body \
          --request POST \
          --url https://api.github.com/repos/${{ github.repository }}/releases \
          --header "Accept: application/vnd.github+json" \
          --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
          --header "X-GitHub-Api-Version: 2022-11-28" \
          --data "{
              \"tag_name\":\"v${version}\",
              \"target_commitish\":\"${{ github.ref }}\",
              \"name\":\"v${version}\",
              \"draft\":false,
              \"prerelease\":false,
              \"generate_release_notes\":false
            }"
    - name: Publish test-fork-core
      run: cd core/ && cargo publish --no-verify --token "${CARGO_REGISTRY_TOKEN}"
      env:
        CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
    - name: Publish test-fork-macros
      run: cd macros/ && cargo publish --no-verify --token "${CARGO_REGISTRY_TOKEN}"
      env:
        CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
    - name: Publish test-fork
      run: cargo publish --no-verify --token "${CARGO_REGISTRY_TOKEN}"
      env:
        CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}