version: 43
jobs:
- name: Build for x86_64
  steps:
  - type: CheckoutStep
    name: Checkout
    cloneCredential:
      type: DefaultCredential
    withLfs: true
    withSubmodules: true
    condition: SUCCESSFUL
    optional: false
  - type: CommandStep
    name: Build VSCode Extension
    runInContainer: true
    image: node:latest
    interpreter:
      type: DefaultInterpreter
      commands: |
        cd vscode-extension
        npm install
        npm install -g typescript
        npm install -g @@vscode/vsce
        vsce package
    useTTY: true
    condition: SUCCESSFUL
    optional: false
  - type: CommandStep
    name: Build everything
    runInContainer: true
    image: onedev.site.tesses.net/crosslang/crosslang:latest
    interpreter:
      type: DefaultInterpreter
      commands: |
        crossint ./build.tcross pack
    useTTY: true
    condition: SUCCESSFUL
    optional: false
  - type: PublishArtifactStep
    name: Publish shell package
    artifacts: Tesses.CrossLang.ShellPackage-*.crvm
    condition: SUCCESSFUL
    optional: false
  - type: PublishArtifactStep
    name: Publish Package Server
    sourcePath: Tesses.CrossLang.PackageServer/bin/
    artifacts: Tesses.CrossLang.PackageServer-*.crvm
    condition: SUCCESSFUL
    optional: false
  - type: BuildImageStep
    name: Build container
    dockerfile: Dockerfile
    output:
      type: RegistryOutput
      tags: onedev.site.tesses.net/crosslang/crosslangextras/crosslangextras:latest
    registryLogins:
    - registryUrl: '@server_url@'
      userName: '@job_token@'
      passwordSecret: dockersecret
    condition: SUCCESSFUL
    optional: false
  - type: SCPCommandStep
    name: Copy Shell Package
    privateKeySecret: tesses_www_private_key
    source: Tesses.CrossLang.ShellPackage-*.crvm
    target: mike@@10.137.42.28:/var/www/downloads/ShellPackage.crvm
    condition: SUCCESSFUL
    optional: false
  - type: BuildImageStep
    name: Build container (package server)
    dockerfile: Dockerfile.packageserver
    output:
      type: RegistryOutput
      tags: onedev.site.tesses.net/crosslang/crosslangextras/packageserver:latest
    registryLogins:
    - registryUrl: '@server_url@'
      userName: '@job_token@'
      passwordSecret: dockersecret
    condition: SUCCESSFUL
    optional: false
  - type: CommandStep
    name: Push packages to CPKG
    runInContainer: true
    image: onedev.site.tesses.net/crosslang/crosslangextras/crosslangextras:latest
    interpreter:
      type: DefaultInterpreter
      commands: |
        cd Tesses.CrossLang.PackageServer
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../Tesses.CrossLang.Args
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../Tesses.CrossLang.BuildEssentials
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../Tesses.CrossLang.Std
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../Tesses.CrossLang.Reference
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../Templates/compiletool
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../console
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../emptyweb
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../lib
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../template
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../tool
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../web
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
        cd ../webapp
        crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/"
    envVars:
    - name: CPKG_KEY
      value: '@secret:CPKG_KEY@'
    useTTY: true
    condition: SUCCESSFUL
    optional: false
  - type: CommandStep
    name: push to coolify
    runInContainer: true
    image: curlimages/curl:latest
    interpreter:
      type: DefaultInterpreter
      commands: |
        curl "$COOLIFY_WEBHOOK" -H "Authorization: Bearer $COOLIFY_TOKEN"
    envVars:
    - name: COOLIFY_WEBHOOK
      value: '@secret:COOLIFY_WEBHOOK@'
    - name: COOLIFY_TOKEN
      value: '@secret:COOLIFY_TOKEN@'
    useTTY: true
    condition: SUCCESSFUL
    optional: false
  triggers:
  - type: DependencyFinishedTrigger
    projects: crosslang
  - type: BranchUpdateTrigger
    branches: master
    userMatch: anyone
    projects: crosslang/crosslangextras
  projectDependencies:
  - projectPath: crosslang
    buildProvider:
      type: LastFinishedBuild
      jobName: Build for x86_64
    artifacts: -**
  retryCondition: never
  maxRetries: 3
  retryDelay: 30
  timeout: 14400
