Skip to content

publish

publish #19

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
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
id: prep
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=ncbi-$PLATFORM_TAG$(if [ ${{ runner.os }} = 'Windows' ]; then echo '.exe'; fi)" >> $GITHUB_ENV
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 && source $HOME/.cargo/env && cargo build --release"
docker cp centos7-container:/github/workspace/target/release/ncbi ./ncbi-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 }} \
./ncbi-centos7 \
--clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
# build-on-centos7:
# runs-on: ubuntu-latest
# needs: build-and-release
# steps:
# - name: Checkout code on the runner
# uses: actions/checkout@v4
# - name: Create Docker container
# run: |
# docker create -w /github/workspace --name centos7-container centos:7 tail -f /dev/null
# docker start centos7-container
# - name: Copy repo to the container
# run: |
# docker cp $GITHUB_WORKSPACE/. centos7-container:/github/workspace
# - name: Install dependencies in the container
# run: |
# docker exec centos7-container yum update -y
# docker exec centos7-container yum install -y gcc make openssl openssl-devel
# - name: Install Rust and Cargo and Build on CentOS 7
# run: |
# docker exec centos7-container bash -c "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"
# - name: Copy artifact from container to runner
# run: |
# docker cp centos7-container:/github/workspace/target/release/ncbi ./ncbi-centos7
# # - name: Install GitHub CLI
# # run: |
# # sudo apt install -y gh
# # - name: Login to GitHub CLI
# # run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
# - name: Upload Release Asset for CentOS 7
# run: |
# gh release upload ${{ github.ref_name }} \
# ./ncbi-centos7 \
# --clobber
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# shell: bash
# - name: Cleanup
# if: always()
# run: docker rm -f centos7-container