Skip to content

Commit

Permalink
Build all platforms properly + desktop testing (#1414)
Browse files Browse the repository at this point in the history
  • Loading branch information
horacioh authored Aug 29, 2023
1 parent 3a44439 commit 388fcbe
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 100 deletions.
80 changes: 41 additions & 39 deletions .github/workflows/desktop-release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Desktop Release
name: Desktop app release

on:
push:

tags:
- '*.*.*'
tags:
- "*.*.*"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -26,25 +25,29 @@ jobs:
run: |
echo "version=v${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
# echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
# echo "version=2023.08.25" >> "$GITHUB_OUTPUT"
# echo "version=0.0.100" >> "$GITHUB_OUTPUT"
build-binaries:
name: Build (${{ matrix.config.os }})
name: Build ${{ matrix.config.os }} @ ${{ matrix.config.arch }}
runs-on: ${{ matrix.config.os }}
# if: startsWith(github.ref, 'refs/tags/')
needs: [get-version]
strategy:
matrix:
config:
- os: macos-latest
arch: x64
goarch: amd64
daemon_name: x86_64-apple-darwin
# - os: macos-latest
# goarch: arm64
# daemon_name: aarch64-apple-darwin
- os: macos-latest
arch: arm64
goarch: arm64
daemon_name: aarch64-apple-darwin
- os: ubuntu-latest
arch: x64
goarch: amd64
daemon_name: x86_64-unknown-linux-gnu
- os: windows-latest
arch: x64
goarch: amd64
daemon_name: x86_64-pc-windows-msvc
steps:
Expand All @@ -55,7 +58,7 @@ jobs:
with:
matrix-os: ${{ matrix.config.os }}
# matrix-target: ${{ matrix.config.daemon_name }}
# matrix-goarch: ${{ matrix.config.goarch }}
# matrix-arch: ${{ matrix.config.arch }}

- name: Build Backend (Unix)
if: matrix.config.os != 'windows-latest'
Expand All @@ -72,63 +75,62 @@ jobs:
mkdir -p plz-out/bin/backend
go build -o plz-out/bin/backend/mintterd-${{ matrix.config.daemon_name }}.exe ./backend/cmd/mintterd
env:
GOOS: "windows"
GOARCH: ${{ matrix.config.goarch }}
CGO_ENABLED: 1

- name: Import MacOS certs
- name: Set MacOS signing certs
if: matrix.config.os == 'macos-latest'
uses: apple-actions/import-codesign-certs@v2
with:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE_BASE64 }}
p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}

# - name: create AppImage private key file
# if: matrix.config.os == 'ubuntu-latest'
# run: |
# export GPG_TTY=$(tty)
# echo "$APPIMAGE_SIGN_PRIVKEY" | gpg --batch --import
# env:
# APPIMAGE_SIGN_PRIVKEY: '${{ secrets.APPIMAGE_SIGN_PRIVKEY }}'

# - name: Setup flatpak
# if: matrix.config.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/')
# run: sudo apt install flatpak flatpak-builder elfutils

- name: Build App Package (Unix)
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE_BASE64 }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_KEYCHAIN_PASSWORD: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }}
run: |
echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
security create-keychain -p $APPLE_KEYCHAIN_PASSWORD build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p $APPLE_KEYCHAIN_PASSWORD build.keychain
security import certificate.p12 -k build.keychain -P $APPLE_CERTIFICATE_PASSWORD -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k $APPLE_KEYCHAIN_PASSWORD build.keychain
rm -fr *.p12
security set-keychain-settings -lut 1200 # prevent the keychain to get locked before codesign is done
- name: Build, package & make (Unix)
if: matrix.config.os != 'windows-latest'
run: |
TAMAGUI_TARGET=web yarn desktop:make
TAMAGUI_TARGET=web DEBUG='electron-osx-sign*,electron-notarize*' yarn desktop:make --arch=${{ matrix.config.arch }}
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
DAEMON_NAME: ${{ matrix.config.daemon_name }}
APP_VERSION: "${{ needs.get-version.outputs.version }}"
# APP_VERSION: "0.0.100"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: "${{ secrets.APPLE_ID_PASSWORD }}"
APPLE_TEAM_ID: "${{ secrets.APPLE_TEAM_ID }}"
timeout-minutes: 10

