Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add Windows builds #100

Merged
merged 1 commit into from
Oct 30, 2024
Merged
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
108 changes: 108 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Build (Release)

on:
push:
tags:
- "*"
workflow_dispatch:

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- { runner: macos-13, rust_target: aarch64-apple-darwin }
- { runner: macos-13, rust_target: x86_64-apple-darwin }
- { runner: ubuntu-22.04, rust_target: x86_64-unknown-linux-musl }
- { runner: windows-2019, rust_target: x86_64-pc-windows-msvc }
name: Build ${{ matrix.platform.rust_target }}
runs-on: ${{ matrix.platform.runner }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- if: ${{ runner.os == 'Linux' }}
name: "[Linux] Disable initramfs and man-db update"
continue-on-error: true
run: |
sudo mkdir -p /etc/initramfs-tools/
echo -e 'update_initramfs=no\nbackup_initramfs=no' | sudo tee /etc/initramfs-tools/update-initramfs.conf
sudo rm -f /var/lib/man-db/auto-update
- if: ${{ runner.os == 'Linux' }}
name: "[Linux] Install platform dependencies"
uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad
with: { packages: "musl-tools" }

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17
with:
targets: ${{ runner.os == 'macOS' && 'aarch64-apple-darwin,x86_64-apple-darwin' || matrix.platform.rust_target }}
toolchain: stable

- name: Setup Cargo cache
uses: swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84
with: { prefix-key: "cargo-${{ matrix.platform.rust_target }}" }

- name: Build release
run: |
cargo build --release --target ${{ matrix.platform.rust_target }}
mkdir -p ./build
exe="${{runner.os == 'Windows' && '.exe' || ''}}"
mv "./target/${{ matrix.platform.rust_target }}/release/marmite${exe}" ./build/
shell: bash

- name: Compress binary
run: |
cd ./build
base_filename="marmite-${{ github.base_ref || github.ref_name }}-${{ matrix.platform.rust_target }}"
if [ "${{ runner.os == 'Windows' }}" = "true" ]; then
7z a "../build/${base_filename}.zip" *
else
tar -czvf "../build/${base_filename}.tar.gz" *
fi
shell: bash

- name: Upload binary as artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: marmite-${{ github.base_ref || github.ref_name }}-${{ matrix.platform.rust_target }}
path: |
./build/*.tar.gz
./build/*.zip

release:
name: Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download binaries
uses: actions/download-artifact@v4
with:
path: ./build
merge-multiple: true

- name: Generate sha256 checksums
run: |
cd build
shasum -a 256 * > SHA256SUMS

- name: Publish Release
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
with:
files: |
./build/*
body: |
> [!TIP]
> Expand the "Assets" section below to download the binaries for this release.
name: ${{ github.base_ref || github.ref_name }}
make_latest: ${{ endsWith(github.ref, '-pre') == false }}
prerelease: ${{ endsWith(github.ref, '-pre') }}
generate_release_notes: true
103 changes: 0 additions & 103 deletions .github/workflows/build.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ url = "2.5.2"
rust-embed = { version = "8.5.0", features = ["interpolate-folder-path"]}
lazy_static = "1.5.0"

[profile.release]
codegen-units = 1
incremental = false
panic = "abort"
lto = true
opt-level = "s"
strip = true

[profile.dev]
incremental = false

43 changes: 36 additions & 7 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,45 @@
check:
cargo fmt -- --check
cargo clippy
cargo fmt -- --check
cargo clippy

pedantic:
cargo fmt -- --check
cargo clippy -- -W clippy::pedantic
cargo fmt -- --check
cargo clippy -- -W clippy::pedantic

fmt:
cargo fmt
cargo fmt

fix:
cargo clippy --fix
cargo clippy --fix

pedantic_fix:
cargo clippy --fix -- -W clippy::pedantic
cargo clippy --fix -- -W clippy::pedantic

[doc('Bump version in Cargo.toml')]
[group('maintainer')]
bumpversion VERSION:
#!/usr/bin/env bash
VERSION="{{ trim_start_match(VERSION, "v") }}"
shopt -s expand_aliases
alias set-version='cargo set-version --package marmite --locked'
set-version "$VERSION" || cargo install -y [email protected] && set-version "$VERSION"
cargo generate-lockfile
just fmt
git add ./Cargo.toml ./Cargo.lock
git commit -m "chore: bump version to $VERSION"

[doc('Push a new tag to the repository')]
[group('maintainer')]
pushtag TAG:
#!/usr/bin/env bash
VERSION="{{ trim_start_match(TAG, "v") }}"
git push origin :refs/tags/$VERSION # delete the origin tag
git tag -d $VERSION # delete the local tag
git tag -a "$VERSION" -m "chore: push $VERSION"
git push origin $VERSION

[doc('Publish a new version (bumpversion + pushtag)')]
[group('maintainer')]
publish TAG:
just bumpversion {{ TAG }}
just pushtag {{ TAG }}