Skip to content

test

test #149

Workflow file for this run

name: Build Tauri App
on:
push:
tags:
- v*
- test*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-binaries:
strategy:
fail-fast: false
matrix:
platform:
# Disabled due to issues with linux building https://github.com/tauri-apps/tauri/issues/8929#issuecomment-1956338150
# NO_STRIP=TRUE fix didn't work, so we are disabling linux builds for now
#- [ self-hosted ]
- [ self-hosted, Windows ]
include:
- platform: [ self-hosted ]
linux: true
- platform: [ self-hosted, Windows ]
windows: true
linux: false
runs-on: ${{ matrix.platform }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VAULT_BASE_URL: ${{ secrets.VAULT_BASE_URL }}
VAULT_ROLE_ID: ${{ secrets.VAULT_ROLE_ID }}
VAULT_SECRET_ID: ${{ secrets.VAULT_SECRET_ID }}
RUST_BACKTRACE: full
RUST_LOG: debug
ACTIONS_STEP_DEBUG: true
steps:
- name: Import Secrets
id: import-secrets
uses: hashicorp/vault-action@v2
with:
url: ${{ secrets.VAULT_BASE_URL }}
method: approle
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
secrets: |
kv/team/text/data/artifactory * | ART_ ;
kv/team/text/data/trokk-stage * | TROKK_ ;
# Git fix for Windows, workaround for permission issues regarding self-hosted runners
- name: Windows; Git fix
if: ${{ matrix.windows }}
run: |
git config --global --add safe.directory C:/Users/lanman/actions-runner/_work/trokk/trokk
- uses: actions/checkout@v4
- name: Ubuntu; Install dependencies
if: ${{ matrix.linux }}
run: |
sudo apt-get update -y
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf libssl-dev curl build-essential
- name: Rust; Install Rust stable actions rust lang
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: false
toolchain: stable
components: rustfmt, clippy
# Cache target directory, ignore the bundle directory. See reasons for this globbing https://github.com/actions/toolkit/issues/713
# Only cache the target directory, avoid "~/.cargo" since this is on a self-hosted runner, there is no need.
- uses: actions/cache@v3
with:
path: |
src-tauri/target/*/*
!src-tauri/target/release/bundle
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: NPM; Sync node version and setup cache
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm' # Set this to npm, yarn or pnpm.
- name: NPM; Install frontend dependencies
run: npm ci
- name: Windows NPM; Install windows dependency
if: ${{ matrix.windows }}
run: npm install @tauri-apps/[email protected]
# TODO when tests are set up again
#- name: NPM; Run frontend tests
# run: npm run test
# Regex match to simple semver without v, and can have an extra dash or plus with numbers behind.
# Examples: 1.2.3, 0.1.2, 0.0.0-123, 1.2.5+123123
# These are the versions that works with both 'npm version' and Tauri (WiX, used by Tauri, has the hardest restrictions).
# More info about the restrictions for tauri here
# https://github.com/tauri-apps/tauri/blob/26f2e19a4f0e609c95c0aba5faefab2eb83a179e/tooling/bundler/src/bundle/windows/msi/wix.rs#L247
# Tauri does not allow 'v' in front of version, npm adds it if it does not exist. Therefore, we remove 'v' if it exists.
# Should be mentioned that our rules in the beginning of this action requires a leading 'v' to build, but that does not matter in this step.
- name: NPM; Set version
shell: bash
run: |
pattern="^[0-9]+.[0-9]+.[0-9]+([-+][0-9]+)?$"
version_modified=$(echo ${{ github.ref_name }} | sed -e '/^v/s/^v//')
if [[ $version_modified =~ $pattern ]]; then
npm version $version_modified --no-git-tag-version
sed -i "s/version = \"0.0.0\"/version = \"$version_modified\"/g" src-tauri/Cargo.toml
echo "Version set to 'v$version_modified'"
else
echo "'${{ github.ref_name }}' is not a valid version - using default. Must be a numerical only semver version."
fi
- name: Supply webview2
if: ${{ matrix.windows }}
shell: cmd
run: |
curl -L -o Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/023aa9c1-c16d-4b52-a1dd-55f125aa3061/Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab"
where expand
where expand.exe
expand.exe Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab -f:* ./src-tauri
del Microsoft.WebView2.FixedVersionRuntime.131.0.2903.99.x86.cab
- name: Tauri build
uses: tauri-apps/tauri-action@v0
env:
VITE_SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }}
VITE_SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }}
SENTRY_URL: ${{ steps.import-secrets.outputs.TROKK_SENTRY_DSN }}
SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_SENTRY_ENVIRONMENT }}
id: tauri_build
- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@v3
# Upload to Artifactory
# Echo array of absolute paths to created artifacts.
# e.g. '["/home/runner/work/trokk/trokk/src-tauri/target/release/bundle/deb/app.deb", "/home/runner/work/trokk/trokk/src-tauri/target/release/bundle/appimage/app.appimage"]'
# sed directly after echo is to handle windows paths with backwards slashes
# e.g. C:\Users\user\actions-runner\_work\trokk\trokk\src-tauri\target\release\bundle\nsis\app.nsis
# jq is used to parse the array
# sed is used to remove the absolute path and only keep the relative path to the artifact
- name: Upload to Artifactory
shell: bash
working-directory: ./src-tauri/target/release/bundle
run: |
echo '${{ steps.tauri_build.outputs.artifactPaths }}' |
sed -e 's#\\#/#g' -e 's#//#/#g' |
jq -r .[] |
sed -n -e 's/^.*bundle\///p' |
xargs -I % jf rt u --url ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_URL }} --user ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_USER }} --password ${{ steps.import-secrets.outputs.ART_ARTIFACTORY_PASSWORD }} % "generic/trokk/${{ github.ref_name }}/"