This repository has been archived by the owner on Jan 5, 2025. It is now read-only.
Update README.md #8
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: Dioxus Builds | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- "v*.*.*" | |
pull_request: | |
workflow_dispatch: | |
permissions: | |
contents: write | |
env: | |
RUSTFLAGS: -D warnings | |
RUSTDOCFLAGS: -D warnings | |
PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig | |
concurrency: | |
group: ci-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
dioxus_build: | |
name: Dioxus Build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
TARGET: desktop | |
- os: ubuntu-latest | |
TARGET: android | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache system dependencies | |
uses: actions/cache@v3 | |
with: | |
path: /var/cache/apt/archives | |
key: ${{ runner.os }}-apt-${{ hashFiles('**/apt-packages.txt') }} | |
restore-keys: | | |
${{ runner.os }}-apt- | |
- name: Install dependencies (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
libgtk-3-dev \ | |
libwebkit2gtk-4.0-dev \ | |
libayatana-appindicator3-dev \ | |
librsvg2-dev \ | |
libjavascriptcoregtk-4.0-dev \ | |
libsoup2.4-dev \ | |
libglib2.0-dev \ | |
libatk1.0-dev \ | |
libpango1.0-dev \ | |
libcairo2-dev \ | |
libgdk-pixbuf2.0-dev \ | |
libwayland-dev \ | |
libxkbcommon-dev \ | |
libjavascriptcoregtk-4.1-dev \ | |
libsoup-3.0-dev \ | |
libwebkit2gtk-4.1-dev \ | |
libxdo-dev \ | |
clang \ | |
llvm \ | |
libclang-dev \ | |
libffi-dev \ | |
libc6-dev \ | |
zlib1g-dev \ | |
libjpeg-dev \ | |
libpng-dev \ | |
libwebp-dev | |
- name: Set up Java for Android | |
if: matrix.TARGET == 'android' | |
uses: actions/setup-java@v3 | |
with: | |
distribution: "zulu" | |
java-version: "17" | |
- name: Set up Android SDK | |
if: matrix.TARGET == 'android' | |
uses: android-actions/setup-android@v3 | |
- name: Install Android SDK components | |
if: matrix.TARGET == 'android' | |
run: | | |
sdkmanager "platform-tools" "platforms;android-33" "build-tools;33.0.0" "ndk;25.1.8937393" | |
echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV | |
echo "ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/25.1.8937393" >> $GITHUB_ENV | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: wasm32-unknown-unknown | |
- name: Cache cargo registry | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: true | |
key: ${{ runner.os }}-rust-${{ matrix.TARGET }}-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache Cargo and Dioxus CLI | |
uses: actions/cache@v3 | |
id: cache-cargo-dioxus | |
with: | |
path: | | |
~/.cargo | |
key: ${{ runner.os }}-cargo-dioxus-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install Dioxus CLI | |
run: cargo install dioxus-cli --locked | |
if: steps.cache-cargo-dioxus.outputs.cache-hit != 'true' | |
- name: Cache Dioxus build artifacts | |
uses: actions/cache@v3 | |
with: | |
path: | | |
target | |
dist | |
key: ${{ runner.os }}-dioxus-${{ matrix.TARGET }}-${{ hashFiles('**/Cargo.lock', '**/*.rs') }} | |
restore-keys: | | |
${{ runner.os }}-dioxus-${{ matrix.TARGET }}- | |
- name: Build for ${{ matrix.TARGET }} | |
run: dx build --release --platform ${{ matrix.TARGET }} | |
- name: Rename and package | |
shell: bash | |
run: | | |
if [ "${{ matrix.TARGET }}" = "web" ]; then | |
tar -czvf myquest-web.tar.gz dist | |
elif [ "${{ matrix.TARGET }}" = "android" ]; then | |
mkdir -p android-artifacts | |
cp target/release/apk/*.apk android-artifacts/ | |
tar -czvf myquest-android.tar.gz android-artifacts | |
elif [ "${{ matrix.os }}" = "windows-latest" ]; then | |
mv target/release/myquest.exe myquest-windows.exe | |
elif [ "${{ matrix.os }}" = "macos-latest" ]; then | |
mv target/release/myquest myquest-macos | |
else | |
mv target/release/myquest myquest-linux | |
fi | |
- name: Create AppImage (Linux) | |
if: matrix.os == 'ubuntu-latest' && matrix.TARGET == 'desktop' | |
run: | | |
sudo apt-get install -y libfuse2 libxdo-dev | |
wget -O linuxdeploy-x86_64.AppImage https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage | |
wget -O linuxdeploy-plugin-gtk.sh https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh | |
chmod +x linuxdeploy-x86_64.AppImage linuxdeploy-plugin-gtk.sh | |
mkdir -p AppDir/usr/bin AppDir/usr/share/applications AppDir/usr/share/icons/hicolor/512x512/apps | |
cp myquest-linux AppDir/usr/bin/myquest | |
cp assets/icon-512.png AppDir/usr/share/icons/hicolor/512x512/apps/myquest.png | |
cp metadata/linux/myquest.desktop AppDir/usr/share/applications/ | |
./linuxdeploy-x86_64.AppImage --appdir AppDir --desktop-file=AppDir/usr/share/applications/myquest.desktop --icon-file=AppDir/usr/share/icons/hicolor/512x512/apps/myquest.png --plugin gtk --library /usr/lib/x86_64-linux-gnu/libxdo.so.3 --output appimage | |
mv myQuest*.AppImage myquest-linux.AppImage | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: myquest-${{ matrix.TARGET }}-${{ matrix.os }} | |
path: | | |
myquest-* | |
*.tar.gz | |
*.AppImage | |
- name: Get version from Cargo.toml | |
id: get_version | |
run: | | |
version=$(grep '^version =' Cargo.toml | cut -d '"' -f 2) | |
echo "VERSION=$version" >> $GITHUB_ENV | |
- name: Update or create pre-release | |
if: github.ref == 'refs/heads/master' | |
continue-on-error: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
tag_name="v${{ env.VERSION }}-pre" | |
release_name="Pre-release ${{ env.VERSION }}" | |
# Delete existing release and tag if they exist | |
existing_release_id=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$GITHUB_REPOSITORY/releases/tags/$tag_name" \ | |
| jq -r '.id') | |
if [ "$existing_release_id" != "null" ]; then | |
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$GITHUB_REPOSITORY/releases/$existing_release_id" | |
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$GITHUB_REPOSITORY/git/refs/tags/$tag_name" | |
fi | |
# Create new pre-release | |
response=$(curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ | |
-d "{\"tag_name\":\"$tag_name\",\"name\":\"$release_name\",\"prerelease\":true}" \ | |
"https://api.github.com/repos/$GITHUB_REPOSITORY/releases") | |
release_id=$(echo $response | jq -r '.id') | |
echo "RELEASE_ID=$release_id" >> $GITHUB_ENV | |
echo "RELEASE_TAG=$tag_name" >> $GITHUB_ENV | |
- name: Upload builds to pre-release | |
if: github.ref == 'refs/heads/master' | |
continue-on-error: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
for file in myquest-* *.tar.gz *.AppImage; do | |
if [ -f "$file" ]; then | |
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Content-Type: application/octet-stream" \ | |
--data-binary @"$file" \ | |
"https://uploads.github.com/repos/$GITHUB_REPOSITORY/releases/${{ env.RELEASE_ID }}/assets?name=$file" || true | |
fi | |
done | |
- uses: svenstaro/upload-release-action@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: myquest-* | |
file_glob: true | |
tag: ${{ github.ref_name }} | |
overwrite: true | |
release_name: Release ${{ github.ref_name }} | |
body: "This is a new release for ${{ github.ref_name }}" |