diff --git a/LICENSE b/LICENSE index a426ef2..5ef024b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,6 @@ +MIT License -The MIT License (MIT) - -Copyright (c) 2018 GitHub, Inc. and contributors +Copyright (c) 2022 Jonas Kruckenberg Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -10,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 50e8a06..8a2ef1e 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,236 @@

+

tauri-build

typescript-action status

+A composable action to build your Tauri project. + ## Usage +As opposed to the offical [tauri-action](https://github.com/tauri-apps/tauri-action) this action is as minimal as possible. +Instead of creating a GitHub release and uploading artifacts all-in-one, it provides outputs to conveniently compose together with other actions such as `actions/upload-artifact`, `actions/download-artifact` or `softprops/action-gh-release`. + +### Minimal + +The following example workflow builds artifacts on all 3 supported platforms (Window, macOS and Linux). + +```yaml +name: 'publish' + +on: + push: + branches: + - release + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-binaries: + strategy: + fail-fast: false + matrix: + platform: [macos-latest, ubuntu-latest, windows-latest] + + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v2 + + - name: setup node + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: install Rust stable + uses: actions-rs/toolchain@v1 + with: + 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 webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf + + - uses: JonasKruckenberg/tauri-build@v0.1.2-beta.9 + id: tauri_build + + # You can now use the JSON array of artifacts under `steps.tauri_build.outputs.artifacts` to post-process/upload your bundles +``` + +### Bundling the app and creating a release + +Chances are you want to do *something* with the artifacts that you produced. The following action will produce artifacts for Windows, macOS and Linux upload them as workflow artifacts, so that a final job (called `publish`) can create a GitHub release and attach all prouced artifacts to it. This would also be the place where you could upload artifacts to an AWS Bucket or similar. + +```yaml +name: 'publish' + +on: + push: + branches: + - release + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-binaries: + strategy: + fail-fast: false + matrix: + platform: [macos-latest, ubuntu-latest, windows-latest] + + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v2 + + - name: setup node + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: install Rust stable + uses: actions-rs/toolchain@v1 + with: + 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 webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf + + - uses: JonasKruckenberg/tauri-build@v0.1.2-beta.9 + id: tauri_build + + # The `artifacts` output can now be used by a different action to upload the artifacts + - uses: actions/upload-artifact@v3 + with: + name: artifacts + path: "${{ join(fromJSON(steps.tauri_build.outputs.artifacts), '\n') }}" + + publish: + needs: build-binaries + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + # Download the previously uploaded artifacts + - uses: actions/download-artifact@v3 + id: download + with: + name: artifacts + path: artifacts + # And create a release with the artifacts attached + - name: 'create release' + uses: softprops/action-gh-release@master + env: + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + with: + draft: false + files: ./artifacts/**/* +``` + +### Building for Apple Silicon + +This example workflow will run produce binaries for Apple Silicon (aarch64) as well as the previously shown 3 platforms. This leverages the build matrix. This can be expanded to produce binaries for other target combinations too. + +```yaml +name: 'publish' + +on: + push: + branches: + - release + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-binaries: + strategy: + fail-fast: false + matrix: + platform: [macos-latest, ubuntu-latest, windows-latest] + include: + - os: ubuntu-latest + rust_target: x86_64-unknown-linux-gnu + - os: macos-latest + rust_target: x86_64-apple-darwin + - os: macos-latest + rust_target: aarch64-apple-darwin + - os: windows-latest + rust_target: x86_64-pc-windows-msvc + + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v2 + + - name: setup node + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: install Rust stable + uses: actions-rs/toolchain@v1 + with: + 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 webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf + + - uses: JonasKruckenberg/tauri-build@v0.1.2-beta.9 + id: tauri_build + with: + target: ${{ matrix.rust_target }} + + # The `artifacts` output can now be used by a different action to upload the artifacts + - uses: actions/upload-artifact@v3 + with: + name: artifacts + path: "${{ join(fromJSON(steps.tauri_build.outputs.artifacts), '\n') }}" + + publish: + needs: build-binaries + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + # Download the previously uploaded artifacts + - uses: actions/download-artifact@v3 + id: download + with: + name: artifacts + path: artifacts + # And create a release with the artifacts attached + - name: 'create release' + uses: softprops/action-gh-release@master + env: + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + with: + draft: false + files: ./artifacts/**/* +``` + ## Inputs | Name | Type | Description | Default | -|---------------|---------|-------------------------------------------------------------|-------------------| +| ------------- | ------- | ----------------------------------------------------------- | ----------------- | | `runner` | String | Binary to use to build the application | | | `args` | String | Additional arguments for the build command | | | `projectPath` | String | Path to the root of the Tauri project | . | | `configPath` | String | Path to the tauri.conf.json file, relative to `projectPath` | `tauri.conf.json` | | `target` | String | Rust target triple to build against | | -| `debug` | Boolean | Wether to build *debug* or *release* binaries | false | +| `debug` | Boolean | Wether to build _debug_ or _release_ binaries | false | ## Outputs | Name | Type | Description | -|-------------|--------|------------------------------------------------------------| +| ----------- | ------ | ---------------------------------------------------------- | | `artifacts` | String | JSON array of artifact paths produced by the build command | ## Permissions @@ -28,4 +240,8 @@ This Action requires the following permissions on the GitHub integration token: ```yaml permissions: contents: write -``` \ No newline at end of file +``` + +## License + +[MIT © Jonas Kruckenberg](./LICENSE) \ No newline at end of file