Skip to content

miyako/4d-class-build-application

Repository files navigation

version license

4d-class-build-application

Classes to build, sign, archive, notarise and staple an app.

Note: there is a newer version for v20.

The project itself is a generic compiler application. See On Startup.

Usage with GitHub Actions

Example workflow here.

c.f. Learn GitHub Actions

Thanks to GitHub Actions, one can...

  • Edit a 4D project (method, class, form, etc.) online and compile for macOS including Apple Silicon
  • Edit a 4D project on Windows and compile for macOS including Apple Silicon

TODO:

  • Build .4DZ component with GitHub Actions
  • Build merged applications with GitHub Actions

Points of Interest

on:
  push:
    branches: [ main ]
    paths:
    - 'Project/*'

push event on main branch triggers the workflow. Limit to contents of the Project folder. Remember to quote the path since the forward slash is a metacharacter.

Create a copy of 4D.app. Register its download URL as a GitHub Secret, for example as URL_4D_19_272594_LTS.

c.f. Encrypted secrets

The first part of the job runs a shell script:

jobs:
  compile:
    runs-on: macos-latest
    steps:
      - name: checkout
        uses: actions/checkout@v2
      - name: compile project
        run: |
          ./main.sh ${{ secrets.URL_4D_19_272594_LTS }}

The main.sh shell script does the following:

  • Download 4D.dmg from URL_4D_19_272594_LTS
  • Mount disk image
  • Copy app to current directory
  • Clone this project to ./compiler
  • Launch this project in headless mode to run Compile project on GitHub
  • Unmount disk image
  • Delete 4D.app
  • Delete 4D.dmg
  • Delete this project

The second part of the job commits the compiled product back to the repository:

      - name: commit
        run: |
            git config --global user.name '4D-JP'
            git config --global user.email '4D-JP@users.noreply.github.com'
            git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
            git add -A
            git commit -m "Automated Compilation"
            git push

Build Application

var $buildApp : cs.BuildApp

$buildApp:=cs.BuildApp.new(New object)

$buildApp.settings.BuildApplicationName:="TEST"
$buildApp.settings.BuildApplicationSerialized:=True
$buildApp.settings.BuildMacDestFolder:=Temporary folder+Generate UUID
$buildApp.settings.SourcesFiles.RuntimeVL.RuntimeVLIncludeIt:=True
$buildApp.settings.SourcesFiles.RuntimeVL.RuntimeVLMacFolder:=System folder(Applications or program files)+"4D v19 R3"+Folder separator+"4D Volume Desktop.app"
$buildApp.settings.SignApplication.MacSignature:=False
$buildApp.settings.SignApplication.AdHocSign:=False

$buildApp.settings.Licenses.ArrayLicenseMac.Item.push(Get 4D folder(Licenses folder)+"R-4UUD190UUS001XXXXXXXXXX.license4D")
$buildApp.settings.Licenses.ArrayLicenseMac.Item.push(Get 4D folder(Licenses folder)+"R-4DDP190UUS001XXXXXXXXXX.license4D")

$status:=$buildApp.build()

Sign, Archive, Notarise, Staple Application

var $signApp : cs.SignApp

$credentials:=New object
$credentials.username:="keisuke.miyako@4d.com"  //apple ID
$credentials.password:="@keychain:altool"  //app specific password or keychain label; must be literal to use listProviders()

$signApp:=cs.SignApp.new($credentials)

$buildApp.build()

$app:=$buildApp.getPlatformDestinationFolder().folder("Final Application").folder($buildApp.settings.BuildApplicationName+".app")

$statusus:=$signApp.sign($app)

$status:=$signApp.archive($app)

If ($status.success)
	$status:=$signApp.notarize($status.file)
End if 

Credits for Inspiration

About

Classes to build, sign, archive, notarise and staple an app.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages