Use fend-core
for download stats
#240
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: build | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_MIN_STACK: 16777212 | |
permissions: {} | |
jobs: | |
build: | |
strategy: | |
matrix: | |
platform: [ubuntu-latest, macos-latest, windows-latest] | |
include: | |
- platform: ubuntu-latest | |
artifact-path: target/release/fend | |
artifact-platform-name: linux-x64 | |
env-command: ">> $GITHUB_ENV" | |
- platform: macos-latest | |
artifact-path: target/release/fend | |
artifact-platform-name: macos-x64 | |
env-command: ">> $GITHUB_ENV" | |
- platform: windows-latest | |
artifact-path: target/release/fend.exe | |
artifact-platform-name: windows-x64-exe | |
env-command: "| Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append" | |
permissions: | |
contents: read | |
runs-on: ${{ matrix.platform }} | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Update Rust | |
run: rustup update | |
- uses: swatinem/rust-cache@v2 | |
- name: Clippy, rustfmt | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
run: | | |
rustup component add clippy | |
cargo clippy --workspace --all-targets --all-features -- -D warnings | |
cargo fmt -- --check | |
- name: Build, get version | |
run: | | |
cargo run --release --package fend -- help | |
echo "FEND_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages | .[0].version')" ${{ matrix.env-command }} | |
# Only run unit tests on non-Linux platforms since Linux runs | |
# them as part of code coverage testing | |
- name: Test | |
if: ${{ matrix.platform != 'ubuntu-latest' }} | |
run: | | |
cargo test --workspace -- --nocapture --quiet | |
- name: Generate code coverage | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
run: | | |
RUSTFLAGS="-C instrument-coverage" \ | |
cargo test --workspace -- --quiet | |
sudo apt-get update -y | |
sudo apt-get install -yq llvm | |
llvm-profdata merge -sparse */*.profraw -o fend.profdata | |
llvm-cov report \ | |
--use-color \ | |
--ignore-filename-regex='/.cargo/registry' \ | |
--ignore-filename-regex='/rustc' \ | |
--instr-profile=fend.profdata \ | |
$( \ | |
for file in \ | |
$( \ | |
RUSTFLAGS="-C instrument-coverage" \ | |
cargo test --workspace --no-run --message-format=json \ | |
| jq -r "select(.profile.test == true) | .filenames[]" \ | |
| grep -v dSYM - \ | |
); \ | |
do \ | |
printf "%s %s " -object $file; \ | |
done \ | |
) | |
llvm-cov export \ | |
--ignore-filename-regex='/.cargo/registry' \ | |
--ignore-filename-regex='/rustc' \ | |
--format='lcov' \ | |
--instr-profile=fend.profdata \ | |
$( \ | |
for file in \ | |
$( \ | |
RUSTFLAGS="-C instrument-coverage" \ | |
cargo test --workspace --no-run --message-format=json \ | |
| jq -r "select(.profile.test == true) | .filenames[]" \ | |
| grep -v dSYM - \ | |
); \ | |
do \ | |
printf "%s %s " -object $file; \ | |
done \ | |
) >coverage.txt | |
- name: Upload to codecov.io | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
uses: codecov/codecov-action@v3 | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: fend-${{ env.FEND_VERSION }}-${{ matrix.artifact-platform-name }} | |
path: ${{ matrix.artifact-path }} | |
if-no-files-found: error | |
- name: Build (Apple Silicon) | |
if: ${{ matrix.platform == 'macos-latest' }} | |
run: | | |
rustup target add aarch64-apple-darwin | |
cargo build --release --package fend --target aarch64-apple-darwin | |
- name: Upload artifacts (Apple Silicon) | |
uses: actions/upload-artifact@v3 | |
if: ${{ matrix.platform == 'macos-latest' }} | |
with: | |
name: fend-${{ env.FEND_VERSION }}-macos-aarch64 | |
path: target/aarch64-apple-darwin/release/fend | |
if-no-files-found: error | |
- name: Build (linux-armv7-gnueabihf) | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
run: | | |
rustup target add armv7-unknown-linux-gnueabihf | |
sudo apt-get install -yq gcc-arm-linux-gnueabihf | |
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=/usr/bin/arm-linux-gnueabihf-gcc | |
cargo build --release --package fend --target armv7-unknown-linux-gnueabihf | |
- name: Upload artifacts (linux-armv7-gnueabihf) | |
uses: actions/upload-artifact@v3 | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
with: | |
name: fend-${{ env.FEND_VERSION }}-linux-armv7-gnueabihf | |
path: target/armv7-unknown-linux-gnueabihf/release/fend | |
if-no-files-found: error | |
- name: Build (linux-aarch64-gnu) | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
run: | | |
rustup target add aarch64-unknown-linux-gnu | |
sudo apt-get install -yq gcc-aarch64-linux-gnu | |
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc | |
cargo build --release --package fend --target aarch64-unknown-linux-gnu | |
- name: Upload artifacts (linux-aarch64-gnu) | |
uses: actions/upload-artifact@v3 | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
with: | |
name: fend-${{ env.FEND_VERSION }}-linux-aarch64-gnu | |
path: target/aarch64-unknown-linux-gnu/release/fend | |
if-no-files-found: error | |
- name: Set up Homebrew | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
run: echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH | |
- name: Build fend-wasm | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
run: | | |
brew install pandoc | |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
./web/build.sh | |
- name: Upload GitHub Pages artifact | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: web | |
- name: Build man page | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
run: | | |
./documentation/build.sh | |
- name: Upload man page | |
if: ${{ matrix.platform == 'ubuntu-latest' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: man-page | |
path: documentation/fend.1 | |
if-no-files-found: error | |
- name: Build MSIX installer | |
if: ${{ github.ref == 'refs/heads/main' && matrix.platform == 'windows-latest' }} | |
run: | | |
.\windows-msix\build.ps1 | |
env: | |
WINDOWS_CERT_PASSWORD: ${{ secrets.WINDOWS_CERT_PASSWORD }} | |
- name: Upload artifacts (MSIX) | |
uses: actions/upload-artifact@v3 | |
if: ${{ github.ref == 'refs/heads/main' && matrix.platform == 'windows-latest' }} | |
with: | |
name: fend-windows-x64-msix | |
path: windows-msix/fend-windows-x64.msix | |
if-no-files-found: error | |
- name: Build MSI installer | |
if: ${{ matrix.platform == 'windows-latest' }} | |
run: | | |
.\windows-wix\build.ps1 | |
- name: Upload artifacts (MSI) | |
uses: actions/upload-artifact@v3 | |
if: ${{ matrix.platform == 'windows-latest' }} | |
with: | |
name: fend-windows-x64-msi | |
path: windows-wix/build/fend-windows-x64.msi | |
if-no-files-found: error | |
- name: Deploy Telegram Bot | |
if: ${{ github.ref == 'refs/heads/main' && matrix.platform == 'ubuntu-latest' }} | |
run: | | |
./telegram-bot/build.sh | |
TELEGRAM_BOT_API_TOKEN=${{ secrets.TELEGRAM_BOT_API_TOKEN }} \ | |
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \ | |
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \ | |
./telegram-bot/deploy.sh | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [build] | |
if: ${{ github.ref == 'refs/heads/main' }} | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 |