-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add workflow files (build/test/fmt/pub) - requires PROJECT_NAME
- Loading branch information
Showing
6 changed files
with
504 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: "Build - Check & Clippy" | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
env: | ||
preview: ${{ github.event_name == 'release' && contains(github.event.release.tag_name, 'preview') }} | ||
on_schedule: "false" | ||
SCCACHE_GHA_ENABLED: true | ||
CARGO_INCREMENTAL: 0 | ||
CARGO_TERM_COLOR: always | ||
RUST_BACKTRACE: 1 | ||
PROJECT_NAME: "NAME_HERE" | ||
jobs: | ||
check: | ||
name: "Build - check" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
gcc: gcc-x86-64-linux-gnu | ||
rust: nightly | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
rust: nightly | ||
runs-on: ${{ matrix.os }} | ||
if: "!contains(github.event.head_commit.message, 'skip ci')" | ||
steps: | ||
- name: "Checkout sources" | ||
uses: actions/checkout@master | ||
- name: "Cache Cargo dependencies" | ||
uses: Swatinem/rust-cache@v2 | ||
- name: "Setup sccache" | ||
uses: mozilla-actions/sccache-action@v0.0.6 | ||
- name: "Install gcc" | ||
if: matrix.gcc != '' | ||
run: sudo apt update && sudo apt install -yq ${{ matrix.gcc }} | ||
- name: "Setup Rust toolchain" | ||
run: rustup toolchain install nightly --profile default --target ${{ matrix.target }} --no-self-update | ||
- name: "Run Cargo fmt" | ||
run: cargo fmt --all -- --check | ||
- name: "Run Cargo check" | ||
run: cargo check | ||
- name: "Run Clippy with pedantic" | ||
run: cargo clippy --all-targets --all-features -- -W clippy::pedantic | ||
- name: "Build project" | ||
run: cargo build --release --all | ||
clippy: | ||
name: "Build - clippy" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
gcc: gcc-x86-64-linux-gnu | ||
rust: nightly | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
rust: nightly | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
RUSTC_WRAPPER: sccache | ||
if: "!contains(github.event.head_commit.message, 'skip ci')" | ||
steps: | ||
- name: "Checkout sources" | ||
uses: actions/checkout@master | ||
- name: "Cache Cargo dependencies" | ||
uses: Swatinem/rust-cache@v2 | ||
- name: "Setup sccache" | ||
uses: mozilla-actions/sccache-action@v0.0.6 | ||
- name: "Install gcc" | ||
if: matrix.gcc != '' | ||
run: sudo apt update && sudo apt install -yq ${{ matrix.gcc }} | ||
- name: "Setup Rust toolchain" | ||
run: rustup toolchain install nightly --profile default --target ${{ matrix.target }} --no-self-update | ||
- name: "Run Cargo fmt" | ||
run: cargo fmt --all -- --check | ||
- name: "Run Clippy with pedantic" | ||
run: cargo clippy --all-targets --all-features -- -W clippy::pedantic | ||
- name: "Build project" | ||
run: cargo build --release --all | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
name: "Doc-check & Generation" | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
env: | ||
SCCACHE_GHA_ENABLED: true | ||
CARGO_INCREMENTAL: 0 | ||
CARGO_TERM_COLOR: always | ||
RUST_BACKTRACE: 1 | ||
PROJECT_NAME: "NAME_HERE" | ||
jobs: | ||
docs: | ||
name: "Docs - docs" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
gcc: gcc-x86-64-linux-gnu | ||
rust: nightly | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
rust: nightly | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
RUSTC_WRAPPER: sccache | ||
steps: | ||
- name: "Checkout sources" | ||
uses: actions/checkout@v4 | ||
- name: "Install gcc" | ||
if: matrix.gcc != '' | ||
run: sudo apt update && sudo apt install -yq ${{ matrix.gcc }} | ||
- name: "Cache Cargo dependencies" | ||
uses: Swatinem/rust-cache@v2 | ||
- name: "Setup Rust toolchain" | ||
run: rustup toolchain install nightly --profile default --target ${{ matrix.target }} --no-self-update | ||
- name: "Setup sccache" | ||
uses: mozilla-actions/sccache-action@v0.0.6 | ||
- name: "Run Cargo Doc checks" | ||
run: cargo doc --no-deps --all-features --all --target ${{ matrix.target }} --document-private-items | ||
env: | ||
RUSTDOCFLAGS: "-D warnings" | ||
package-docs-unix: | ||
name: "Docs - package-docs-unix" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
gcc: gcc-x86-64-linux-gnu | ||
rust: nightly | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
RUSTC_WRAPPER: sccache | ||
steps: | ||
- name: "Checkout sources" | ||
uses: actions/checkout@v4 | ||
- name: "Install gcc" | ||
if: matrix.gcc != '' | ||
run: sudo apt update && sudo apt install -yq ${{ matrix.gcc }} | ||
- name: "Cache Cargo dependencies" | ||
uses: Swatinem/rust-cache@v2 | ||
- name: "Setup Rust toolchain" | ||
run: rustup toolchain install nightly --profile default --target ${{ matrix.target }} --no-self-update | ||
- name: "Cache Cargo dependencies" | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
cache-all-crates: true | ||
- name: "Setup sccache" | ||
uses: mozilla-actions/sccache-action@v0.0.6 | ||
- name: "Run Cargo Doc generation" | ||
env: | ||
RUSTDOCFLAGS: "-D warnings" | ||
run: cargo doc --no-deps --all-features --all --target ${{ matrix.target }} --document-private-items | ||
- name: "Ensure Zip Installed on Unix" | ||
run: | | ||
if ! command -v zip &> /dev/null | ||
then | ||
sudo apt-get install zip | ||
fi | ||
zip --version | ||
- name: "Package Docs Unix" | ||
env: | ||
TARGET_NAME: ${{ env.PROJECT_NAME }}-${{ matrix.target }}-docs | ||
PROJECT_NAME: ${{ env.PROJECT_NAME }} | ||
shell: bash | ||
run: | | ||
mkdir -p "$TARGET_NAME" | ||
cp -r "target/${{ matrix.target }}/doc" "$TARGET_NAME" | ||
zip -r "$TARGET_NAME.zip" "target/${{ matrix.target }}/doc" | ||
- name: "Upload artifact" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.PROJECT_NAME }}-${{ matrix.target }}-docs.zip | ||
path: ${{ env.PROJECT_NAME }}-${{ matrix.target }}-docs.zip | ||
package-docs-windows: | ||
name: "Docs - package-docs-windows" | ||
strategy: | ||
matrix: | ||
include: | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
rust: nightly | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
RUSTC_WRAPPER: sccache | ||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: lld-link.exe | ||
steps: | ||
- name: "Checkout sources" | ||
uses: actions/checkout@master | ||
- name: "Cache Cargo dependencies" | ||
uses: Swatinem/rust-cache@v2 | ||
- name: "Setup sccache" | ||
uses: mozilla-actions/sccache-action@v0.0.6 | ||
- name: "Install gcc" | ||
if: matrix.gcc != '' | ||
run: sudo apt update && sudo apt install -yq ${{ matrix.gcc }} | ||
- name: "Setup Rust toolchain" | ||
run: rustup toolchain install nightly --profile default --target ${{ matrix.target }} --no-self-update | ||
- name: "Run Cargo Doc generation" | ||
env: | ||
RUSTDOCFLAGS: "-D warnings" | ||
run: cargo doc --no-deps --all-features --all --target ${{ matrix.target }} --document-private-items | ||
- name: "Package Docs Windows" | ||
env: | ||
TARGET_NAME: ${{ env.PROJECT_NAME }}-${{ matrix.target }}-docs | ||
PROJECT_NAME: ${{ env.PROJECT_NAME }} | ||
shell: powershell | ||
run: | | ||
New-Item -ItemType Directory -Path ${env:TARGET_NAME} | ||
Copy-Item -Path ".\target\${{ matrix.target }}\doc" -Destination ${env:TARGET_NAME} | ||
Compress-Archive -Path ${env:TARGET_NAME} -DestinationPath ${env:TARGET_NAME} | ||
- name: "Upload artifact" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.PROJECT_NAME }}-${{ matrix.target }}-docs.zip | ||
path: ${{ env.PROJECT_NAME }}-${{ matrix.target }}-docs.zip | ||
if-no-files-found: 'error' | ||
compression-level: '9' | ||
overwrite: 'true' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
name: "Draft" | ||
on: | ||
push: | ||
# branches: | ||
# - master | ||
# - main | ||
tags: ["v[0-9]+.[0-9]+.[0-9]?"] | ||
# workflow_dispatch: | ||
# inputs: | ||
|
||
env: | ||
SCCACHE_GHA_ENABLED: true | ||
CARGO_INCREMENTAL: 0 | ||
CARGO_TERM_COLOR: always | ||
RUST_BACKTRACE: 1 | ||
PROJECT_NAME: "NAME_HERE" | ||
jobs: | ||
build-unix: | ||
name: "Draft - build-unix" | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
gcc: gcc-x86-64-linux-gnu | ||
rust: nightly | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
RUSTC_WRAPPER: sccache | ||
steps: | ||
- name: "Checkout sources" | ||
uses: actions/checkout@master | ||
- name: "Cache Cargo dependencies" | ||
uses: Swatinem/rust-cache@v2 | ||
- name: "Setup sccache" | ||
uses: mozilla-actions/sccache-action@v0.0.6 | ||
- name: "Install gcc" | ||
if: matrix.gcc != '' | ||
run: sudo apt update && sudo apt install -yq ${{ matrix.gcc }} | ||
- name: "Setup Rust toolchain" | ||
run: rustup toolchain install nightly --profile default --target ${{ matrix.target }} --no-self-update | ||
- name: "Make script executable # Test if works when already within GH Actions" | ||
run: chmod +x build/build.sh | ||
- name: "Build" | ||
run: ./build/build.sh ${{ matrix.target }} | ||
- name: "Upload artifact" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.PROJECT_NAME }}-${{ matrix.target }}.zip | ||
path: ${{ env.PROJECT_NAME }}-${{ matrix.target }}.zip | ||
if-no-files-found: 'error' | ||
compression-level: '9' | ||
overwrite: 'true' | ||
build-windows: | ||
name: "Draft - build-windows" | ||
strategy: | ||
matrix: | ||
include: | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
rust: nightly | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
RUSTC_WRAPPER: sccache | ||
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: lld-link.exe | ||
steps: | ||
- name: "Checkout sources" | ||
uses: actions/checkout@master | ||
- name: "Cache Cargo dependencies" | ||
uses: Swatinem/rust-cache@v2 | ||
- name: "Setup sccache" | ||
uses: mozilla-actions/sccache-action@v0.0.6 | ||
- name: "Install gcc" | ||
if: matrix.gcc != '' | ||
run: sudo apt update && sudo apt install -yq ${{ matrix.gcc }} | ||
- name: "Setup Rust toolchain" | ||
run: rustup toolchain install nightly --profile default --target ${{ matrix.target }} --no-self-update | ||
- name: "Build" | ||
run: cargo build --release --locked --target ${{ matrix.target }} | ||
- name: "Pack artifact" | ||
env: | ||
TARGET_NAME: ${{ env.PROJECT_NAME }}-${{ matrix.target }} | ||
DIR: ${{ github.workspace }} | ||
run: | | ||
New-Item -ItemType Directory -Path ${env:TARGET_NAME} | ||
Copy-Item -Path "target\${{ matrix.target }}\release\${{ env.PROJECT_NAME }}.exe" -Destination ${env:TARGET_NAME} | ||
Copy-Item -Path "README.md", "LICENSE-APACHE", "LICENSE-MIT" -Destination ${env:TARGET_NAME} | ||
Compress-Archive -Path ${env:TARGET_NAME} -DestinationPath "${env:TARGET_NAME}" | ||
- name: "Upload artifact" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ env.PROJECT_NAME }}-${{ matrix.target }}-${{ github.ref_name }}.zip | ||
path: ${{ env.PROJECT_NAME }}-${{ matrix.target }}.zip | ||
if-no-files-found: 'error' | ||
compression-level: '9' | ||
overwrite: 'true' | ||
draft: | ||
if: startsWith(github.ref, 'refs/tags/') | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
needs: [build-unix, build-windows] | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
merge-multiple: true | ||
- name: "Draft" | ||
uses: softprops/action-gh-release@master | ||
with: | ||
draft: true | ||
# make_latest: true ## Drafts & prereleases cannot be set as `make_latest:` | ||
files: | | ||
${{ env.PROJECT_NAME }}-*.zip | ||
generate_release_notes: true | ||
# body_path: ${{ github.workspace }}-CHANGELOG.txt ## For adding changelog content | ||
|
||
nightly: | ||
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
needs: [build-unix, build-windows] | ||
steps: | ||
- run: | | ||
echo 'NIGHTLY_BODY<<EOF' >> $GITHUB_ENV | ||
echo "From commit: ${GITHUB_SHA:0:8}" >> $GITHUB_ENV | ||
echo "Generated on: $(date -u +"%Y-%m-%d %H:%M") UTC" >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
merge-multiple: true | ||
- name: "Update the tag" | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git tag --force nightly && git push --force origin tag nightly | ||
- name: "Nightly" | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: nightly | ||
prerelease: true | ||
files: | | ||
${{ env.PROJECT_NAME }}-*.zip | ||
name: Nightly Build | ||
body: ${{ env.NIGHTLY_BODY }} | ||
target_commitish: ${{ github.sha }} | ||
|
Oops, something went wrong.