Skip to content

ci build & release

ci build & release #37

Workflow file for this run

# steal from https://github.com/Enter-tainer/typstyle/blob/master/.github/workflows/release.yml
name: CI
on:
push:
pull_request:
types: [opened, synchronize]
workflow_dispatch:
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run Clippy and Format
run: |
cargo fmt --all --check
cargo clippy --release
- name: Install Cargo Tarpaulin
uses: taiki-e/install-action@v2
with:
tool: cargo-tarpaulin
- name: Test with Coverage
run: cargo tarpaulin --workspace --timeout 120 --out xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
if: github.ref == 'refs/heads/master'
with:
token: ${{ secrets.CODECOV_TOKEN }}
pre-build:
permissions:
actions: write
contents: read
name: Duplicate Actions Detection
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
cancel_others: "true"
build:
needs: [pre-build]
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
rust-target: x86_64-pc-windows-msvc
platform: win32
arch: x64
- os: windows-latest
rust-target: aarch64-pc-windows-msvc
platform: win32
arch: arm64
- os: ubuntu-20.04
rust-target: x86_64-unknown-linux-gnu
platform: linux
arch: x64
- os: ubuntu-20.04
rust-target: aarch64-unknown-linux-gnu
platform: linux
arch: arm64
- os: ubuntu-20.04
rust-target: arm-unknown-linux-gnueabihf
platform: linux
arch: armhf
- os: macos-11
rust-target: x86_64-apple-darwin
platform: darwin
arch: x64
- os: macos-11
rust-target: aarch64-apple-darwin
platform: darwin
arch: arm64
name: build (${{ matrix.platform }}-${{ matrix.arch }})
runs-on: ${{ matrix.os }}
env:
target: ${{ matrix.platform }}-${{ matrix.arch }}
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust-target }}
- name: Install llvm
if: matrix.platform == 'linux'
run: |
sudo apt-get update
sudo apt-get install llvm
- name: Install AArch64 target toolchain
if: matrix.rust-target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu
- name: Install ARM target toolchain
if: matrix.rust-target == 'arm-unknown-linux-gnueabihf'
run: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf
- name: Build Binary
run: cargo build --release --target ${{ matrix.rust-target }}
- name: Upload Binary Artifacts
uses: actions/upload-artifact@v4
with:
name: typst-upgrade-${{ env.target }}
path: target/${{ matrix.rust-target }}/release/typst-upgrade${{ fromJSON('["", ".exe"]')[matrix.platform == 'win32'] }}
release:
runs-on: ubuntu-latest
needs: [build, test]
if: success() && startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Publish Crate
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display Artifact
run: ls -R artifacts
- uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "artifacts/*/*"
prerelease: true
allowUpdates: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true