Workflow file for this run
This file contains hidden or 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
on: | |
push: | |
tags: | |
- '*' | |
workflow_dispatch: | |
name: Create Release & Publish Crate | |
permissions: | |
contents: write | |
jobs: | |
cargo_version: | |
name: Get version number from Cargo.toml | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.awk.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get the version number using awk | |
id: awk | |
run: echo "version=$(awk -F\" '/^version/ {print $2}' Cargo.toml)" >> "$GITHUB_OUTPUT" | |
test: | |
name: Run Cargo Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install stable toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- run: cargo test | |
fmt: | |
name: Rustfmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
- name: Enforce formatting | |
run: cargo fmt --check | |
clippy: | |
name: Clippy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: clippy | |
- uses: Swatinem/rust-cache@v2 | |
- name: Linting | |
run: cargo clippy -- -D warnings | |
security_audit: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: taiki-e/install-action@cargo-deny | |
- name: Scan for vulnerabilities | |
run: cargo deny check advisories | |
build_linux: | |
runs-on: ubuntu-latest | |
needs: | |
- cargo_version | |
- clippy | |
- fmt | |
- security_audit | |
- test | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Make binaries and packages | |
id: make | |
run: make linux | |
- name: List the current directory | |
run: ls -alh | |
- name: Generate shasum for RPM | |
run: shasum -a 256 check-jitter-opsview-${{ needs.cargo_version.outputs.version }}-1.x86_64.rpm > check-jitter-opsview-${{ needs.cargo_version.outputs.version }}-1.x86_64.rpm.sha256 | |
- name: Generate shasum for DEB | |
run: shasum -a 256 check-jitter-opsview_${{ needs.cargo_version.outputs.version }}-1_amd64.deb > check-jitter-opsview_${{ needs.cargo_version.outputs.version }}-1_amd64.deb.sha256 | |
- name: Rename binary | |
run: mv check_jitter-x86_64-unknown-linux-musl check_jitter | |
- name: Archive binary as tar.gz | |
run: tar -czf check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.gz check_jitter | |
- name: Generate shasum for tar.gz | |
run: shasum -a 256 check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.gz > check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.gz.sha256 | |
- name: Archive binary as tar.xz | |
run: tar -cJf check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.xz check_jitter | |
- name: Generate shasum for tar.xz | |
run: shasum -a 256 check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.xz > check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.xz.sha256 | |
- name: Archive binary as zstd | |
run: tar -c --zstd -f check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.zst check_jitter | |
- name: Generate shasum for tar.zst | |
run: shasum -a 256 check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.zst > check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.zst.sha256 | |
- name: Upload tar.gz artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.gz | |
path: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.gz | |
- name: Upload tar.gz sha256 artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.gz.sha256 | |
path: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.gz.sha256 | |
- name: Upload tar.xz artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.xz | |
path: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.xz | |
- name: Upload tar.xz sha256 artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.xz.sha256 | |
path: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.xz.sha256 | |
- name: Upload tar.zst artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.zst | |
path: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.zst | |
- name: Upload tar.zst sha256 artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.zst.sha256 | |
path: check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.zst.sha256 | |
- name: Upload Opsview RPM | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-opsview-${{ needs.cargo_version.outputs.version }}-1.x86_64.rpm | |
path: check-jitter-opsview-${{ needs.cargo_version.outputs.version }}-1.x86_64.rpm | |
- name: Upload Opsview RPM sha256 | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-opsview-${{ needs.cargo_version.outputs.version }}-1.x86_64.rpm.sha256 | |
path: check-jitter-opsview-${{ needs.cargo_version.outputs.version }}-1.x86_64.rpm.sha256 | |
- name: Upload Opsview DEB | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-opsview_${{ needs.cargo_version.outputs.version }}-1_amd64.deb | |
path: check-jitter-opsview_${{ needs.cargo_version.outputs.version }}-1_amd64.deb | |
- name: Upload Opsview DEB sha256 | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-opsview_${{ needs.cargo_version.outputs.version }}-1_amd64.deb.sha256 | |
path: check-jitter-opsview_${{ needs.cargo_version.outputs.version }}-1_amd64.deb.sha256 | |
build_windows: | |
runs-on: ubuntu-latest | |
needs: | |
- cargo_version | |
- clippy | |
- fmt | |
- security_audit | |
- test | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Make binaries and packages | |
id: make | |
run: make windows | |
- name: List the current directory | |
run: ls -alh | |
- name: Rename binary | |
run: mv check_jitter-x86_64-pc-windows-gnu.exe check_jitter.exe | |
- name: Install zip | |
run: sudo apt update && sudo apt install -y zip | |
- name: Archive binary | |
run: /usr/bin/zip check-jitter-${{ needs.cargo_version.outputs.version }}-x86_64-windows.zip check_jitter.exe | |
- name: Generate shasum for zip | |
run: shasum -a 256 check-jitter-${{ needs.cargo_version.outputs.version }}-x86_64-windows.zip > check-jitter-${{ needs.cargo_version.outputs.version }}-x86_64-windows.zip.sha256 | |
- name: Upload zip artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-${{ needs.cargo_version.outputs.version }}-x86_64-windows.zip | |
path: check-jitter-${{ needs.cargo_version.outputs.version }}-x86_64-windows.zip | |
- name: Upload zip sha256 artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: check-jitter-${{ needs.cargo_version.outputs.version }}-x86_64-windows.zip.sha256 | |
path: check-jitter-${{ needs.cargo_version.outputs.version }}-x86_64-windows.zip.sha256 | |
create_release: | |
runs-on: ubuntu-latest | |
needs: | |
- cargo_version | |
- build_linux | |
- build_windows | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
- name: List the current directory | |
run: ls -alh | |
- name: Create GH Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.gz | |
check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.xz | |
check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.zst | |
check-jitter-opsview-${{ needs.cargo_version.outputs.version }}-1.x86_64.rpm | |
check-jitter-opsview_${{ needs.cargo_version.outputs.version }}-1_amd64.deb | |
check-jitter-${{ needs.cargo_version.outputs.version }}-x86_64-windows.zip | |
check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.gz.sha256 | |
check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.xz.sha256 | |
check-jitter-x86_64-unknown-linux-musl-${{ needs.cargo_version.outputs.version }}.tar.zst.sha256 | |
check-jitter-opsview-${{ needs.cargo_version.outputs.version }}-1.x86_64.rpm.sha256 | |
check-jitter-opsview_${{ needs.cargo_version.outputs.version }}-1_amd64.deb.sha256 | |
check-jitter-${{ needs.cargo_version.outputs.version }}-x86_64-windows.zip.sha256 | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
publish: | |
needs: | |
- create_release | |
name: Publish Crate to crates.io | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Install stable toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- run: cargo publish --token ${CRATES_IO_TOKEN} | |
env: | |
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} |