Skip to content

Commit cf3a0ca

Browse files
feat: auto auth (#173)
* define is dmg running * windows compilation cfg * import libc * use raw ptr * read where from attr * resolve disk image path * solve dependencies * conditional tests * macos tests * hooks * tests on pre commit * error descriptions * mount path test * abort commit if error * format info * dmg check backing file * remove redundant code * use direct array * use command only on macos * auth token storage * format * obtain token on startup * setup base hooks * custom resources for windows * zip 2.5.0 yanked https://crates.io/crates/zip/2.5.0 updating to a closest version * auth project setup * expose auth token; * update lock * add new project to bump version script * add new project to analyzers * change resource directory * before build hook * update hook * expose logs * script read from installer setup * update build command * proper stripping * before lsdev command * add missing comma * update tauri config * prebuild auto auth * remove NSIS message boxes, proper path args propagation, version print on start, headless mode * replace json to txt for token files * read token * integration test for the token from file function * update background for dmg * remove redundant code * skip update if from dmg * auto install * macos cfg * macos cfg results * cfg for return * log auto install * adding new commands to edit dmg (#174) * adding new commands to edit dmg * correct tauri path * correct tauri path * correct create-dmg command * correct create-dmg command * consolidate and simplify changes * remove background validation * remove commented code * correct background path and app name * added back .app to icon name and remove drop-link * change to brew install --------- Co-authored-by: Nick Khalow <[email protected]> * apply format * initialization order * tests for token extraction from url * mntfrom -> mnton * enhance error message * remove parent call * enhance logging --------- Co-authored-by: Charly <[email protected]>
1 parent 5670ee8 commit cf3a0ca

File tree

27 files changed

+4208
-52
lines changed

27 files changed

+4208
-52
lines changed

.githooks/pre-commit

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
set -e
3+
4+
echo "Running checks..."
5+
6+
for dir in core src-tauri src-auto-auth; do
7+
echo "Executing $dir"
8+
(
9+
cd "$dir"
10+
echo "Format $dir"
11+
cargo fmt
12+
echo "Check $dir"
13+
cargo check
14+
echo "Clippy $dir"
15+
cargo clippy --all-targets --all-features -- -D warnings
16+
echo "Test $dir"
17+
cargo test
18+
)
19+
done
20+
21+
echo "All checks passed!"

.github/workflows/release.yml

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ jobs:
143143
VITE_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
144144

145145
- name: Import Apple Developer certificate
146-
if: ${{ matrix.os == 'macos-latest' && inputs.dry-run == false }}
146+
if: ${{ matrix.os == 'macos-latest' }}
147147
env:
148148
APPLE_CERTIFICATE: ${{ secrets.MACOS_CSC_LINK }}
149149
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CSC_KEY_PASSWORD }}
@@ -159,7 +159,7 @@ jobs:
159159
security find-identity -v -p codesigning build.keychain
160160
161161
- name: Verify Apple certificate
162-
if: ${{ matrix.os == 'macos-latest' && inputs.dry-run == false }}
162+
if: ${{ matrix.os == 'macos-latest' }}
163163
run: |
164164
CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application")
165165
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
@@ -200,10 +200,19 @@ jobs:
200200
SIGN_SCRIPT_PATH="${GITHUB_WORKSPACE}/src-tauri/scripts/sign.ps1"
201201
sed -i.bak "s|\"sign.ps1\"|\"${SIGN_SCRIPT_PATH//\\/\/}\"|g" src-tauri/tauri.conf.json
202202
203+
- name: Prebuild AutoAuth
204+
working-directory: ${{ github.workspace }}
205+
if: ${{ matrix.os == 'windows-latest' }}
206+
run: powershell -ExecutionPolicy Bypass -File ./pre-build-auto-auth.ps1
207+
203208
- name: Code Analysis Core
204209
working-directory: ${{ github.workspace }}/core
205210
run: cargo clippy --all-targets --all-features -- -D warnings
206211

212+
- name: Code Analysis AutoAuth
213+
working-directory: ${{ github.workspace }}/src-auto-auth
214+
run: cargo clippy --all-targets --all-features -- -D warnings
215+
207216
- name: Code Analysis Tauri
208217
working-directory: ${{ github.workspace }}/src-tauri
209218
run: cargo clippy --all-targets --all-features -- -D warnings
@@ -257,6 +266,99 @@ jobs:
257266
args: ${{ secrets.args }}
258267
projectPath: ${{ env.PROJECT_PATH }}
259268

