Skip to content

publish

publish #29

Workflow file for this run

name: "publish"
on:
create:
tags:
- '*'
# This is the example from the readme.
# On each push to the `release` branch it will create or update a GitHub release, build your app, and upload the artifacts to the release.
env:
CARGO_TERM_COLOR: always
BINARIES_LIST: 'ncbi estimate_capacity build_db classify'
PROJECT_PREFIX: 'kraken_rust_'
jobs:
build-and-release:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --release
# Set up the GitHub CLI
- name: Install GitHub CLI
run: |
brew install gh
if: matrix.platform == 'macos-latest'
- name: Install GitHub CLI
run: |
sudo apt install -y gh
if: matrix.platform == 'ubuntu-20.04'
- name: Install GitHub CLI
run: |
choco install gh
if: matrix.platform == 'windows-latest'
# Log in to the GitHub CLI
- name: Login to GitHub CLI
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
# # Create a release
# - name: Create Release
# id: create_release
# run: |
# gh release create ${{ github.ref_name }} \
# --title "Release ${{ github.ref_name }}" \
# --notes "Release notes for ${{ github.ref_name }}" \
# --draft
# shell: bash
- name: Prepare asset name
run: |
PLATFORM_TAG=$(echo ${{ matrix.platform }} | sed -e 's/-latest//' -e 's/ubuntu-20.04/linux-x86_64/' -e 's/macos/macos-x86_64/' -e 's/windows/windows-x86_64/')
echo "ASSET_NAME=${PROJECT_PREFIX}${PLATFORM_TAG}.tar.gz" >> $GITHUB_ENV
shell: bash
- name: Create tar.gz archive
run: |
mkdir -p ./target/release/packaged
for binary in ${{ env.BINARIES_LIST }}; do
cp "./target/release/$binary" "./target/release/packaged/"
done
tar czvf "./target/release/${{ env.ASSET_NAME }}" -C "./target/release/packaged/" .
shell: bash
- name: Upload Release Asset
run: |
mv ./target/release/ncbi ./target/release/${{ env.ASSET_NAME }}
gh release upload ${{ github.ref_name }} \
./target/release/${{ env.ASSET_NAME }} \
--clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
# This step is for building on CentOS 7, only run on ubuntu-latest
- name: Build on CentOS 7
if: matrix.platform == 'ubuntu-20.04'
run: |
docker run --name centos7-container -v $GITHUB_WORKSPACE:/github/workspace -w /github/workspace centos:7 \
/bin/bash -c "yum update -y && yum install -y gcc make openssl openssl-devel && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && export PATH=\$HOME/.cargo/bin:\$PATH && cd /github/workspace && cargo build --release"
mkdir -p ./target/release/packaged_centos7
for binary in $BINARIES_LIST; do
docker cp centos7-container:/github/workspace/target/release/$binary ./target/release/packaged_centos7/
done
tar czvf ./${PROJECT_PREFIX}centos7.tar.gz -C ./target/release/packaged_centos7 .
docker rm centos7-container
- name: Upload Release Asset for CentOS 7
if: matrix.platform == 'ubuntu-20.04'
run: |
gh release upload ${{ github.ref_name }} \
./${PROJECT_PREFIX}centos7.tar.gz \
--clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash