attempt appimage fix #105
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: | |
- main | |
tags: | |
- 'v*.*.*' # Trigger for version tags, adjust if necessary | |
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: | |
fmt: | |
name: Rustfmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: --all -- --check | |
dioxus_build: | |
name: Dioxus Build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
TARGET: desktop | |
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 | |
- 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 mylife-web.tar.gz dist | |
elif [ "${{ matrix.os }}" = "windows-latest" ]; then | |
mv target/release/mylife.exe mylife-windows.exe | |
elif [ "${{ matrix.os }}" = "macos-latest" ]; then | |
mv target/release/mylife mylife-macos | |
else | |
mv target/release/mylife mylife-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/256x256/apps | |
cp mylife-linux AppDir/usr/bin/mylife | |
cp assets/icon-256.png AppDir/usr/share/icons/hicolor/256x256/apps/mylife.png | |
cat > AppDir/usr/share/applications/mylife.desktop << EOF | |
[Desktop Entry] | |
Name=MyLife | |
Exec=mylife | |
Icon=mylife | |
Type=Application | |
Categories=Utility; | |
EOF | |
./linuxdeploy-x86_64.AppImage --appdir AppDir --desktop-file=AppDir/usr/share/applications/mylife.desktop --icon-file=AppDir/usr/share/icons/hicolor/256x256/apps/mylife.png --plugin gtk --library /usr/lib/x86_64-linux-gnu/libxdo.so.3 --output appimage | |
mv MyLife*.AppImage mylife-linux.AppImage | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: mylife-${{ matrix.TARGET }}-${{ matrix.os }} | |
path: | | |
mylife-* | |
*.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/main' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
tag_name="v${{ env.VERSION }}-pre" | |
release_name="Pre-release ${{ env.VERSION }}" | |
# Check if the release already exists | |
release_id=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$GITHUB_REPOSITORY/releases/tags/$tag_name" \ | |
| jq -r '.id') | |
if [ "$release_id" = "null" ]; then | |
# 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') | |
else | |
# Update existing pre-release | |
curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" \ | |
-d "{\"name\":\"$release_name\",\"prerelease\":true}" \ | |
"https://api.github.com/repos/$GITHUB_REPOSITORY/releases/$release_id" | |
fi | |
echo "RELEASE_ID=$release_id" >> $GITHUB_ENV | |
echo "RELEASE_TAG=$tag_name" >> $GITHUB_ENV | |
- name: Upload Linux builds to pre-release | |
if: matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/main' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
for file in mylife-linux mylife-linux.AppImage; do | |
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" | |
done | |
- uses: svenstaro/upload-release-action@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: mylife-* | |
file_glob: true | |
tag: ${{ github.ref }} | |
overwrite: true | |
release_name: Release ${{ github.ref }} | |
body: "This is a new release for ${{ github.ref }}" |