Skip to content

Deploy

Deploy #14

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
inputs:
new_version:
description: New version to deploy
required: true
type: string
env:
BIN_NAME: cotp
PROJECT_NAME: cotp
REPO_NAME: replydev/cotp
jobs:
dist:
name: Dist
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # don't fail other jobs if one fails
matrix:
build: [x86_64-linux, aarch64-linux, x86_64-macos, aarch64-macos, x86_64-win-msvc]
include:
- build: x86_64-linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- build: aarch64-linux
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- build: x86_64-macos
os: macos-latest
target: x86_64-apple-darwin
- build: aarch64-macos
os: macos-latest
target: aarch64-apple-darwin
- build: x86_64-win-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
# Cache dependencies
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}-release
- name: Install cross for arm64 compilation
if: matrix.build == 'aarch64-linux'
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Install Dependencies for Linux x86_64
if: matrix.build == 'x86_64-linux'
run: sudo apt update && sudo apt install -y libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev
- name: Build release binary (arm64)
if: matrix.build == 'aarch64-linux'
run: cross build --release --locked --target ${{ matrix.target }}
- name: Build release binary (x86_64)
if: matrix.build != 'aarch64-linux'
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Build archive
shell: bash
run: |
mkdir dist
if [ "${{ matrix.os }}" == *"windows"* ]; then
cp "target/${{ matrix.target }}/release/$BIN_NAME.exe" "dist/"
else
cp "target/${{ matrix.target }}/release/$BIN_NAME" "dist/"
fi
- uses: actions/upload-artifact@v4.3.4
with:
name: cotp-${{ matrix.build }}
path: dist
publish:
name: "Publish binaries to release page"
needs: [dist]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: false
- uses: actions/download-artifact@v4
- run: ls -al cotp-*
- name: Build archive
shell: bash
env:
NEW_VERSION: ${{ inputs.new_version }}
run: |
set -ex
rm -rf tmp
mkdir tmp
mkdir dist
for dir in cotp-* ; do
platform=${dir#"cotp-"}
unset exe
# If platform contains "win" then append .exe to the filename
if [[ "$platform" == *"win"* ]]; then
exe=".exe"
fi
pkgname=$PROJECT_NAME-$NEW_VERSION-$platform
mkdir tmp/$pkgname
# cp LICENSE README.md tmp/$pkgname
mv cotp-$platform/$BIN_NAME$exe tmp/$pkgname
chmod +x tmp/$pkgname/$BIN_NAME$exe
if [ "$exe" = "" ]; then
tar cJf dist/$pkgname.tar.xz -C tmp $pkgname
else
(cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname)
fi
done
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*
file_glob: true
tag: v${{ inputs.new_version }}
overwrite: true
publish_on_cargo_crates:
name: "Publish crate on crates.io"
needs: [dist]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: false
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Login
run: cargo login ${{ secrets.CRATE_AUTH_TOKEN }}
- name: List
run: cargo package --list
- name: Publish
run: cargo publish