name: Release on: release: types: [published] workflow_dispatch: jobs: build-appimage: runs-on: ubuntu-22.04 permissions: contents: write steps: - name: Checkout uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable - name: Install dependencies run: | sudo apt-get update -q sudo apt-get install -y \ libgl1-mesa-dev libx11-dev libxcursor-dev libxi-dev libxrandr-dev \ libxkbcommon-dev libwayland-dev libfontconfig1-dev libfreetype6-dev \ librsvg2-bin fuse libfuse2 - name: Build run: cargo build --release - name: Prepare AppDir run: | mkdir -p AppDir/usr/bin mkdir -p AppDir/usr/share/applications mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps cp target/release/H7CAD AppDir/usr/bin/H7CAD cp packaging/H7CAD.desktop AppDir/usr/share/applications/io.github.HakanSeven12.H7CAD.desktop rsvg-convert -w 256 -h 256 assets/logo.svg \ -o AppDir/usr/share/icons/hicolor/256x256/apps/io.github.HakanSeven12.H7CAD.png - name: Download linuxdeploy run: | wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage chmod +x linuxdeploy-x86_64.AppImage - name: Build AppImage env: APPIMAGE_EXTRACT_AND_RUN: 1 run: | ./linuxdeploy-x86_64.AppImage \ --appdir AppDir \ --desktop-file AppDir/usr/share/applications/io.github.HakanSeven12.H7CAD.desktop \ --icon-file AppDir/usr/share/icons/hicolor/256x256/apps/io.github.HakanSeven12.H7CAD.png \ --output appimage mv H7CAD*.AppImage H7CAD.AppImage - name: Upload AppImage to release if: github.event_name == 'release' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | mv H7CAD.AppImage H7CAD-${{ github.ref_name }}-linux-x86_64.AppImage gh release upload ${{ github.ref_name }} H7CAD-${{ github.ref_name }}-linux-x86_64.AppImage --clobber --repo ${{ github.repository }} build-windows: runs-on: windows-latest permissions: contents: write steps: - name: Checkout uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable - name: Build run: cargo build --release - name: Upload exe to release if: github.event_name == 'release' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | mv target/release/H7CAD.exe H7CAD-${{ github.ref_name }}-windows-x86_64.exe gh release upload ${{ github.ref_name }} H7CAD-${{ github.ref_name }}-windows-x86_64.exe --clobber --repo ${{ github.repository }} build-macos: runs-on: macos-14 # Apple Silicon (arm64) only permissions: contents: write steps: - name: Checkout uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@stable with: targets: aarch64-apple-darwin - name: Install librsvg (for rsvg-convert) env: HOMEBREW_NO_AUTO_UPDATE: "1" run: brew install librsvg - name: Build run: cargo build --release --target aarch64-apple-darwin - name: Build .icns from SVG run: | mkdir -p H7CAD.iconset # Render all the sizes Apple expects in an .icns. for SIZE in 16 32 64 128 256 512 1024; do rsvg-convert -w $SIZE -h $SIZE assets/logo.svg -o H7CAD.iconset/icon_${SIZE}x${SIZE}.png done # @2x retina variants (half-size base name) for BASE in 16 32 128 256 512; do DOUBLE=$((BASE * 2)) cp H7CAD.iconset/icon_${DOUBLE}x${DOUBLE}.png H7CAD.iconset/icon_${BASE}x${BASE}@2x.png done iconutil -c icns H7CAD.iconset -o AppIcon.icns - name: Assemble .app bundle run: | APP=H7CAD.app rm -rf "$APP" mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources" cp target/aarch64-apple-darwin/release/H7CAD "$APP/Contents/MacOS/H7CAD" chmod +x "$APP/Contents/MacOS/H7CAD" cp AppIcon.icns "$APP/Contents/Resources/AppIcon.icns" # Substitute version into Info.plist. VERSION="${{ github.ref_name }}" VERSION="${VERSION#v}" [ -z "$VERSION" ] && VERSION="0.0.0" sed "s/__VERSION__/$VERSION/g" packaging/Info.plist > "$APP/Contents/Info.plist" - name: Create .dmg run: | hdiutil create \ -volname "H7CAD" \ -srcfolder H7CAD.app \ -ov -format UDZO \ H7CAD.dmg - name: Upload .dmg to release if: github.event_name == 'release' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | mv H7CAD.dmg H7CAD-${{ github.ref_name }}-macos-arm64.dmg gh release upload ${{ github.ref_name }} H7CAD-${{ github.ref_name }}-macos-arm64.dmg --clobber --repo ${{ github.repository }}