269+
- name: Build & replace custom DMG (macOS)
270+
if: ${{ matrix.os == 'macos-latest' }}
271+
env:
272+
APP_NAME: Decentraland
273+
DMG_BACKGROUND: ${{ github.workspace }}/src-tauri/images/background.png
274+
OUTDIR: src-tauri/target/custom-dmg
275+
CERT_ID: ${{ env.CERT_ID }}
276+
APPLE_ID: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
277+
APPLE_PASSWORD: ${{ secrets.MACOS_NOTARIZATION_PWD }}
278+
APPLE_TEAM_ID: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
279+
run: |
280+
set -euo pipefail
281+
282+
# --- Resolve .app bundle path ---
283+
APP_PATH=$(
284+
ls -1d src-tauri/target/release/bundle/macos/${APP_NAME}.app 2>/dev/null || \
285+
ls -1d src-tauri/target/universal-apple-darwin/release/bundle/macos/${APP_NAME}.app 2>/dev/null || \
286+
ls -1d src-tauri/target/aarch64-apple-darwin/release/bundle/macos/${APP_NAME}.app 2>/dev/null || \
287+
ls -1d src-tauri/target/x86_64-apple-darwin/release/bundle/macos/${APP_NAME}.app 2>/dev/null
288+
)
289+
echo "APP_PATH=$APP_PATH" | tee -a "$GITHUB_ENV"
290+
[[ -d "$APP_PATH" ]] || { echo "❌ .app not found"; exit 1; }
291+
[[ -f "$DMG_BACKGROUND" ]] || { echo "⚠️ Missing background: $DMG_BACKGROUND"; }
292+
293+
# --- Ensure shell create-dmg is available ---
294+
brew update
295+
brew install create-dmg
296+
297+
# --- Prepare unique staging folder ---
298+
mkdir -p "$OUTDIR"
299+
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
300+
STAGE="$OUTDIR/dmg-src-$TIMESTAMP"
301+
mkdir -p "$STAGE"
302+
echo "Using staging folder: $STAGE"
303+
304+
# Copy only the .app into the staging folder
305+
cp -R "$APP_PATH" "$STAGE/${APP_NAME}.app"
306+
307+
# --- Build custom DMG ---
308+
DMG_NAME="${APP_NAME}-custom.dmg"
309+
create-dmg \
310+
--volname "Decentraland Installer" \
311+
--background "$DMG_BACKGROUND" \
312+
--window-pos 200 120 \
313+
--window-size 600 520 \
314+
--icon-size 120 \
315+
--icon "${APP_NAME}.app" 300 230 \
316+
--no-internet-enable \
317+
--format ULFO \
318+
"$OUTDIR/$DMG_NAME" \
319+
"$STAGE"
320+
321+
NEW_DMG_PATH="$OUTDIR/$DMG_NAME"
322+
echo "NEW_DMG_PATH=$NEW_DMG_PATH" | tee -a "$GITHUB_ENV"
323+
[[ -f "$NEW_DMG_PATH" ]] || { echo "❌ Custom DMG not created"; exit 1; }
324+
325+
# --- Codesign + verify ---
326+
codesign --force --sign "$CERT_ID" --timestamp "$NEW_DMG_PATH"
327+
codesign --verify --verbose "$NEW_DMG_PATH"
328+
329+
# --- Notarize + staple ---
330+
xcrun notarytool submit "$NEW_DMG_PATH" \
331+
--apple-id "$APPLE_ID" \
332+
--team-id "$APPLE_TEAM_ID" \
333+
--password "$APPLE_PASSWORD" \
334+
--wait
335+
xcrun stapler staple "$NEW_DMG_PATH"
336+
337+
# --- Replace Tauri DMG with same original filename ---
338+
DMG_DIR=$(
339+
ls -1d src-tauri/target/release/bundle/dmg 2>/dev/null || \
340+
ls -1d src-tauri/target/universal-apple-darwin/release/bundle/dmg 2>/dev/null || \
341+
ls -1d src-tauri/target/aarch64-apple-darwin/release/bundle/dmg 2>/dev/null || \
342+
ls -1d src-tauri/target/x86_64-apple-darwin/release/bundle/dmg 2>/dev/null
343+
)
344+
if [[ ! -d "$DMG_DIR" ]]; then
345+
echo "⚠️ Tauri DMG dir not found; leaving custom DMG at $NEW_DMG_PATH"
346+
exit 1
347+
fi
348+
349+
ORIG_DMG=$(ls -1 "$DMG_DIR"/*.dmg 2>/dev/null | head -n1 || true)
350+
if [[ -z "${ORIG_DMG}" ]]; then
351+
echo "❌ No existing Tauri DMG found in $DMG_DIR to infer original name"; exit 1
352+
fi
353+
ORIG_NAME="$(basename "$ORIG_DMG")"
354+
355+
rm -f "$DMG_DIR"/*.dmg
356+
FINAL_DMG="$DMG_DIR/$ORIG_NAME"
357+
cp "$NEW_DMG_PATH" "$FINAL_DMG"
358+
359+
echo "FINAL_DMG=$FINAL_DMG" | tee -a "$GITHUB_ENV"
360+
echo "✅ Replaced Tauri DMG with custom DMG at $FINAL_DMG (kept original filename)"
361+
260362
- name: Verify Windows signature
261363
if: ${{ matrix.os == 'windows-latest' && inputs.dry-run == false }}
262364
run: |

0 commit comments

Comments
 (0)