- name: Build App Package (Win32)
- name: Build, package and make (Win32)
if: matrix.config.os == 'windows-latest'
run: |
$env:TAMAGUI_TARGET="web"
yarn desktop:make
$env:DEBUG='electron-osx-sign*,electron-notarize*'
yarn desktop:make --arch=${{ matrix.config.arch }}
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
DAEMON_NAME: "${{ matrix.config.daemon_name }}.exe"
APP_VERSION: "${{ needs.get-version.outputs.version }}"
# APP_VERSION: "0.0.100"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

# WINDOWS_PFX_FILE: '${{ steps.write_file.outputs.filePath }}'
# WINDOWS_PFX_PASSWORD: '${{ secrets.WINDOWS_PFX_PASSWORD }}'

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts-${{ matrix.config.daemon_name }}
path: frontend/apps/desktop/out/make/**/*

publish-to-github:
needs: [get-version, build-binaries]
runs-on: ubuntu-latest
Expand Down
27 changes: 13 additions & 14 deletions .github/workflows/validate-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ on:
push:
branches:
- master
- electron-ci
paths:
- '.github/workflows/validate-desktop.yml'
- 'frontend/apps/desktop/**'
- 'frotend/packages/**'
- 'package.json'
- 'frontend/apps/desktop/package.json'
- ".github/workflows/validate-desktop.yml"
- "frontend/apps/desktop/**"
- "frotend/packages/**"
- "package.json"
- "frontend/apps/desktop/package.json"
pull_request:
paths:
- '.github/workflows/validate-desktop.yml'
- 'frontend/apps/desktop/**'
- 'frotend/packages/**'
- 'package.json'
- 'frontend/apps/desktop/package.json'
- ".github/workflows/validate-desktop.yml"
- "frontend/apps/desktop/**"
- "frotend/packages/**"
- "package.json"
- "frontend/apps/desktop/package.json"
branches-ignore:
- 'renovate/**'
- "renovate/**"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -33,12 +32,12 @@ jobs:

- uses: ./.github/actions/ci-setup
with:
matrix-os: 'ubuntu-latest'
matrix-os: "ubuntu-latest"

