Build and Release #40
This file contains hidden or 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 and Release | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| create-release: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| release_id: ${{ steps.create_release.outputs.id }} | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| version: ${{ steps.get_version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Get Version | |
| id: get_version | |
| shell: bash | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.get_version.outputs.version }} | |
| name: Markpad v${{ steps.get_version.outputs.version }} | |
| draft: true | |
| prerelease: false | |
| generate_release_notes: true | |
| build: | |
| needs: create-release | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: windows-latest | |
| os: windows | |
| arch: x64 | |
| target: '' | |
| rust_target: '' | |
| - platform: windows-latest | |
| os: windows | |
| arch: arm64 | |
| target: 'aarch64-pc-windows-msvc' | |
| rust_target: 'aarch64-pc-windows-msvc' | |
| - platform: ubuntu-24.04 | |
| os: linux | |
| arch: x64 | |
| target: '' | |
| rust_target: '' | |
| - platform: macos-latest | |
| os: macos | |
| arch: universal | |
| target: 'universal-apple-darwin' | |
| rust_target: 'aarch64-apple-darwin,x86_64-apple-darwin' | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.rust_target }} | |
| - name: Install Linux dependencies | |
| if: matrix.platform == 'ubuntu-24.04' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libappindicator3-dev \ | |
| librsvg2-dev \ | |
| patchelf \ | |
| rpm \ | |
| libwebkit2gtk-4.1-0=2.44.0-2 \ | |
| libwebkit2gtk-4.1-dev=2.44.0-2 \ | |
| libjavascriptcoregtk-4.1-0=2.44.0-2 \ | |
| libjavascriptcoregtk-4.1-dev=2.44.0-2 \ | |
| gir1.2-javascriptcoregtk-4.1=2.44.0-2 \ | |
| gir1.2-webkit2-4.1=2.44.0-2 | |
| sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf rpm xdg-utils | |
| sudo snap install lxd | |
| sudo lxd waitready | |
| sudo lxd init --auto | |
| sudo usermod -aG lxd $USER | |
| sudo iptables -F FORWARD | |
| sudo iptables -P FORWARD ACCEPT | |
| sudo snap install snapcraft --classic | |
| - name: Install Frontend Dependencies | |
| run: npm install | |
| # --- Windows Build (x64) --- | |
| - name: Build Windows x64 | |
| if: matrix.platform == 'windows-latest' && matrix.arch == 'x64' | |
| run: npm run tauri build | |
| - name: Upload Windows x64 Artifacts | |
| if: matrix.platform == 'windows-latest' && matrix.arch == 'x64' | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ needs.create-release.outputs.version }}" | |
| cp src-tauri/target/release/Markpad.exe "Markpad_${VERSION}_x64.exe" | |
| cp "Markpad_${VERSION}_x64.exe" "MarkpadInstaller_${VERSION}_x64.exe" | |
| gh release upload v$VERSION "Markpad_${VERSION}_x64.exe" "MarkpadInstaller_${VERSION}_x64.exe" --clobber | |
| - name: Create Chocolatey Package | |
| if: matrix.platform == 'windows-latest' && matrix.arch == 'x64' | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| mkdir -p packaging/choco/tools | |
| cp src-tauri/target/release/Markpad.exe packaging/choco/tools/Markpad.exe | |
| cp LICENSE packaging/choco/tools/LICENSE.txt | |
| choco pack packaging/choco/markpad-app.nuspec --version ${{ needs.create-release.outputs.version }} --outdir . | |
| gh release upload v${{ needs.create-release.outputs.version }} markpad-app.${{ needs.create-release.outputs.version }}.nupkg --clobber | |
| - name: Publish to Chocolatey | |
| if: matrix.platform == 'windows-latest' && matrix.arch == 'x64' | |
| shell: pwsh | |
| env: | |
| CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }} | |
| run: | | |
| choco apikey --key $env:CHOCO_API_KEY --source https://push.chocolatey.org/ | |
| choco push markpad-app.${{ needs.create-release.outputs.version }}.nupkg --source https://push.chocolatey.org/ | |
| choco push markpad-app.${{ needs.create-release.outputs.version }}.nupkg --source https://push.chocolatey.org/ | |
| # --- Windows Build (ARM64) --- | |
| - name: Build Windows ARM64 | |
| if: matrix.platform == 'windows-latest' && matrix.arch == 'arm64' | |
| run: npm run tauri build -- --target aarch64-pc-windows-msvc | |
| - name: Upload Windows ARM64 Artifacts | |
| if: matrix.platform == 'windows-latest' && matrix.arch == 'arm64' | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION="${{ needs.create-release.outputs.version }}" | |
| cp src-tauri/target/aarch64-pc-windows-msvc/release/Markpad.exe "Markpad_${VERSION}_arm64.exe" | |
| cp "Markpad_${VERSION}_arm64.exe" "MarkpadInstaller_${VERSION}_arm64.exe" | |
| gh release upload v$VERSION "Markpad_${VERSION}_arm64.exe" "MarkpadInstaller_${VERSION}_arm64.exe" --clobber | |
| # --- Linux Build --- | |
| - name: Pre-download AppImage Dependencies | |
| if: matrix.platform == 'ubuntu-24.04' | |
| run: | | |
| mkdir -p ~/.cache/tauri | |
| wget -q https://github.com/tauri-apps/binary-releases/releases/download/apprun-old/AppRun-x86_64 -O ~/.cache/tauri/AppRun-x86_64 | |
| wget -q https://github.com/tauri-apps/binary-releases/releases/download/linuxdeploy/linuxdeploy-x86_64.AppImage -O ~/.cache/tauri/linuxdeploy-x86_64.AppImage | |
| chmod +x ~/.cache/tauri/AppRun-x86_64 ~/.cache/tauri/linuxdeploy-x86_64.AppImage | |
| - name: Build Linux | |
| if: matrix.platform == 'ubuntu-24.04' | |
| run: npm run tauri build | |
| - name: Upload Linux Artifacts | |
| if: matrix.platform == 'ubuntu-24.04' | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| find src-tauri/target/release/bundle/deb -name "*.deb" -exec gh release upload v${{ needs.create-release.outputs.version }} {} --clobber \; | |
| find src-tauri/target/release/bundle/rpm -name "*.rpm" -exec gh release upload v${{ needs.create-release.outputs.version }} {} --clobber \; | |
| find src-tauri/target/release/bundle/appimage -name "*.AppImage" -exec gh release upload v${{ needs.create-release.outputs.version }} {} --clobber \; | |
| - name: Build and Publish Snap Package | |
| if: matrix.platform == 'ubuntu-24.04' | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} | |
| run: | | |
| # Build snap | |
| sg lxd -c 'snapcraft pack' | |
| sg lxd -c 'snapcraft pack' | |
| # Find and upload the snap | |
| SNAP_FILE=$(ls *.snap | head -n 1) | |
| if [ -n "$SNAP_FILE" ]; then | |
| gh release upload v${{ needs.create-release.outputs.version }} $SNAP_FILE --clobber | |
| # Publish to snap store | |
| snapcraft push $SNAP_FILE --release stable | |
| else | |
| echo "Snap file not found!" | |
| exit 1 | |
| fi | |
| # --- MacOS Build --- | |
| - name: Build MacOS (Universal) | |
| if: matrix.platform == 'macos-latest' | |
| env: | |
| # Fix OOM issue | |
| NODE_OPTIONS: "--max-old-space-size=8192" | |
| run: npm run tauri build -- --target universal-apple-darwin | |
| - name: Upload MacOS Artifacts | |
| if: matrix.platform == 'macos-latest' | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| find src-tauri/target/universal-apple-darwin/release/bundle/dmg -name "*.dmg" -exec gh release upload v${{ needs.create-release.outputs.version }} {} --clobber \; |