Skip to content

Commit

Permalink
Update workflow dependencies and switch to dtolnay/rust-toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
theRookieCoder committed Feb 3, 2024
1 parent f0d224a commit bff5d4f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 101 deletions.
126 changes: 35 additions & 91 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,155 +23,99 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Create `out/`
run: mkdir out

# Install Rust on the various platforms

- name: Install Rust for macOS
if: matrix.os == 'macos-latest'
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: aarch64-apple-darwin
targets: aarch64-apple-darwin, x86-64-apple-darwin

- name: Install Rust for Windows
if: matrix.os == 'windows-latest'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
uses: dtolnay/rust-toolchain@stable

- name: Install Windows GNU toolchain
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-pc-windows-gnu
- name: Install Linux musl toolchain
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/toolchain@v1
with:
default: true
toolchain: stable
target: x86_64-unknown-linux-musl
- name: Install Linux musl toolchain for ARM64
- name: Install Rust for Linux
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: aarch64-unknown-linux-musl
targets: x86_64-pc-windows-gnu, x86_64-unknown-linux-musl, aarch64-unknown-linux-musl

- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install gcc-mingw-w64-x86-64 musl musl-tools gcc-aarch64-linux-gnu
curl https://apt.llvm.org/llvm.sh | sudo bash -s 16
sudo apt update
sudo apt install gcc-mingw-w64-x86-64 musl musl-tools gcc-aarch64-linux-gnu
curl https://apt.llvm.org/llvm.sh | sudo bash -s 17
- name: Install Rust cache
uses: Swatinem/rust-cache@v2

- name: Lint code
uses: actions-rs/cargo@v1
with:
command: clippy
run: cargo clippy

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
# Linux CIs don't have GUIs
args: --no-default-features
run: cargo test --no-default-features

- name: Build macOS Intel
if: matrix.os == 'macos-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=x86_64-apple-darwin --release
run: |
cargo build --target=x86_64-apple-darwin --release
zip -r out/ferium-macos-x64.zip -j target/x86_64-apple-darwin/release/ferium
- name: Build macOS ARM
if: matrix.os == 'macos-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=aarch64-apple-darwin --release

- name: Zip macOS outputs
if: matrix.os == 'macos-latest'
run: |
zip -r out/ferium-macos-x64.zip -j target/x86_64-apple-darwin/release/ferium
cargo build --target=aarch64-apple-darwin --release
zip -r out/ferium-macos-arm.zip -j target/aarch64-apple-darwin/release/ferium
- name: Build Windows MSVC
if: matrix.os == 'windows-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=x86_64-pc-windows-msvc --release
- name: Zip Windows output
if: matrix.os == 'windows-latest'
run: Compress-Archive -Path "target\x86_64-pc-windows-msvc\release\ferium.exe" -DestinationPath "out\ferium-windows-msvc.zip"
run: |
cargo build --target=x86_64-pc-windows-msvc --release
Compress-Archive -Path "target\x86_64-pc-windows-msvc\release\ferium.exe" -DestinationPath "out\ferium-windows-msvc.zip"
- name: Build Linux
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=x86_64-unknown-linux-musl --release
run: |
cargo build --target=x86_64-unknown-linux-musl --release
zip -r out/ferium-linux.zip -j target/x86_64-unknown-linux-musl/release/ferium
- name: Build ARM Linux
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: rustc
args: --target=aarch64-unknown-linux-musl --release -- -Clink-self-contained=yes -Clinker=rust-lld
env:
CC_aarch64_unknown_linux_musl: clang-16

- name: Zip Linux outputs
if: matrix.os == 'ubuntu-latest'
run: |
zip -r out/ferium-linux.zip -j target/x86_64-unknown-linux-musl/release/ferium
cargo rustc --target=aarch64-unknown-linux-musl --release -- -Clink-self-contained=yes -Clinker=rust-lld
zip -r out/ferium-linux-arm64.zip -j target/aarch64-unknown-linux-musl/release/ferium
env:
CC_aarch64_unknown_linux_musl: clang-17

- name: Build Linux nogui
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=x86_64-unknown-linux-musl --release --no-default-features
run: |
cargo build --target=x86_64-unknown-linux-musl --release --no-default-features
zip -r out/ferium-linux-nogui.zip -j target/x86_64-unknown-linux-musl/release/ferium
- name: Build ARM Linux nogui
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: rustc
args: --target=aarch64-unknown-linux-musl --release --no-default-features -- -Clink-self-contained=yes -Clinker=rust-lld
env:
CC_aarch64_unknown_linux_musl: clang-16

- name: Zip Linux nogui outputs
if: matrix.os == 'ubuntu-latest'
run: |
zip -r out/ferium-linux-nogui.zip -j target/x86_64-unknown-linux-musl/release/ferium
cargo rustc --target=aarch64-unknown-linux-musl --release --no-default-features -- -Clink-self-contained=yes -Clinker=rust-lld
zip -r out/ferium-linux-arm64-nogui.zip -j target/aarch64-unknown-linux-musl/release/ferium
env:
CC_aarch64_unknown_linux_musl: clang-17

- name: Build Windows GNU
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/cargo@v1
with:
command: build
args: --target=x86_64-pc-windows-gnu --release
- name: Zip Windows GNU output
if: matrix.os == 'ubuntu-latest'
run: zip -r out/ferium-windows-gnu.zip -j target/x86_64-pc-windows-gnu/release/ferium.exe
run: |
cargo build --target=x86_64-pc-windows-gnu --release
run: zip -r out/ferium-windows-gnu.zip -j target/x86_64-pc-windows-gnu/release/ferium.exe
- name: Upload build artefacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: binaries
path: out/ferium*.zip
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,31 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Upload to Crates
uses: actions-rs/cargo@v1
with:
command: publish
uses: dtolnay/rust-toolchain@stable

- name: Upload to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Download artifacts
uses: dawidd6/action-download-artifact@v2
uses: dawidd6/action-download-artifact@v3
with:
workflow_conclusion: success
workflow: build.yml
name: binaries
path: ./out

- name: Create sha256sum for Scoop
run: sha256sum ./out/ferium-windows-msvc.zip | cut -d ' ' -f 1 > ./out/ferium-windows-msvc.zip.sha256
# Remove the dots for the markdown header
- name: MD Header
run: echo "MD_HEADER=$(echo ${{ github.ref_name }} | sed 's/\.//g')" >> $GITHUB_ENV

- name: Create release
uses: softprops/action-gh-release@v1
with:
Expand Down Expand Up @@ -71,7 +70,8 @@ jobs:
commit_username: "Ilesh Thiada"
commit_email: ileshkt@gmail.com
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}

- name: Update Homebrew formula
uses: mislav/bump-homebrew-formula-action@v2
uses: mislav/bump-homebrew-formula-action@v3
env:
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}

0 comments on commit bff5d4f

Please sign in to comment.