publish #13
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
include: | |
- platform: macos-latest | |
os: macos | |
- platform: ubuntu-20.04 | |
os: linux | |
- platform: windows-latest | |
os: windows | |
- platform: ubuntu-20.04 | |
os: centos | |
container: centos:7 | |
runs-on: ${{ matrix.platform }} | |
container: ${{ matrix.container }} | |
steps: | |
- uses: actions/checkout@v4 | |
# Install dependencies for CentOS 7 | |
- name: Install dependencies on CentOS 7 | |
if: matrix.os == 'centos' | |
run: | | |
yum update -y | |
yum install -y gcc make openssl-devel pkgconfig | |
curl https://sh.rustup.rs -sSf | sh -s -- -y | |
source $HOME/.cargo/env | |
rustup default stable | |
# Build for CentOS 7 | |
- name: Build on CentOS 7 | |
if: matrix.os == 'centos' | |
run: cargo build --release | |
- name: Build | |
run: cargo build --release | |
if: matrix.os != 'centos' | |
# 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/') | |
ASSET_NAME="ncbi-${PLATFORM_TAG}$(if [ ${{ matrix.os }} = 'windows' ]; then echo '.exe'; elif [ ${{ matrix.os }} = 'centos' ]; then echo '-centos7'; fi)" | |
echo "ASSET_NAME=$ASSET_NAME" >> $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 |