mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
feat: Add support for multiple CPU targets in Rust workflow (#1707)
* Enhance CI with x86-64-v2 build and release notes Add build job for x86-64-v2 architecture and update release process. Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * Enhance CI workflow for x86-64 architecture support Updated CI workflow to support additional x86-64 architectures and removed deprecated build job for x86-64-v2. Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * Refactor Rust CI workflow with new build steps Refactor CI workflow to simplify architecture and improve clarity. Added new build steps for standard, x86-64-v2, and x86-64-v3 releases. Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * add macOS Intel x86-64-v3 * Add x86-64-v4 Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * treatment for OCD Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * 0 Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * rollback Removed x86-64-v4 architecture from the workflow and adjusted related steps for x86-64-v2 and x86-64-v3. Updated comments and artifact names accordingly. Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * Refactor CI workflow for Rust project Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * Refactor CI workflow for Rust with additional checks Updated CI workflow for Rust project to include formatting checks, unused dependency detection, and enhanced build and test steps across multiple platforms and architectures. Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * Update GitHub Actions workflow for Rust project Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * Upgrade checkout action from v4 to v6 Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * Update rust.yml Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * Update GitHub Actions workflow for Rust Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * Update install-action version in rust.yml Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> * Update rust.yml Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com> --------- Signed-off-by: Missing_Love <42416195+Q2297045667@users.noreply.github.com>
This commit is contained in:
192
.github/workflows/rust.yml
vendored
192
.github/workflows/rust.yml
vendored
@@ -2,7 +2,9 @@ name: Cargo Build, Test, and Linting
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
@@ -15,123 +17,171 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
toolchain:
|
||||
- stable
|
||||
toolchain: [stable]
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
|
||||
- run: rustup component add rustfmt
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo fmt --check
|
||||
|
||||
machete:
|
||||
name: Detect unused dependencies
|
||||
runs-on: ubuntu-latest
|
||||
needs: [format]
|
||||
strategy:
|
||||
matrix:
|
||||
toolchain:
|
||||
- stable
|
||||
toolchain: [stable]
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
|
||||
- uses: bnjbvr/cargo-machete@main
|
||||
|
||||
clippy_debug:
|
||||
name: Run lints (debug)
|
||||
runs-on: ubuntu-latest
|
||||
needs: [machete]
|
||||
strategy:
|
||||
matrix:
|
||||
toolchain:
|
||||
- stable
|
||||
toolchain: [stable]
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
|
||||
- run: rustup component add clippy
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Clippy (debug)
|
||||
run: cargo clippy --all-targets --all-features
|
||||
- run: cargo clippy --all-targets --all-features
|
||||
|
||||
clippy_release:
|
||||
name: Run lints (release)
|
||||
runs-on: ubuntu-latest
|
||||
needs: [machete]
|
||||
strategy:
|
||||
matrix:
|
||||
toolchain:
|
||||
- stable
|
||||
toolchain: [stable]
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
|
||||
- run: rustup component add clippy
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Clippy (release)
|
||||
run: cargo clippy --release --all-targets --all-features
|
||||
- run: cargo clippy --release --all-targets --all-features
|
||||
|
||||
build_and_test:
|
||||
name: Build project and test
|
||||
name: Build and test (${{ matrix.os }}, ${{ matrix.arch_variant }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: [clippy_debug, clippy_release]
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
[
|
||||
ubuntu-latest,
|
||||
ubuntu-24.04-arm,
|
||||
windows-latest,
|
||||
windows-11-arm,
|
||||
macos-latest,
|
||||
macos-15-intel,
|
||||
]
|
||||
toolchain:
|
||||
- stable
|
||||
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-latest, macos-15-intel]
|
||||
arch_variant: [standard, x86-64-v3]
|
||||
toolchain: [stable]
|
||||
exclude:
|
||||
- os: ubuntu-24.04-arm
|
||||
arch_variant: x86-64-v3
|
||||
- os: windows-11-arm
|
||||
arch_variant: x86-64-v3
|
||||
- os: macos-latest
|
||||
arch_variant: x86-64-v3
|
||||
- os: macos-15-intel
|
||||
arch_variant: standard
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
|
||||
- uses: taiki-e/install-action@nextest
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Cargo nextest
|
||||
run: cargo nextest run --verbose
|
||||
- name: Cargo doctest
|
||||
run: cargo test --doc --verbose
|
||||
- name: Set CPU flags
|
||||
if: matrix.arch_variant != 'standard'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "RUSTFLAGS=-C target-cpu=${{ matrix.arch_variant }}" >> "$GITHUB_ENV"
|
||||
- run: cargo nextest run --verbose
|
||||
- run: cargo test --doc --verbose
|
||||
|
||||
build_release:
|
||||
name: Build project in release
|
||||
name: Build Release (${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.variant }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: [build_and_test]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
[
|
||||
ubuntu-latest,
|
||||
ubuntu-24.04-arm,
|
||||
windows-latest,
|
||||
windows-11-arm,
|
||||
macos-latest,
|
||||
macos-15-intel,
|
||||
]
|
||||
toolchain:
|
||||
- stable
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
platform: linux
|
||||
arch: x86_64
|
||||
variant: standard
|
||||
bin: pumpkin
|
||||
- os: ubuntu-latest
|
||||
platform: linux
|
||||
arch: x86_64
|
||||
variant: x86-64-v3
|
||||
bin: pumpkin
|
||||
- os: ubuntu-24.04-arm
|
||||
platform: linux
|
||||
arch: aarch64
|
||||
variant: standard
|
||||
bin: pumpkin
|
||||
- os: windows-latest
|
||||
platform: windows
|
||||
arch: x86_64
|
||||
variant: standard
|
||||
bin: pumpkin.exe
|
||||
- os: windows-latest
|
||||
platform: windows
|
||||
arch: x86_64
|
||||
variant: x86-64-v3
|
||||
bin: pumpkin.exe
|
||||
- os: windows-11-arm
|
||||
platform: windows
|
||||
arch: aarch64
|
||||
variant: standard
|
||||
bin: pumpkin.exe
|
||||
- os: macos-latest
|
||||
platform: macos
|
||||
arch: aarch64
|
||||
variant: standard
|
||||
bin: pumpkin
|
||||
- os: macos-15-intel
|
||||
platform: macos
|
||||
arch: x86_64
|
||||
variant: x86-64-v3
|
||||
bin: pumpkin
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Build Release
|
||||
- name: Install Rust and set flags
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "${{ runner.arch }}" == "X64" ]]; then
|
||||
export RUSTFLAGS="$RUSTFLAGS -C target-cpu=x86-64-v3"
|
||||
rustup update stable && rustup default stable
|
||||
if [ "${{ matrix.variant }}" != "standard" ]; then
|
||||
echo "RUSTFLAGS=-C target-cpu=${{ matrix.variant }}" >> "$GITHUB_ENV"
|
||||
fi
|
||||
cargo build --verbose --release
|
||||
- name: Prepare artifacts
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo build --release --verbose
|
||||
- name: Verify binary
|
||||
shell: bash
|
||||
run: |
|
||||
if [ ! -f "target/release/${{ matrix.bin }}" ]; then
|
||||
echo "Binary not found"; ls -la target/release/; exit 1
|
||||
fi
|
||||
- name: Prepare artifact with clean name
|
||||
shell: bash
|
||||
run: |
|
||||
name="pumpkin-${{ matrix.platform }}-${{ matrix.arch }}"
|
||||
if [ "${{ matrix.variant }}" != "standard" ]; then
|
||||
suffix="${{ matrix.variant }}"
|
||||
suffix="${suffix#x86-64-}"
|
||||
name="$name-$suffix"
|
||||
fi
|
||||
if [ "${{ matrix.platform }}" = "windows" ]; then
|
||||
name="$name.exe"
|
||||
fi
|
||||
mkdir -p dist
|
||||
if [ "${{ runner.os }}" == "Windows" ]; then EXT=".exe"; fi
|
||||
cp "target/release/pumpkin$EXT" "dist/pumpkin-${{ runner.arch }}-${{ runner.os }}$EXT"
|
||||
- name: Export executable
|
||||
uses: actions/upload-artifact@v7
|
||||
cp "target/release/${{ matrix.bin }}" "dist/$name"
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: pumpkin-${{ runner.arch }}-${{ runner.os }}
|
||||
name: release-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.variant }}
|
||||
path: dist/*
|
||||
if-no-files-found: error
|
||||
compression-level: 9
|
||||
path: dist/pumpkin-*
|
||||
|
||||
draft_release:
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -140,30 +190,28 @@ jobs:
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Download prebuilt binary artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
pattern: "**/pumpkin-*"
|
||||
path: dist/
|
||||
pattern: release-*
|
||||
merge-multiple: true
|
||||
- name: Generate release notes
|
||||
run: |
|
||||
tree dist/
|
||||
echo "From commit: $(git rev-parse --short HEAD)" > dist/RELEASE.md
|
||||
echo "Generated on: $(date -u +"%Y-%m-%d %H:%M") UTC" >> dist/RELEASE.md
|
||||
cat dist/RELEASE.md
|
||||
|
||||
- name: Update the nightly tag
|
||||
run: |
|
||||
- run: find dist/ -type f | sort
|
||||
- run: |
|
||||
echo "# Nightly Build" > dist/RELEASE.md
|
||||
echo "Commit: $(git rev-parse --short HEAD)" >> dist/RELEASE.md
|
||||
echo "Date: $(date -u +'%Y-%m-%d %H:%M UTC')" >> dist/RELEASE.md
|
||||
- run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git tag --force nightly && git push --force origin tag nightly
|
||||
|
||||
- name: Draft a nightly github release
|
||||
uses: softprops/action-gh-release@v2
|
||||
git tag -f nightly
|
||||
git push origin :nightly 2>/dev/null || true
|
||||
git push origin refs/tags/nightly
|
||||
- uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
prerelease: true
|
||||
files: dist/pumpkin*
|
||||
tag_name: nightly
|
||||
name: Nightly Build
|
||||
prerelease: true
|
||||
body_path: dist/RELEASE.md
|
||||
files: |
|
||||
dist/pumpkin-*
|
||||
|
||||
|
||||
Reference in New Issue
Block a user