Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:

jobs:
build-release:
needs: create-release
name: build-release
runs-on: ${{ matrix.os }}
env:
RUST_BACKTRACE: 1
strategy:
matrix:
build:
- linux musl x64
- linux musl aarch64
- macos x64
- macos aarch64
include:
- build: linux musl x64
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
- build: linux musl aarch64
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-musl
- build: macos x64
os: macos-latest
rust: stable
target: x86_64-apple-darwin
- build: macos aarch64
os: macos-latest
rust: stable
target: aarch64-apple-darwin
steps:
- name: Set release tag
run: |
if [ "$GITHUB_EVENT_NAME" == 'workflow_dispatch' ]; then
echo "RELEASE_TAG=main" >> "$GITHUB_ENV"
else
echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV"
fi

- name: Checkout repository
uses: actions/checkout@v4

- name: Install musl-tools
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y --no-install-recommends musl-tools

- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: "${{ matrix.target }},wasm32-wasip1"
# Just to make sure the cache doesn't interfere with the build here
cache: false
rustflags: ""

- name: Build release binary
run: cargo xtask ci cross ${{ matrix.target }}

# this breaks on aarch64 and this if conditional isn't working for some reason: TODO: investigate
#- name: Strip release binary
# if: runner.target != 'aarch64-unknown-linux-musl' && runner.target != 'aarch64-apple-darwin'
# run: strip "target/${{ matrix.target }}/release/fswatcher"

- name: Create checksum
id: make-checksum
working-directory: ./target/${{ matrix.target }}/release
run: |
name="fswatcher-${{ matrix.target }}.sha256sum"
if [[ "$RUNNER_OS" != "macOS" ]]; then
sha256sum "fswatcher" > "${name}"
else
shasum -a 256 "fswatcher" > "${name}"
fi
echo "::set-output name=name::${name}"

- name: Tar release
id: make-artifact
working-directory: ./target/${{ matrix.target }}/release
run: |
name="fswatcher-${{ matrix.target }}.tar.gz"
tar cvzf "${name}" "fswatcher"
echo "::set-output name=name::${name}"

- name: Upload release archive
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./target/${{ matrix.target }}/release/${{ steps.make-artifact.outputs.name }}
asset_name: fswatcher-${{matrix.target}}.tar.gz
asset_content_type: application/octet-stream

- name: Upload checksum
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./target/${{ matrix.target }}/release/${{ steps.make-checksum.outputs.name }}
asset_name: fswatcher-${{matrix.target}}.sha256sum
asset_content_type: text/plain

create-release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: create_release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event_name == 'workflow_dispatch' && '' || github.ref }}
release_name: Release ${{ github.event_name == 'workflow_dispatch' && 'main' || github.ref }}
draft: ${{ github.event_name == 'workflow_dispatch' }}
prerelease: false
68 changes: 68 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Rust

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Setup toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: ""

- name: Build
run: cargo xtask build

test:
name: Test

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Setup toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: ""

- name: Test
run: cargo xtask test

format:
name: Check Formatting
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: ""

- name: Check Format
run: cargo xtask format --check
Loading