From e01b305970eb07330d89412b70ea65e1e41cd57d Mon Sep 17 00:00:00 2001 From: Vincent Emonet Date: Wed, 20 Mar 2024 23:40:03 +0100 Subject: [PATCH] merge 2 workflows in 1 --- .github/workflows/build.yml | 94 +++++++++++++++++++++++++---- .github/workflows/release.yml | 109 ---------------------------------- README.md | 9 ++- src/routes/+page.svelte | 2 + 4 files changed, 92 insertions(+), 122 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3e6e5cb..c77424a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,21 +1,27 @@ -name: 'Build app' -on: [push, pull_request, workflow_call, workflow_dispatch] +name: 'Build' +on: + workflow_dispatch: + push: + branches: [main, release] + pull_request: jobs: - test-tauri: + build-tauri: + name: 🐂 Build with Tauri + permissions: + contents: write strategy: fail-fast: false matrix: platform: [macos-latest, ubuntu-latest, windows-latest] - runs-on: ${{ matrix.platform }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 16 + node-version: 20 - name: Install Rust stable uses: dtolnay/rust-toolchain@stable @@ -26,16 +32,82 @@ jobs: sudo apt-get update sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf - - name: Install app dependencies + - name: Install frontend dependencies run: yarn - name: Lint check if: matrix.platform == 'ubuntu-latest' run: yarn lint - - name: Build the app - run: yarn build + - name: Build with tauri to test + if: github.ref != 'refs/heads/release' + uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: tauri-apps/tauri-action@v0 + - name: Build and publish with tauri + if: github.ref == 'refs/heads/release' + id: create-release + uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version + releaseName: 'Emoji Mart v__VERSION__' + releaseBody: 'See the assets to download this version and install.' + releaseDraft: false + prerelease: false + + + build-flatpak: + name: 📦️ Build with Flatpak + needs: build-tauri + runs-on: ubuntu-latest + container: + image: bilelmoussaoui/flatpak-github-actions:gnome-45 + options: --privileged + + steps: + - uses: actions/checkout@v4 + with: + repository: flathub/io.github.vemonet.EmojiMart + ref: dev + submodules: 'recursive' + + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Update package version in flatpak manifest + # env: + # PACKAGE_VERSION: ${{ needs.create-release.outputs.releaseId }} + run: | + curl -L -o package.json https://raw.github.com/vemonet/EmojiMart/release/package.json + PACKAGE_VERSION=$(node -p "require('./package.json').version") + rm package.json + echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV + sed -i "s/- --device=dri/- --device=all/g" ./io.github.vemonet.EmojiMart.yml + sed -i "s/tag: v[0-9]*\.[0-9]*\.[0-9]*$/tag: v$PACKAGE_VERSION/g" ./io.github.vemonet.EmojiMart.yml + sed -i "s/$/\\n \\n <\/release>\\n/g" ./io.github.vemonet.EmojiMart.appdata.xml + echo "🏷️ Publishing $PACKAGE_VERSION" + + - name: Build flatpak + uses: flatpak/flatpak-github-actions/flatpak-builder@v6.1 + with: + bundle: EmojiMart.flatpak + manifest-path: io.github.vemonet.EmojiMart.yml + cache-key: flatpak-builder-${{ github.sha }} + + - uses: actions/upload-artifact@v4 + with: + name: EmojiMart.flatpak + path: EmojiMart.flatpak + + - name: Update Release + if: github.ref == 'refs/heads/release' + uses: softprops/action-gh-release@v1 + with: + files: | + EmojiMart.flatpak + tag_name: v${{ github.env.PACKAGE_VERSION }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index ae79333..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: 'Publish new release' -# Triggered when pushing to the `release` branch -on: - push: - branches: [release] - workflow_dispatch: - -jobs: - create-release: - permissions: - contents: write - strategy: - fail-fast: false - matrix: - platform: [macos-latest, ubuntu-latest, windows-latest] - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v3 - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - - - name: Install Rust stable - uses: dtolnay/rust-toolchain@stable - - - name: Install dependencies (ubuntu only) - if: matrix.platform == 'ubuntu-latest' - run: | - sudo apt-get update - sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf - - - name: Install frontend dependencies - run: yarn - - - name: Lint check - if: matrix.platform == 'ubuntu-latest' - run: yarn lint - - - name: Build and publish with tauri - id: create-release - uses: tauri-apps/tauri-action@v0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version - releaseName: 'Emoji Mart v__VERSION__' - releaseBody: 'See the assets to download this version and install.' - releaseDraft: false - prerelease: false - - # Unfortunately does not return the actual release tag - # outputs: - # releaseId: ${{ steps.create-release.outputs.releaseId }} - - publish-flatpak: - needs: create-release - runs-on: ubuntu-latest - container: - image: bilelmoussaoui/flatpak-github-actions:gnome-44 - options: --privileged - - steps: - - uses: actions/checkout@v4 - with: - repository: flathub/io.github.vemonet.EmojiMart - ref: dev - submodules: 'recursive' - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 20 - - - name: Update package version in flatpak manifest - # env: - # PACKAGE_VERSION: ${{ needs.create-release.outputs.releaseId }} - run: | - curl -L -o package.json https://raw.github.com/vemonet/EmojiMart/release/package.json - PACKAGE_VERSION=$(node -p "require('./package.json').version") - rm package.json - echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV - sed -i "s/- --device=dri/- --device=all/g" ./io.github.vemonet.EmojiMart.yml - sed -i "s/tag: v[0-9]*\.[0-9]*\.[0-9]*$/tag: v$PACKAGE_VERSION/g" ./io.github.vemonet.EmojiMart.yml - sed -i "s/$/\\n \\n <\/release>\\n/g" ./io.github.vemonet.EmojiMart.appdata.xml - echo "🏷️ Publishing $PACKAGE_VERSION" - - - name: Build flatpak - uses: flatpak/flatpak-github-actions/flatpak-builder@v6.1 - with: - bundle: EmojiMart.flatpak - manifest-path: io.github.vemonet.EmojiMart.yml - cache-key: flatpak-builder-${{ github.sha }} - - - uses: actions/upload-artifact@v3 - with: - name: EmojiMart.flatpak - path: EmojiMart.flatpak - - - name: Update Release - if: github.event_name == 'release' - uses: softprops/action-gh-release@v1 - with: - files: | - EmojiMart.flatpak - # EmojiMart-.flatpak - # Tag auto pick from release trigger env - # tag_name: v${{ github.env.PACKAGE_VERSION }} diff --git a/README.md b/README.md index 7cfedf8..b4081bd 100644 --- a/README.md +++ b/README.md @@ -71,9 +71,11 @@ flatpak run io.github.vemonet.EmojiMart --lang fr gsettings set org.gnome.mutter center-new-windows true ``` + +
Alternatively, but not recommended, you can also use the .AppImage file This is not recommended, as the apps takes longer to startup than with the flatpak, and not all dependencies are included to auto-paste. @@ -153,7 +157,8 @@ Inspired by: ## 🛠️ Development -[![Latest release](https://shields.io/github/v/release/vemonet/EmojiMart)](https://github.com/vemonet/EmojiMart/releases/latest) [![Build app](https://github.com/vemonet/EmojiMart/actions/workflows/build.yml/badge.svg)](https://github.com/vemonet/EmojiMart/actions/workflows/build.yml) [![Publish new release](https://github.com/vemonet/EmojiMart/actions/workflows/release.yml/badge.svg)](https://github.com/vemonet/EmojiMart/actions/workflows/release.yml) +[![Latest release](https://shields.io/github/v/release/vemonet/EmojiMart)](https://github.com/vemonet/EmojiMart/releases/latest) +[![Build](https://github.com/vemonet/EmojiMart/actions/workflows/build.yml/badge.svg)](https://github.com/vemonet/EmojiMart/actions/workflows/build.yml) Built with [Tauri](https://tauri.app/), [Svelte](https://svelte.dev), [TypeScript](https://www.typescriptlang.org/), and [Vite](https://vitejs.dev/). diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 8d5f325..ad43b1e 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -25,6 +25,8 @@ if (pickMulti) { selection.push(emoji.native) } else { + // Adding to the clipboard and hiding the window is done here + // Rust handles auto-paste const previous = await clipboard.readText() clipboard.writeText(emoji.native) appWindow.hide()