systeroid/.github/workflows/cd.yml

192 lines
6.0 KiB
YAML

name: Continuous Deployment
on:
push:
tags:
- "v*.*.*"
jobs:
publish-github:
name: Publish on GitHub
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
TOOLCHAIN: [nightly]
CONFIG:
- { TARGET: x86_64-unknown-linux-gnu, FEATURES: "" }
- { TARGET: x86_64-unknown-linux-musl, FEATURES: "" }
- {
TARGET: x86_64-unknown-linux-gnu,
FEATURES: "--no-default-features",
}
- {
TARGET: x86_64-unknown-linux-musl,
FEATURES: "--no-default-features",
}
- {
TARGET: i686-unknown-linux-gnu,
FEATURES: "--no-default-features",
}
- {
TARGET: i686-unknown-linux-musl,
FEATURES: "--no-default-features",
}
- {
TARGET: aarch64-unknown-linux-gnu,
FEATURES: "--no-default-features",
}
- {
TARGET: aarch64-unknown-linux-musl,
FEATURES: "--no-default-features",
}
- {
TARGET: armv5te-unknown-linux-gnueabi,
FEATURES: "--no-default-features",
}
- {
TARGET: armv7-unknown-linux-gnueabihf,
FEATURES: "--no-default-features",
}
- {
TARGET: arm-unknown-linux-gnueabi,
FEATURES: "--no-default-features",
}
- {
TARGET: arm-unknown-linux-gnueabihf,
FEATURES: "--no-default-features",
}
- {
TARGET: riscv64gc-unknown-linux-gnu,
FEATURES: "--no-default-features",
}
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
--no-install-recommends \
--allow-unauthenticated \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
libxkbcommon-dev \
musl-tools
- name: Checkout the repository
uses: actions/checkout@v3
- name: Set the release version
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.TOOLCHAIN }}
target: ${{ matrix.CONFIG.TARGET }}
profile: minimal
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.CONFIG.FEATURES != '' }}
command: build
args: >
--release
--locked
--target ${{ matrix.CONFIG.TARGET }}
${{ matrix.CONFIG.FEATURES }}
- name: Prepare release assets
id: assets
shell: bash
run: |
release_dir="systeroid-${{ env.RELEASE_VERSION }}"
if [ -z "${{ matrix.CONFIG.FEATURES }}" ]; then
artifact_name="$release_dir-${{ matrix.CONFIG.TARGET }}_all-features.tar.gz"
else
artifact_name="$release_dir-${{ matrix.CONFIG.TARGET }}.tar.gz"
fi
mkdir -p release/man8
cp {README.md,LICENSE-*,CHANGELOG.md} release/
cp man8/* release/man8/
for bin in 'systeroid' 'systeroid-tui'; do
cp "target/${{ matrix.CONFIG.TARGET }}/release/$bin" release/
done
mv release/ "$release_dir/"
tar -czvf "$artifact_name" "$release_dir/"
echo "::set-output name=artifact_name::$artifact_name"
- name: Sign assets & generate checksums
run: |
sha512sum ${{ steps.assets.outputs.artifact_name }} > \
${{ steps.assets.outputs.artifact_name }}.sha512
echo "${{ secrets.GPG_KEY }}" | base64 --decode > signing.key
echo "${{ secrets.GPG_PASSPHRASE }}" | \
gpg --pinentry-mode=loopback --passphrase-fd 0 --import signing.key
echo "${{ secrets.GPG_PASSPHRASE }}" | \
gpg --pinentry-mode=loopback --passphrase-fd 0 --detach-sign \
${{ steps.assets.outputs.artifact_name }}
- name: Upload the release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.assets.outputs.artifact_name }}*
file_glob: true
overwrite: true
tag: ${{ github.ref }}
body: |
See [**CHANGELOG.md**](https://github.com/orhun/systeroid/blob/main/CHANGELOG.md) for release notes.
publish-crates-io:
name: Publish on crates.io
needs: publish-github
runs-on: ubuntu-20.04
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
--no-install-recommends \
--allow-unauthenticated \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
libxkbcommon-dev
- name: Checkout the repository
uses: actions/checkout@v3
- name: Set the release version
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Publish the core library
run: |
cargo publish \
--manifest-path systeroid-core/Cargo.toml \
--locked \
--token ${{ secrets.CARGO_TOKEN }}
- name: Wait for core library to be discoverable
shell: bash
run: |
crate_status="https://raw.githubusercontent.com/rust-lang/crates.io-index/master/sy/st/systeroid-core"
until curl -s "$crate_status" | grep -q '"vers":"${{ env.RELEASE_VERSION }}"'; do sleep 5; done;
- name: Publish the binaries
shell: bash
run: |
for bin in 'systeroid' 'systeroid-tui'; do
cargo publish \
--manifest-path "$bin/Cargo.toml" \
--locked \
--token ${{ secrets.CARGO_TOKEN }}
done