Skip to content

Pull up RNG cluster of dependencies #40

Pull up RNG cluster of dependencies

Pull up RNG cluster of dependencies #40

on: [push, pull_request, workflow_dispatch]
# These tests check for buildability, tests and lints, and if these check out and its on main, deploys the webpage and artifacts
name: ContinuousDeployment
env:
RUST_NIGHTLY_TOOLCHAIN_VERSION: "nightly-2024-10-15"
jobs:
clippy-native:
name: Clippy + Check native
# clippy is a superset of cargo check.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo +stable --locked clippy --workspace --target x86_64-unknown-linux-gnu --all-features --all-targets -- -D warnings
clippy-web:
name: Clippy + Check wasm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{env.RUST_NIGHTLY_TOOLCHAIN_VERSION}}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo clippy --locked --workspace --target wasm32-unknown-unknown --all-features --all-targets -- -D warnings
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo +stable --locked test --target x86_64-unknown-linux-gnu --lib
build-webpage:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: fat
config_file: Trunk.fat.toml
pre_build: just patch_fat_html
- name: slim
config_file: Trunk.toml
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v2
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{env.RUST_NIGHTLY_TOOLCHAIN_VERSION}}
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Download and install Trunk binary
run: wget -qO- https://github.com/trunk-rs/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
- if: ${{matrix.pre_build}}
run: ${{matrix.pre_build}}
- name: Build ${{ matrix.name }}
run: cd executable && ../trunk build --config ${{ matrix.config_file }} --release --public-url __RENAME_ME__
# Cloudflare doesnt respect precompressed artifacts. It just does its own brotli compression, which is pretty shitty.
# See also ./assets/_headers
# It might respect gzip artifacts, but these dont reach normal brotli compression levels, and are pretty close the the levels seen with cloudflares brotli.
# - name: Precompress every file
# run: find ./dist/ -type f -exec brotli -k -f {} \;
build-combined-webpage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v2
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{env.RUST_NIGHTLY_TOOLCHAIN_VERSION}}
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Download and install Trunk binary
run: wget -qO- https://github.com/trunk-rs/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
- name: Build combined
run: export PATH=$PATH:$(pwd); just td build --release
# Cloudflare doesnt respect precompressed artifacts. It just does its own brotli compression, which is pretty shitty.
# See also ./assets/_headers
# It might respect gzip artifacts, but these dont reach normal brotli compression levels, and are pretty close the the levels seen with cloudflares brotli.
# - name: Precompress every file
# run: find ./dist/ -type f -exec brotli -k -f {} \;
- name: Save Artifacts
uses: actions/upload-artifact@v4
with:
name: combined-artifacts
path: executable/dist/combined
build-executable:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
# macos-latest seems to already run on arm64(=aarch64):
# https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job#standard-github-hosted-runners-for-public-repositories
TARGET: aarch64-apple-darwin
pretty_name: macos-arm64
- os: macos-latest
TARGET: x86_64-apple-darwin
# even though the runner uses arm64, MacOS on arm64 seems to support building for amd64.
# which makes sense, would be bad for devs otherwise.
cross: false
pretty_name: macos-amd64
- os: ubuntu-latest
TARGET: aarch64-unknown-linux-gnu
cross: true
pretty_name: linux-gnu-arm64
# who even uses these.
# - os: ubuntu-latest
# TARGET: armv7-unknown-linux-gnueabihf
# cross: true
- os: ubuntu-latest
TARGET: x86_64-unknown-linux-gnu
pretty_name: linux-gnu-amd64
# disabled for now, as github workers are SLOW on windows.
# Alternatively switch away from rust-cache, but it'll still be slower:
# https://github.com/bukowa/tauri-e2e/issues/3
# But I might want to explore that when I actually release.
- os: windows-latest
TARGET: x86_64-pc-windows-msvc
EXTENSION: .exe
pretty_name: windows-amd64
steps:
- name: Install cross
# Github doesnt have runners with exotic architectures (eg. arm64/aarch64 on anything but macos).
# Thus we use cross.
# It's necessary to use an up-to-date cross from the git repository to avoid glibc problems on linux
# Ref: https://github.com/cross-rs/cross/issues/1510
if: matrix.cross
run: |
cargo +stable --locked install cross --git https://github.com/cross-rs/cross --rev 1b8cf50d20180c1a394099e608141480f934b7f7
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.TARGET }}
- uses: Swatinem/rust-cache@v2
with:
# this is required to avoid failures due to caching of artifacts for different architectures
# The reason is the potential usage of cross.
# The cache checks the rustc host which doesn't record us targeting
# different architectures (and native) with cross on the generic ubuntu-latest.
key: ${{ matrix.TARGET }}
- if: ${{ !matrix.cross }}
name: Cargo Build
run: cargo +stable --locked build --locked --verbose --release --target=${{ matrix.TARGET }}
- if: matrix.cross
name: Cross Build
# run: cross +stable build --locked --verbose --release --target=${{ matrix.TARGET }}
run: |
# hotfix for https://github.com/cross-rs/cross/issues/1541
rm rust-toolchain.toml
cross build --locked --verbose --release --target=${{ matrix.TARGET }}
- name: Rename
run: cp target/${{ matrix.TARGET }}/release/${{ github.event.repository.name }}${{ matrix.EXTENSION }} ${{ github.event.repository.name }}-${{ matrix.pretty_name }}${{ matrix.EXTENSION }}
- name: Compress
run: |
# zstd ${{ github.event.repository.name }}-${{ matrix.pretty_name }}${{ matrix.EXTENSION }}
tar caf ${{ github.event.repository.name }}-${{ matrix.pretty_name }}${{ matrix.EXTENSION }}.tar.gz ${{ github.event.repository.name }}-${{ matrix.pretty_name }}${{ matrix.EXTENSION }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.TARGET }}-executable
compression-level: 0
path: ${{ github.event.repository.name }}-${{ matrix.pretty_name }}${{ matrix.EXTENSION }}.*
fine-for-deployment:
runs-on: ubuntu-latest
needs:
- clippy-native
- clippy-web
- test
steps:
- run: echo "Github, you really should have something for this kind of coordination."
upload-executables:
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- fine-for-deployment
- build-executable
if: ${{ github.event_name == 'push' }}
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: "*-executable"
merge-multiple: true
- name: Create a valid release tag
id: tag
run: |
string=${{ github.ref }};
cleaned_string="${string#refs/tags/}";
cleaned_string="${cleaned_string#refs/heads/}";
echo "tag=$cleaned_string" >> $GITHUB_OUTPUT;
- name: Upload binaries to release (create one if not existing)
uses: softprops/action-gh-release@v2
if: ${{ github.event_name == 'push' }}
with:
files: ${{ github.event.repository.name }}-*.*
tag_name: ${{ steps.tag.outputs.tag }}
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
deploy-webpage:
runs-on: ubuntu-latest
needs:
- fine-for-deployment
- build-combined-webpage
permissions:
contents: write # for committing to artifacts/* branch.
steps:
- uses: actions/checkout@v4
# with:
# I just need a git repo with correct remote for the deploy action
# sparse-checkout: .
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
pattern: "*-artifacts"
path: dist
merge-multiple: true
- name: Deploy to Pages branch
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: dist
branch: artifacts/webpage/${{ github.head_ref || github.ref_name }}
# this option will not maintain any history of your previous pages deployment
# set to false if you want all page build to be committed to your gh-pages branch history
single-commit: true
# TODO: Add container build-step, to be saved in GHCR.