ringdrop 0.7.0

P2P streamed file transfer with ring-based access control, built on iroh and bao protocols
Documentation
name: Publish

on:
  push:
    tags: ['v*']

jobs:
  ci_tests:
    uses: ./.github/workflows/tests.yml

  build:
    name: Build ${{ matrix.target }}
    needs: [ci_tests]
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            archive: rdrop-x86_64-unknown-linux-gnu.tar.gz
          - os: macos-latest
            target: aarch64-apple-darwin
            archive: rdrop-aarch64-apple-darwin.tar.gz
          - os: macos-latest
            target: x86_64-apple-darwin
            archive: rdrop-x86_64-apple-darwin.tar.gz
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            archive: rdrop-x86_64-pc-windows-msvc.zip
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - uses: Swatinem/rust-cache@v2
        with:
          save-if: false

      - name: Build
        run: cargo build --release --target ${{ matrix.target }}

      - name: Package (Unix)
        if: runner.os != 'Windows'
        run: |
          cp target/${{ matrix.target }}/release/rdrop rdrop
          tar czf ${{ matrix.archive }} rdrop

      - name: Package (Windows)
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          Copy-Item target\${{ matrix.target }}\release\rdrop.exe rdrop.exe
          Compress-Archive rdrop.exe ${{ matrix.archive }}

      - uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.target }}
          path: ${{ matrix.archive }}

  publish:
    name: Publish
    needs: [build]
    runs-on: ubuntu-latest
    environment: release
    permissions:
      id-token: write
      contents: write
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable

      - uses: rust-lang/crates-io-auth-action@v1
        id: auth

      - run: cargo publish --no-verify
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

      - uses: actions/download-artifact@v4
        with:
          path: artifacts
          merge-multiple: true

      - name: Extract release notes from CHANGELOG.md
        run: |
          VERSION="${GITHUB_REF_NAME#v}"
          awk "/^## \[${VERSION}\]/{p=1;next} /^## \[/{p=0} p" CHANGELOG.md > RELEASE_NOTES.md

      - name: Create GitHub release
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          gh release create "${{ github.ref_name }}" \
            --title "${{ github.ref_name }}" \
            --notes-file RELEASE_NOTES.md \
            --latest \
            artifacts/*

      - name: Update Homebrew formula
        env:
          TAP_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
          TAG: ${{ github.ref_name }}
        run: |
          SHA256=$(curl -sL "https://github.com/rikettsie/ringdrop/archive/refs/tags/${TAG}.tar.gz" | sha256sum | cut -d' ' -f1)
          git clone "https://x-access-token:${TAP_TOKEN}@github.com/rikettsie/homebrew-tap.git"
          cd homebrew-tap
          sed -i "s|url \".*\"|url \"https://github.com/rikettsie/ringdrop/archive/refs/tags/${TAG}.tar.gz\"|" Formula/rdrop.rb
          sed -i "s|sha256 \".*\"|sha256 \"${SHA256}\"|" Formula/rdrop.rb
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add Formula/rdrop.rb
          git commit -m "chore: bump rdrop to ${TAG}"
          git push

      - name: Update Scoop manifest
        env:
          TAP_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
          TAG: ${{ github.ref_name }}
        run: |
          VERSION="${TAG#v}"
          SHA256=$(curl -sL "https://github.com/rikettsie/ringdrop/releases/download/${TAG}/rdrop-x86_64-pc-windows-msvc.zip" | sha256sum | cut -d' ' -f1)
          git clone "https://x-access-token:${TAP_TOKEN}@github.com/rikettsie/scoop-bucket.git"
          cd scoop-bucket
          jq --arg version "$VERSION" \
             --arg hash "$SHA256" \
             --arg url "https://github.com/rikettsie/ringdrop/releases/download/${TAG}/rdrop-x86_64-pc-windows-msvc.zip" \
             '.version = $version | .architecture."64bit".hash = $hash | .architecture."64bit".url = $url' \
             bucket/rdrop.json > tmp.json && mv tmp.json bucket/rdrop.json
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add bucket/rdrop.json
          git commit -m "chore: bump rdrop to ${TAG}"
          git push