mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-31 08:22:33 +00:00
210 lines
6.3 KiB
YAML
210 lines
6.3 KiB
YAML
name: Cargo Build, Test, and Linting
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUSTFLAGS: "-Dwarnings"
|
|
|
|
jobs:
|
|
format:
|
|
name: Check formatting
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
toolchain:
|
|
- stable
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
submodules: recursive
|
|
- 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
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
submodules: recursive
|
|
- 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
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
submodules: recursive
|
|
- 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
|
|
clippy_release:
|
|
name: Run lints (release)
|
|
runs-on: ubuntu-latest
|
|
needs: [machete]
|
|
strategy:
|
|
matrix:
|
|
toolchain:
|
|
- stable
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
submodules: recursive
|
|
- 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
|
|
build_and_test:
|
|
name: Build project and test
|
|
runs-on: ${{ matrix.os }}
|
|
needs: [clippy_debug, clippy_release]
|
|
strategy:
|
|
matrix:
|
|
os:
|
|
[
|
|
ubuntu-latest,
|
|
ubuntu-26.04-arm,
|
|
windows-latest,
|
|
windows-11-arm,
|
|
macos-latest,
|
|
]
|
|
toolchain:
|
|
- stable
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
submodules: recursive
|
|
- 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
|
|
build_release:
|
|
name: Build project in release
|
|
runs-on: ${{ matrix.os }}
|
|
needs: [build_and_test]
|
|
strategy:
|
|
matrix:
|
|
os:
|
|
[
|
|
ubuntu-latest,
|
|
ubuntu-24.04-arm,
|
|
windows-latest,
|
|
windows-11-arm,
|
|
macos-latest,
|
|
]
|
|
toolchain:
|
|
- stable
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
submodules: recursive
|
|
|
|
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Build Release
|
|
shell: bash
|
|
run: |
|
|
cargo build --verbose --release
|
|
|
|
- name: Prepare artifacts
|
|
shell: bash
|
|
run: |
|
|
mkdir -p dist
|
|
if [ "${{ runner.os }}" == "Windows" ]; then EXT=".exe"; fi
|
|
cp "target/release/pumpkin$EXT" "dist/pumpkin-${{ runner.arch }}-${{ runner.os }}$EXT"
|
|
|
|
- name: Upload unsigned executable for SignPath (Windows only)
|
|
if: runner.os == 'Windows' && github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
id: upload_unsigned
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: unsigned-${{ runner.arch }}-${{ runner.os }}
|
|
path: dist/pumpkin-*
|
|
retention-days: 1
|
|
|
|
- name: Submit SignPath signing request (Windows only)
|
|
if: runner.os == 'Windows' && github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
uses: signpath/github-action-submit-signing-request@v2
|
|
with:
|
|
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
|
|
organization-id: '${{ secrets.SIGNPATH_ORGANIZATION_ID }}'
|
|
project-slug: '${{ secrets.SIGNPATH_PROJECT_SLUG }}'
|
|
signing-policy-slug: '${{ secrets.SIGNPATH_SIGNING_POLICY_SLUG }}'
|
|
github-artifact-id: '${{ steps.upload_unsigned.outputs.artifact-id }}'
|
|
wait-for-completion: true
|
|
output-artifact-directory: dist/signed/
|
|
|
|
- name: Overwrite with signed version (Windows only)
|
|
if: runner.os == 'Windows' && github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
shell: bash
|
|
run: |
|
|
cp dist/signed/* dist/
|
|
rm -rf dist/signed/
|
|
|
|
- name: Export executable
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: pumpkin-${{ runner.arch }}-${{ runner.os }}
|
|
compression-level: 9
|
|
path: dist/pumpkin-*
|
|
draft_release:
|
|
permissions:
|
|
contents: write
|
|
needs: [build_release]
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
submodules: recursive
|
|
- name: Download prebuilt binary artifacts
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
pattern: "**/pumpkin-*"
|
|
path: dist/
|
|
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: |
|
|
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@v3
|
|
with:
|
|
prerelease: true
|
|
files: dist/pumpkin*
|
|
tag_name: nightly
|
|
name: Nightly Build
|
|
body_path: dist/RELEASE.md
|