name: Main
on:
push:
branches: [main]
tags: [v*.*.*]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
prek:
name: Prek
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Run prek
uses: j178/prek-action@53276d8b0d10f8b6672aa85b4588c6921d0370cc
lint:
name: Lint code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Rust Cache
uses: swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4
- name: Lint code
run: make lint-ci
test:
name: Test
permissions:
contents: write
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Rust Cache
uses: swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4
- uses: taiki-e/install-action@7a562dfa955aa2e4d5b0fd6ebd57ff9715c07b0b with:
tool: nextest,cargo-llvm-cov
- name: Run tests
run: make test-ci
- name: Upload coverage
uses: deadnews/coverage-badge-action@bc4aaf332f25c52d1e8dd21ef9ed0b2337ad39af if: github.event_name == 'push' && matrix.os == 'ubuntu-latest'
with:
file: lcov.info
type: lcov
cargo-deploy:
name: Release to crates.io
if: github.ref_type == 'tag'
needs: [lint, test]
environment: crates.io
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Authenticate to crates.io
uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe id: auth
- name: Set version in Cargo.toml
run: sed "s|^version.*=.*$|version = '${GITHUB_REF_NAME#v}'|" -i Cargo.toml
- name: Sync Cargo.lock version
run: cargo generate-lockfile
- name: Publishing on crates.io
run: cargo publish --locked --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
pypi-build:
name: Build wheel
if: github.ref_type == 'tag'
needs: [lint, test]
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, target: x86_64, manylinux: 2_28 }
- { os: ubuntu-latest, target: aarch64, manylinux: 2_28 }
- { os: ubuntu-latest, target: x86_64, manylinux: musllinux_1_2 }
- { os: ubuntu-latest, target: aarch64, manylinux: musllinux_1_2 }
- { os: macos-latest, target: aarch64 }
- { os: windows-latest, target: x86_64 }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set version
shell: bash
run: sed "s|^version.*|version = '${GITHUB_REF_NAME#v}'|" Cargo.toml > t && mv t Cargo.toml
- name: Build wheel
uses: pyo3/maturin-action@04ac600d27cdf7a9a280dadf7147097c42b757ad with:
command: build
args: --release --compatibility pypi
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || '' }}
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f with:
name: wheel-${{ matrix.os }}-${{ matrix.target }}-${{ matrix.manylinux || 'native' }}
path: target/wheels/
pypi-deploy:
name: Release to PyPI
if: github.ref_type == 'tag'
needs: [pypi-build]
environment: pypi
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c with:
pattern: wheel-*
merge-multiple: true
path: dist/
- uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e with:
packages-dir: dist
github-deploy:
name: Release to GitHub
if: github.ref_type == 'tag'
needs: [lint, test]
environment: github-releases
permissions:
contents: write
env:
CHANGELOG: https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md
PRERELEASE: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Create GitHub Release
run: |
gh release create "${GITHUB_REF_NAME}" \
--title "${GITHUB_REF_NAME}" \
--notes="See [the CHANGELOG](${CHANGELOG}) for more details." \
--draft="${PRERELEASE}" \
--prerelease="${PRERELEASE}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
github-build:
name: Build binary (${{ matrix.target }})
if: github.ref_type == 'tag'
needs: [github-deploy]
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu }
- { os: ubuntu-latest, target: x86_64-unknown-linux-musl }
- { os: ubuntu-latest, target: aarch64-unknown-linux-gnu }
- { os: ubuntu-latest, target: aarch64-unknown-linux-musl }
- { os: macos-latest, target: aarch64-apple-darwin }
- { os: windows-latest, target: x86_64-pc-windows-msvc }
- { os: windows-latest, target: aarch64-pc-windows-msvc }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set version
shell: bash
run: sed "s|^version.*|version = '${GITHUB_REF_NAME#v}'|" Cargo.toml > t && mv t Cargo.toml
- name: Build and upload binary
uses: taiki-e/upload-rust-binary-action@10c1cf6a3da113ad4e60018e386570529aa5f1d3 with:
bin: imgup
target: ${{ matrix.target }}
aur-deploy:
name: Release to AUR
if: true && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta')
needs: [github-build]
environment:
name: aur
url: https://aur.archlinux.org/packages/${{ github.event.repository.name }}-bin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Update version in PKGBUILD
run: |
pkgver="${GITHUB_REF_NAME#v}"
pkgver="${pkgver//-/_}"
sed "s|^pkgver=.*$|pkgver=\"${pkgver}\"|" -i PKGBUILD
- name: Deploy PKGBUILD to the AUR
uses: ksxgithub/github-actions-deploy-aur@abe8ac26b51011c88be58c8809fd2ac674068ea5 with:
pkgname: ${{ github.event.repository.name }}-bin
pkgbuild: ./PKGBUILD
commit_username: ${{ github.actor }}
commit_email: ${{ github.actor }}@users.noreply.github.com
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Upstream release ${{ github.ref_name }}
updpkgsums: true
test: true