Skip to content

Bump version: 2.0.0 #297

Bump version: 2.0.0

Bump version: 2.0.0 #297

Workflow file for this run

on: [push, pull_request]
name: CI
env:
CARGO_DEB: 1.37.0
CARGO_RPM: 0.8.0
CARGO_OUTDATED: 0.11.1
CARGO_AUDIT: 0.17.0
TECTONIC_VER: 0.14.1
jobs:
fmt:
name: Format check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install rustfmt
run: rustup component add rustfmt
- name: Perform format check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true
- name: Cache cargo tools
id: cargo-tools-cache
uses: actions/cache@v3
with:
path: cargo-tools
key: lint-tools-${{ env.CARGO_OUTDATED }}-${{ env.CARGO_AUDIT }}
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: lint-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Install cargo tools if not cached
if: steps.cargo-tools-cache.outputs.cache-hit != 'true'
run: |
cargo install cargo-outdated --version ${{ env.CARGO_OUTDATED }} --root cargo-tools --target-dir cargo-tools-build
cargo install cargo-audit --version ${{ env.CARGO_AUDIT }} --root cargo-tools --target-dir cargo-tools-build
- name: Clippy
run: cargo clippy --no-deps -- -D warnings
- name: Outdated dependencies
# TODO: add support for githubActions format in cargo-outdated directly?
shell: python
run: |
import json
import subprocess
import os
env = os.environ.copy()
env["PATH"] = os.getcwd() + "/cargo-tools/bin:" + env["PATH"]
ps = subprocess.Popen(['cargo', 'outdated', '--format', 'json'], stdout=subprocess.PIPE, env=env)
output = json.load(ps.stdout)
outdated = output['dependencies']
for dep in outdated:
msg = "{}: project: {}, compat: {}, latest: {}, kind: {}".format(dep['name'], dep['project'], dep['compat'], dep['latest'], dep['kind'])
print("::warning title=Outdated dependency '{}'::{}".format(dep['name'], msg))
- name: Audit
run: |
PATH="$PATH:$PWD/cargo-tools/bin" cargo audit
test-linux:
name: Test on Linux
needs: fmt
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: test-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Cache tectonic
id: tectonic-cache
uses: actions/cache@v3
with:
path: |
~/tectonic-bin
~/.cache/Tectonic
key: test-tectonic-${{ runner.os }}-${{ env.TECTONIC_VER }}-${{ hashFiles('src/render/templates/pdf.hbs') }}
- name: Download tectonic binary if not cached
if: steps.tectonic-cache.outputs.cache-hit != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p ~/tectonic-bin
cd ~/tectonic-bin
gh release download --repo tectonic-typesetting/tectonic tectonic@${{ env.TECTONIC_VER }} -p tectonic-${{ env.TECTONIC_VER }}-x86_64-unknown-linux-musl.tar.gz
tar -xzf tectonic-${{ env.TECTONIC_VER }}-x86_64-unknown-linux-musl.tar.gz
ls -la ~/tectonic-bin
- name: Test
run: |
PATH="$PATH:$HOME/tectonic-bin" tectonic -V
PATH="$PATH:$HOME/tectonic-bin" cargo test --locked -- --nocapture
- name: Install apt packages
id: apt-packages
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: nodejs poppler-utils
version: 1.0
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: |
~/.npm
key: test-npm-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Additional tests
run: |
PATH="$PATH:$HOME/tectonic-bin" tectonic -V
PATH="$PATH:$HOME/tectonic-bin" cargo test --locked -- --ignored --nocapture
test-windows:
name: Test on Windows
needs: fmt
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: test-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Cache tectonic
id: tectonic-cache
uses: actions/cache@v3
with:
path: ~\AppData\Local\TectonicProject # as per https://github.com/actions/cache/tree/ac25611caef967612169ab7e95533cf932c32270#windows-environment-variables
key: test-tectonic-${{ runner.os }}-${{ env.TECTONIC_VER }}-${{ hashFiles('src/render/templates/pdf.hbs') }}
- name: Download tectonic binary if not cached
if: steps.tectonic-cache.outputs.cache-hit != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir ~\AppData\Local\TectonicProject\bin
cd ~\AppData\Local\TectonicProject\bin
gh release download --repo tectonic-typesetting/tectonic tectonic@${{ env.TECTONIC_VER }} -p tectonic-${{ env.TECTONIC_VER }}-x86_64-pc-windows-msvc.zip
7z x tectonic-${{ env.TECTONIC_VER }}-x86_64-pc-windows-msvc.zip
rm tectonic-${{ env.TECTONIC_VER }}-x86_64-pc-windows-msvc.zip
dir ~\AppData\Local\TectonicProject\bin
- name: Test
run: |
$env:PATH += ";$env:USERPROFILE\AppData\Local\TectonicProject\bin"
Write-Output $env:PATH
tectonic -V
cargo test --locked -- --nocapture
msrv:
name: MSRV check
needs: fmt
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Extract MSRV
id: get-msrv
run: echo msrv=$(yq .package.rust-version Cargo.toml -oy) | tee -a "$GITHUB_OUTPUT"
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ steps.get-msrv.outputs.msrv }}
override: true
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: msrv-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Perform MSRV check
uses: actions-rs/cargo@v1
with:
command: check
args: --locked --tests
book-check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: 'latest'
- run: make book
build-linux:
name: Linux build
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/ci'
needs:
- test-linux
- test-windows
- msrv
- book-check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: x86_64-unknown-linux-musl
override: true
- name: Install APT packages
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: musl-tools # provides musl-gcc
version: 1.0
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: build-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Cache cargo tools
id: cargo-tools-cache
uses: actions/cache@v3
with:
path: cargo-tools
key: build-tools-${{ env.CARGO_DEB }}-${{ env.CARGO_RPM }}
- name: Install cargo tools if not cached
if: steps.cargo-tools-cache.outputs.cache-hit != 'true'
run: |
cargo install cargo-deb --version ${{ env.CARGO_DEB }} --root cargo-tools --target-dir cargo-tools-build
cargo install cargo-generate-rpm --version ${{ env.CARGO_RPM }} --root cargo-tools --target-dir cargo-tools-build
- name: Build
run: cargo build --locked --release --target=x86_64-unknown-linux-musl
- name: Generate packages
run: |
PATH="$PATH:$PWD/cargo-tools/bin" cargo deb --no-build --target=x86_64-unknown-linux-musl -o target/debian/bard.deb
PATH="$PATH:$PWD/cargo-tools/bin" cargo generate-rpm --target=x86_64-unknown-linux-musl -o target/generate-rpm/bard.rpm
# call upload-artifact per file to flatten resulting directory structure
- name: Upload linux binary
uses: actions/upload-artifact@v3
with:
name: bard-linux
path: target/x86_64-unknown-linux-musl/release/bard
if-no-files-found: error
- name: Upload deb package
uses: actions/upload-artifact@v3
with:
name: bard-linux
path: target/debian/bard.deb
if-no-files-found: error
- name: Upload rpm package
uses: actions/upload-artifact@v3
with:
name: bard-linux
path: target/generate-rpm/bard.rpm
if-no-files-found: error
build-windows:
name: Windows build
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/ci'
needs:
- test-linux
- test-windows
- msrv
- book-check
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: build-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Build
run: |
cargo build --locked --release
Move-Item -Force -Path target\release\bard.exe -Destination target\release\bard-no-tectonic.exe
- name: Upload Windows exe
uses: actions/upload-artifact@v3
with:
name: bard-windows
path: target/release/bard-no-tectonic.exe
if-no-files-found: error
deploy-docker:
name: Deploy to DockerHub
if: startsWith(github.ref, 'refs/tags/')
needs:
- build-linux
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3 # need the Dockerfile
- uses: actions/download-artifact@v3
with:
name: bard-linux
path: bard-linux
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver: docker
- name: Docker metadata
uses: docker/metadata-action@v4
id: meta
with:
images: vojtechkral/bard
tags: |
type=ref,event=tag
type=sha,prefix=git-
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: .github/workflows/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
daft-release:
name: Draft a Release
if: startsWith(github.ref, 'refs/tags/')
needs:
- build-linux
- build-windows
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
# no options -> gets all the artifacts
- name: Create a Release draft
uses: softprops/action-gh-release@v1
with:
draft: true
name: "bard ${{ github.ref_name }}"
files: |
./bard-linux/bard
./bard-linux/bard.deb
./bard-linux/bard.rpm
./bard-windows/bard-no-tectonic.exe