From 6424b00ca7a5d28253ed806e6d061d1d4118a47a Mon Sep 17 00:00:00 2001 From: Jacob Bolda Date: Wed, 2 Sep 2020 11:57:28 -0500 Subject: [PATCH] feat: build tauri communication app on demand (#1001) * feat: build tauri communication app on demand * add run command * manually set defaults, build tauri.js * add script defaults and options * run command doesn't need the `yarn` and `build` * try just build? * empty script * just skip it for now * try fix on fix/paths-expect-arrays branch * add tauri as script * use nested folders * enable on pr again * switch to preferGlobal * skip install * build without action * flip global * list * add yarn bin to path * now try with action * extra spaces * prepare for release * don't run on pr --- .github/workflows/build-smoke-tests.yml | 138 ++++++++++------------ tauri/examples/communication/package.json | 1 + 2 files changed, 62 insertions(+), 77 deletions(-) diff --git a/.github/workflows/build-smoke-tests.yml b/.github/workflows/build-smoke-tests.yml index 718a62660..c9636c323 100644 --- a/.github/workflows/build-smoke-tests.yml +++ b/.github/workflows/build-smoke-tests.yml @@ -1,63 +1,61 @@ -name: build smoke tests with source +name: build smoke test with source on: - push: - branches: - - stop-running + workflow_dispatch: + inputs: + repository: + description: 'Repository from which to pull and create a Tauri app.' + required: false + default: 'tauri-apps/tauri' + ref: + description: 'Branch or ref to pull down.' + required: false + default: 'dev' + dir: + description: 'Directory we expect to run in.' + required: false + default: 'tauri/examples/communication' + buildAssets: + description: 'Command to build the assets.' + required: false + default: 'echo no build needed' + buildTauri: + description: 'Command to build the Tauri app.' + required: false + default: 'tauri' env: RUST_BACKTRACE: 1 jobs: - node: + create-and-upload-assets: runs-on: ${{ matrix.platform }} - timeout-minutes: 40 + timeout-minutes: 30 strategy: fail-fast: false matrix: platform: [ubuntu-latest, macos-latest, windows-latest] - example: - - name: GatsbyThemedSite - folder: react/gatsby-themed-site - executable: gatsby-themed-site-app - - name: CRAApp - folder: react/create-react-app - executable: app - - name: NextjsApp - folder: react/next.js - executable: app - - name: VanillajsMonolithApp - folder: vanillajs/monolith - executable: app - - name: quasar-app - folder: vue/quasar-app - executable: app - - name: svelte-app - folder: svelte/svelte-app - executable: app include: - platform: ubuntu-latest - CARGO_HOME: ~/.cargo releaseFolder: target/release/bundle/deb - ext: _0.1.0_amd64.deb - platform: macos-latest - CARGO_HOME: ~/.cargo releaseFolder: target/release/bundle/osx - ext: .app - platform: windows-latest - CARGO_HOME: ~/.cargo - releaseFolder: target/release - ext: .x64.msi + releaseFolder: target/release/bundle/msi steps: - - name: checkout tauri - uses: actions/checkout@v2 - - name: checkout examples - uses: actions/checkout@v2 + - uses: actions/checkout@v2 with: - repository: tauri-apps/examples - ref: latest - path: examples + path: tauri + - uses: actions/checkout@v2 + with: + repository: ${{ github.event.inputs.repository }} + ref: ${{ github.event.inputs.ref }} + path: example + - name: setup node + uses: actions/setup-node@v1 + with: + node-version: 12 - name: install rust stable uses: actions-rs/toolchain@v1 with: @@ -68,45 +66,31 @@ jobs: run: | sudo apt-get update sudo apt-get install -y webkit2gtk-4.0 - - name: cache rust bin - uses: actions/cache@v1 - with: - path: ${{ format('{0}/bin/', matrix.CARGO_HOME) }} - key: ${{ runner.OS }}-build-bin-${{ hashFiles('**/Cargo.toml') }}- - - name: cache rust registry/index - uses: actions/cache@v1 - with: - path: ${{ format('{0}/registry/index/', matrix.CARGO_HOME) }} - key: ${{ runner.OS }}-build-reg-index-${{ hashFiles('**/Cargo.toml') }}- - - name: cache rust registry/cache - uses: actions/cache@v1 - with: - path: ${{ format('{0}/registry/cache/', matrix.CARGO_HOME) }} - key: ${{ runner.OS }}-build-reg-cache-${{ hashFiles('**/Cargo.toml') }}- - - run: cargo install --path ./cli/tauri-bundler --force - - name: install cli deps via yarn - working-directory: ./cli/tauri.js + - name: yarn install for cli + working-directory: tauri/cli/tauri.js run: yarn - - name: build cli & api - working-directory: ./cli/tauri.js - run: yarn build - - name: cache node modules - uses: actions/cache@v1 + - name: build tauri.js + working-directory: tauri/cli/tauri.js + run: | + yarn build-release + yarn global add $PWD + echo "::add-path::$(yarn global bin)" + - name: install and build assets + working-directory: 'example/${{ github.event.inputs.dir }}' + run: ${{ github.event.inputs.buildAssets }} + - name: cargo install tauri-bundler --force + working-directory: tauri/cli/tauri-bundler + run: cargo install tauri-bundler --path . --force + - name: build tauri app + uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - path: ${{ format('examples/node/{0}/node_modules', matrix.example.folder) }} - key: ${{ runner.OS }}-build-${{ hashFiles(format('examples/node/{0}/yarn.lock', matrix.example.folder)) }} - restore-keys: ${{ runner.OS }}-build-${{ env.cache-name }}- - - name: install via yarn - working-directory: ./examples/node/${{ matrix.example.folder }} - run: yarn - - name: build example - working-directory: ./examples/node/${{ matrix.example.folder }} - run: yarn build - - name: yarn tauri build - working-directory: ./examples/node/${{ matrix.example.folder }} - run: yarn tauri:source:build - - uses: actions/upload-artifact@v1 + includeDebug: true + projectPath: 'example/${{ github.event.inputs.dir }}' + preferGlobal: true + - uses: actions/upload-artifact@v2 if: success() with: - name: ${{ matrix.example.name }}(${{ matrix.platform }}) - path: ${{ format('./examples/node/{0}/src-tauri/{1}/{2}{3}', matrix.example.folder, matrix.releaseFolder, matrix.example.executable, matrix.ext ) }} + name: tauri-app.${{ matrix.platform }} + path: ${{ format('./{0}{1}/src-tauri/{2}/**', 'example/', github.event.inputs.dir, matrix.releaseFolder ) }} diff --git a/tauri/examples/communication/package.json b/tauri/examples/communication/package.json index 233cd59f7..d8de87b00 100644 --- a/tauri/examples/communication/package.json +++ b/tauri/examples/communication/package.json @@ -5,6 +5,7 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", + "tauri": "tauri", "build": "tauri build" }, "private": true,