barkit 0.1.1

BarKit — a cross-platform and ultrafast toolkit for barcodes manipulation in FASTQ files
Documentation
name: Continuous Deployment

on:
  push:
    tags:
      - "v*.*.*"

jobs:
  generate-changelog:
    name: Generate changelog
    runs-on: ubuntu-22.04
    outputs:
      release_body: ${{ steps.git-cliff.outputs.content }}
    steps:
      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Install git-cliff
        uses: actions-rs/cargo@v1
        id: git-cliff
        with:
          command: install
          args: git-cliff
      - name: Run git-cliff to generate changelog
        run: git-cliff -vv --latest --no-exec --github-repo ${{ github.repository }} --config cliff.toml
        id: barkit

  publish-binaries:
    name: Publish binaries
    needs: generate-changelog
    runs-on: ${{ matrix.build.os }}
    strategy:
      fail-fast: false
      matrix:
        build:
          - {
              NAME: linux-x64-glibc,
              OS: ubuntu-22.04,
              TOOLCHAIN: stable,
              TARGET: x86_64-unknown-linux-gnu,
              NPM_PUBLISH: true,
            }
          - {
              NAME: linux-x64-musl,
              OS: ubuntu-22.04,
              TOOLCHAIN: stable,
              TARGET: x86_64-unknown-linux-musl,
              NPM_PUBLISH: false,
            }
          - {
              NAME: linux-x86-glibc,
              OS: ubuntu-22.04,
              TOOLCHAIN: stable,
              TARGET: i686-unknown-linux-gnu,
              NPM_PUBLISH: false,
            }
          - {
              NAME: linux-x86-musl,
              OS: ubuntu-22.04,
              TOOLCHAIN: stable,
              TARGET: i686-unknown-linux-musl,
              NPM_PUBLISH: false,
            }
          - {
              NAME: linux-arm64-glibc,
              OS: ubuntu-22.04,
              TOOLCHAIN: stable,
              TARGET: aarch64-unknown-linux-gnu,
              NPM_PUBLISH: true,
            }
          - {
              NAME: linux-arm64-musl,
              OS: ubuntu-22.04,
              TOOLCHAIN: stable,
              TARGET: aarch64-unknown-linux-musl,
              NPM_PUBLISH: false,
            }
          - {
              NAME: win32-x64-mingw,
              OS: windows-2022,
              TOOLCHAIN: stable,
              TARGET: x86_64-pc-windows-gnu,
              NPM_PUBLISH: false,
            }
          - {
              NAME: win32-x64-msvc,
              OS: windows-2022,
              TOOLCHAIN: stable,
              TARGET: x86_64-pc-windows-msvc,
              NPM_PUBLISH: true,
            }
          - {
              NAME: win32-x86-msvc,
              OS: windows-2022,
              TOOLCHAIN: stable,
              TARGET: i686-pc-windows-msvc,
              NPM_PUBLISH: false,
            }
          - {
              NAME: win32-arm64-msvc,
              OS: windows-2022,
              TOOLCHAIN: stable,
              TARGET: aarch64-pc-windows-msvc,
              NPM_PUBLISH: true,
            }
          - {
              NAME: darwin-x64,
              OS: macos-14,
              TOOLCHAIN: stable,
              TARGET: x86_64-apple-darwin,
              NPM_PUBLISH: true,
            }
          - {
              NAME: darwin-arm64,
              OS: macos-14,
              TOOLCHAIN: stable,
              TARGET: aarch64-apple-darwin,
              NPM_PUBLISH: true,
            }
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set the release version
        shell: bash
        run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> "$GITHUB_ENV"
      - name: Install dependencies
        shell: bash
        run: |
          if [[ "${{ matrix.build.NAME }}" == *"-musl" ]]; then
            sudo apt-get update
            sudo apt-get install -y --no-install-recommends \
              --allow-unauthenticated musl-tools
          fi
      - name: Install Rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: ${{ matrix.build.TOOLCHAIN }}
          target: ${{ matrix.build.TARGET }}
          override: true
      - name: Build (linux/macos)
        if: matrix.build.OS != 'windows-2022'
        uses: actions-rs/cargo@v1
        with:
          use-cross: true
          command: build
          args: --release --locked --target ${{ matrix.build.TARGET }}
      - name: Build (windows)
        if: matrix.build.OS == 'windows-2022'
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: --release --locked --target ${{ matrix.build.TARGET }} # --no-default-features
      - name: Prepare release assets
        shell: bash
        run: |
          mkdir -p release/
          cp {LICENSE,README.md,CHANGELOG.md} release/
          for bin in 'barkit'; do
            if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
              bin="${bin}.exe"
            fi
            cp "target/${{ matrix.build.TARGET }}/release/${bin}" release/
          done
          mv release/ barkit-${{ env.RELEASE_VERSION }}/
      - name: Create release artifacts
        shell: bash
        run: |
          if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
            7z a -tzip "barkit-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.zip" \
              barkit-${{ env.RELEASE_VERSION }}/
          else
            tar -czvf barkit-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \
              barkit-${{ env.RELEASE_VERSION }}/
            shasum -a 512 barkit-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \
              > barkit-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz.sha512
          fi
      - name: Sign the release
        if: matrix.build.OS == 'ubuntu-22.04' || matrix.build.OS == 'macos-14'
        run: |
          echo "${{ secrets.GPG_RELEASE_KEY }}" | base64 --decode > private.key
          echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
            --passphrase-fd 0 --import private.key
          echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
            --passphrase-fd 0 --detach-sign \
            barkit-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz
      - name: Publish to GitHub
        if: ${{ !contains(github.ref, '-') }}
        uses: svenstaro/upload-release-action@v2
        with:
          repo_token: ${{ secrets.API_TOKEN }}
          file: barkit-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}*
          file_glob: true
          overwrite: true
          tag: ${{ github.ref }}
          release_name: "Release v${{ env.RELEASE_VERSION }}"
          body: "${{ needs.generate-changelog.outputs.release_body }}"
      - name: Publish to GitHub (pre-release)
        if: ${{ contains(github.ref, '-') }}
        uses: svenstaro/upload-release-action@v2
        with:
          repo_token: ${{ secrets.API_TOKEN }}
          file: barkit-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}*
          file_glob: true
          overwrite: true
          tag: ${{ github.ref }}
          release_name: "Pre-release v${{ env.RELEASE_VERSION }}"
          prerelease: true

  publish-crates-io:
    name: Publish on crates.io
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set the release version
        run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> "$GITHUB_ENV"
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: x86_64-unknown-linux-gnu
      - name: Publish the barkit-extract binary
        run: |
          cargo publish --manifest-path barkit-extract/Cargo.toml \
            --locked --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
      - name: Publish the barkit binary
        run: |
          cargo publish --manifest-path Cargo.toml \
            --locked --token ${{ secrets.CARGO_REGISTRY_TOKEN }}