Build dufs with embed assets #24
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
name: Build dufs with embed assets | |
on: | |
workflow_dispatch: | |
jobs: | |
build-assets: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: latest | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
check-latest: true | |
cache: pnpm | |
cache-dependency-path: "**/package.json" | |
- name: Build assets | |
run: | | |
pnpm install | |
DUFS_EMBED_FILENAME=1 pnpm run build | |
- name: Upload assets | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dufs-material-assets-embed | |
path: dist | |
# https://github.com/sigoden/dufs/blob/main/.github/workflows/release.yaml | |
build-dufs: | |
needs: build-assets | |
strategy: | |
matrix: | |
include: | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-latest | |
use-cross: true | |
cargo-flags: "" | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
use-cross: true | |
cargo-flags: "" | |
- target: aarch64-pc-windows-msvc | |
os: windows-latest | |
use-cross: true | |
cargo-flags: "" | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
cargo-flags: "" | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
cargo-flags: "" | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
use-cross: true | |
cargo-flags: "" | |
- target: i686-unknown-linux-musl | |
os: ubuntu-latest | |
use-cross: true | |
cargo-flags: "" | |
- target: i686-pc-windows-msvc | |
os: windows-latest | |
use-cross: true | |
cargo-flags: "" | |
- target: armv7-unknown-linux-musleabihf | |
os: ubuntu-latest | |
use-cross: true | |
cargo-flags: "" | |
- target: arm-unknown-linux-musleabihf | |
os: ubuntu-latest | |
use-cross: true | |
cargo-flags: "" | |
runs-on: ${{ matrix.os }} | |
env: | |
BUILD_CMD: cargo | |
steps: | |
- name: Check Tag | |
id: check-tag | |
shell: bash | |
run: | | |
ver=$(curl --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/sigoden/dufs/tags | jq -r .[0].name) | |
echo "version=$ver" >> $GITHUB_OUTPUT | |
- uses: actions/checkout@v4 | |
with: | |
repository: sigoden/dufs | |
ref: ${{ steps.check-tag.outputs.version }} | |
- name: Install Rust Toolchain Components | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Install cross | |
if: matrix.use-cross | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cross | |
- name: Overwrite build command env variable | |
if: matrix.use-cross | |
shell: bash | |
run: echo "BUILD_CMD=cross" >> $GITHUB_ENV | |
- name: Show Version Information (Rust, cargo, GCC) | |
shell: bash | |
run: | | |
gcc --version || true | |
rustup -V | |
rustup toolchain list | |
rustup default | |
cargo -V | |
rustc -V | |
- name: Download assets | |
uses: actions/download-artifact@v4 | |
with: | |
name: dufs-material-assets-embed | |
path: dufs-material-assets-embed | |
- name: Replace assets | |
shell: bash | |
run: | | |
cp dufs-material-assets-embed/index.css assets/index.css | |
cp dufs-material-assets-embed/index.html assets/index.html | |
cp dufs-material-assets-embed/index.js assets/index.js | |
- name: Build | |
shell: bash | |
id: build | |
run: | | |
$BUILD_CMD build --locked --release --target=${{ matrix.target }} ${{ matrix.cargo-flags }} | |
if [[ "$RUNNER_OS" == "Windows" ]]; then | |
echo "executable=target/${{ matrix.target }}/release/dufs.exe" >> $GITHUB_OUTPUT | |
else | |
echo "executable=target/${{ matrix.target }}/release/dufs" >> $GITHUB_OUTPUT | |
fi | |
- name: Upload executable | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dufs-mod-${{ steps.check-tag.outputs.version }}-${{ matrix.target }} | |
path: ${{ steps.build.outputs.executable }} |