- name: Validate code
run: |
yarn validate
- name: Build Backend (Unix)
run: |
mkdir -p plz-out/bin/backend
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ plz-out
types
docs
.yarn/*
.github/*
.yarnrc.yml
.vscode/*

Expand Down
12 changes: 10 additions & 2 deletions dev
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ def main():
@cmd(
cmds, "frontend-validate", "Formats, Validates"
)
def validate(args):
def frontend_validate(args):
run("yarn validate")


@cmd(
cmds, "frontend-test", "Tests frontend code"
)
def validate(args):
def frontend_test(args):
run("yarn test")

@cmd(cmds, "run-backend", "Build and run mintterd binary for the current platform.")
Expand All @@ -138,6 +138,14 @@ def main():
@cmd(cmds, "ping-p2p", "Execute ping utility to check visibility.")
def ping_p2p(args):
return run("plz run //backend:pingp2p", args=args)

@cmd(
cmds, "release", "Create a new Release. this will create a new tag and push it to the remote repository"
)
def release(args):
# run("yarn validate")
# run("yarn test")
run("node scripts/tag.mjs")


if len(sys.argv) == 1:
Expand Down
12 changes: 12 additions & 0 deletions frontend/apps/desktop/entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
28 changes: 19 additions & 9 deletions frontend/apps/desktop/forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ const config = {
packageManager: 'yarn',
extraResource: [daemonBinaryPath],
beforeCopy: [setLanguages(['en', 'en_US'])],
osxSign: {
entitlements: './entitlements.plist',
executableName: 'Mintter',
entitlementsInherit: './entitlements.plist',
gatekeeperAssess: false,
hardenedRuntime: true,
identity:
'Developer ID Application: Mintter Technologies S.L. (XSKC6RJDD8)',
binaries: [daemonBinaryPath],
},
},
makers: [
{
Expand Down Expand Up @@ -163,19 +173,19 @@ function notarizeMaybe() {
return
}

// config.packagerConfig.osxNotarize = {
// tool: 'notarytool',
// appleId: process.env.APPLE_ID,
// appleIdPassword: process.env.APPLE_ID_PASSWORD,
// teamId: process.env.APPLE_TEAM_ID,
// }
config.packagerConfig.osxNotarize = {
tool: 'notarytool',
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
}

config.osxSign = {
entitlements: './entitlements.plist',
executableName: 'Mintter',
'entitlements-inherit': './entitlements.plist',
'gatekeeper-assess': false,
'hardened-runtime': true,
entitlementsInherit: './entitlements.plist',
gatekeeperAssess: false,
hardenedRuntime: true,
identity:
'Developer ID Application: Mintter Technologies S.L. (XSKC6RJDD8)',
binaries: [daemonBinaryPath],
Expand Down
5 changes: 3 additions & 2 deletions frontend/apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"main": ".vite/build/main.js",
"scripts": {
"dev": "electron-forge start",
"test": "playwright test",
"test": "xvfb-maybe -- playwright test",
"format": "prettier \"**/*.{ts,tsx,md,mdx,json}\" --check --ignore-path ../../../.prettierignore",
"lint": "echo TODO",
"make": "electron-forge make",
Expand Down Expand Up @@ -66,6 +66,7 @@
"electron-packager-languages": "^0.5.0",
"electron-playwright-helpers": "1.6.0",
"eslint-config-custom": "workspace:*",
"vite-tsconfig-paths": "4.2.0"
"vite-tsconfig-paths": "4.2.0",
"xvfb-maybe": "^0.2.1"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"desktop:make": "yarn workspace @mintter/desktop make",
"desktop:package": "yarn workspace @mintter/desktop package",
"desktop:publish": "yarn workspace @mintter/desktop publish",
"desktop:test": "echo 'NO TESTS'",
"desktop:test": "yarn workspace @mintter/desktop test",
"fix": "manypkg fix",
"build": "yarn workspaces foreach --exclude @mintter/site --exclude @mintter/desktop --exclude @mintter/desktop --exclude @mintter/docs -pi run build",
"upgrade:tamagui": "manypkg upgrade tamagui && manypkg upgrade @tamagui && manypkg upgrade tamagui-loader && manypkg upgrade react-native-web-lite",
Expand Down
31 changes: 0 additions & 31 deletions scripts/get-app-version.mjs

This file was deleted.

35 changes: 35 additions & 0 deletions scripts/tag.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {execSync} from 'child_process'

// Get the current year and month
const currentDate = new Date()
const year = currentDate.getFullYear()
const month = (currentDate.getMonth() + 1).toString().padStart(2, '0')
const nextMonth = (currentDate.getMonth() + 2).toString().padStart(2, '0')

// Get the number of commits in the current month
const commitCount = execSync(
`git log --since="${year}-${month}-01" --until="${year}-${nextMonth}-01" --oneline | wc -l`,
)
.toString()
.trim().padStart(2, '0')

// Construct the new version string
const newVersion = `${year}.${month}.${commitCount}`

pushTag(newVersion)

function pushTag(tagName) {
try {
// Step 1: Create a lightweight tag
execSync(`git tag ${tagName}`);

console.log('Tag created:', tagName);

// Step 2: Push the tag to remote
// execSync(`git push origin ${tagName}`);

console.log('Tag pushed:', tagName);
} catch (error) {
console.error('Error:', error.message);
}
}
Loading

0 comments on commit 388fcbe

Please sign in to comment.