-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (129 loc) · 6.19 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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: Tauri build
uses: tauri-apps/tauri-action@v0
env:
VITE_SENTRY_DSN: ${{ steps.import-secrets.outputs.TROKK_VITE_SENTRY_DSN }}
VITE_SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_VITE_SENTRY_ENVIRONMENT }}
RUST_SENTRY_DSN: ${{ steps.import-secrets.outputs.TROKK_RUST_SENTRY_DSN }}
RUST_SENTRY_ENVIRONMENT: ${{ steps.import-secrets.outputs.TROKK_RUST_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 }}/"