aboutsummaryrefslogtreecommitdiff
path: root/ci/taskfile.yaml
blob: c35b2268c5f4fefed9aa0436aec420e7e43cc973 (plain)
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
147
148
149
# https://taskfile.dev

#Called by the vnbuild system to produce builds for my website
#https://www.vaughnnugent.com/resources/software

version: "3"

vars:
  BUILDS_URL: https://www.vaughnnugent.com/public/resources/software/builds
  SQLITE_OUT_DIR: "plugins/assets/VNLib.Plugins.Extensions.Loading.Sql.SQLite"
  WEBSERVER_VERSION: 'a04d0118b671dfc647647d4c425172013011e401'

includes:
  install:
    taskfile: install.taskfile.yaml

  plugins:
    taskfile: plugins.taskfile.yaml

  container:
    dir: container  #always run from the container directory
    taskfile: container/Taskfile.yaml
    vars:
      BUILDS_URL: '{{.BUILDS_URL}}'
      PACKAGE_FILE_NAME: "sb-alpine3.19-oci.tgz"  #the name of the output package file

tasks:

  build:
    cmds:
    #clean out dist dir before building
    - cmd: powershell -Command "rm -Recurse -Force ./dist"
      ignore_error: true

    - cmd: powershell -Command "mkdir lib -Force"
      ignore_error: true
  
    - task: plugins:all
    - task: install-webserver
    - task: prune-runtimes
    
    #run container build last
    - task: container:build

  install-webserver:
    cmds:
    - cmd : powershell -Command "mkdir webserver -Force"
      ignore_error: true
    
    #clone the webserver (it's cross platform when using dotnet command so just grab the linux version)
    - task: install:install
      vars:
        PROJECT_NAME: 'VNLib.Webserver'
        MODULE_NAME: "VNLib.Webserver"
        FILE_NAME: "linux-x64-release.tgz"
        DIR: 'webserver/'
        VERSION: '{{.WEBSERVER_VERSION}}'

    #remove the executable since its not needed
    - cmd: cd webserver/ && powershell -Command "rm VNlib.WebServer"

    - for: [ windows-x86_64, linux-x86_64, osx-x86_64, windows-arm, linux-arm, osx-arm ]
      task: create-env
      vars: 
        TARGET_OS: '{{.ITEM}}'

  postbuild_success:
    cmds:
    #make bin dir
    - cmd: powershell -Command "mkdir bin -Force"
      ignore_error: true
    - for: [ windows-x86_64, linux-x86_64, osx-x86_64, windows-arm, linux-arm, osx-arm ]
      task: pack
      vars: 
        TARGET_OS: '{{.ITEM}}'

    #cleanup unnecessary build files that clog up the pipeline
    - for: [ build, plugins, dist, lib, webserver ]
      cmd: powershell -Command "rm -Recurse '{{.ITEM}}'"
      ignore_error: true

    - task: container:postbuild_success
  
  build-container:
    cmds:
     - task: container:build
    
  create-env:
    vars:
      BUILD_DIR: './build/{{.TARGET_OS}}'
    cmds:
    #create dir for env
    - cmd: powershell -Command "mkdir {{.BUILD_DIR}} -Force"
      ignore_error: true
    
    #copy build files for target os
    - for: [ plugins, dist, lib, config, webserver ]
      cmd: powershell -Command "cp -Recurse -Force {{.ITEM}} {{.BUILD_DIR}}"

    #copy release taskfile and rename it
    - cmd: powershell -Command "cp -Force release.taskfile.yaml {{.BUILD_DIR}}/Taskfile.yaml"
 
  pack:
    internal: true
    cmds:
    - cmd: powershell -Command "mkdir build/{{.TARGET_OS}}/ -Force"
      ignore_error: true
    - cd build/{{.TARGET_OS}} && tar -czf ../../bin/{{.TARGET_OS}}-release.tgz . 

  prune-runtimes:
    cmds:
    #prune sqlite runtime native libraries that Im not targeting
    #windows
    - for: ['browser-wasm', 'linux-arm', 'linux-arm64', 'linux-armel', 'linux-mips64', 'linux-musl-arm', 'linux-musl-arm64', 'linux-musl-x64', 'linux-ppc64le', 'linux-s390x', 'linux-x64', 'linux-x86', 'maccatalyst-arm64', 'maccatalyst-x64', 'osx-arm64', 'osx-x64', 'win-arm', 'win-arm64' ]
      cmd: cd build/windows-x86_64/{{.SQLITE_OUT_DIR}}/runtimes && powershell -Command "rm {{.ITEM}} -Recurse -Force"
      ignore_error: true
   
    #windows arm
    - for: ['browser-wasm', 'linux-arm', 'linux-arm64', 'linux-armel', 'linux-mips64', 'linux-musl-arm', 'linux-musl-arm64', 'linux-musl-x64', 'linux-ppc64le', 'linux-s390x', 'linux-x64', 'linux-x86', 'maccatalyst-arm64', 'maccatalyst-x64', 'osx-arm64', 'osx-x64', 'win-x86', 'win-x64' ]
      cmd: cd build/windows-arm/{{.SQLITE_OUT_DIR}}/runtimes && powershell -Command "rm {{.ITEM}} -Recurse -Force"
      ignore_error: true

    #linux x64
    - for: ['browser-wasm', 'linux-arm', 'linux-arm64', 'linux-armel', 'linux-musl-arm', 'linux-musl-arm64', 'maccatalyst-arm64', 'maccatalyst-x64', 'osx-arm64', 'osx-x64', 'win-arm', 'win-arm64', 'win-x86', 'win-x64' ]
      cmd: cd build/linux-x86_64/{{.SQLITE_OUT_DIR}}/runtimes && powershell -Command "rm {{.ITEM}} -Recurse -Force"
      ignore_error: true
 
    #linux arm
    - for: ['browser-wasm', 'linux-mips64', 'linux-musl-x64', 'linux-ppc64le', 'linux-s390x', 'linux-x64', 'linux-x86', 'maccatalyst-arm64', 'maccatalyst-x64', 'osx-arm64', 'osx-x64', 'win-arm', 'win-arm64', 'win-x86', 'win-x64' ]
      cmd: cd build/linux-arm/{{.SQLITE_OUT_DIR}}/runtimes && powershell -Command "rm {{.ITEM}} -Recurse -Force"
      ignore_error: true

    #osx x64
    - for: ['browser-wasm', 'linux-arm', 'linux-arm64', 'linux-armel', 'linux-mips64', 'linux-musl-arm', 'linux-musl-arm64', 'linux-musl-x64', 'linux-ppc64le', 'linux-s390x', 'linux-x64', 'linux-x86', 'maccatalyst-arm64', 'win-arm', 'win-arm64', 'win-x86', 'win-x64' ]
      cmd: cd build/osx-x86_64/{{.SQLITE_OUT_DIR}}/runtimes && powershell -Command "rm {{.ITEM}} -Recurse -Force"
      ignore_error: true

    #osx arm
    - for: ['browser-wasm', 'linux-arm', 'linux-arm64', 'linux-armel', 'linux-mips64', 'linux-musl-arm', 'linux-musl-arm64', 'linux-musl-x64', 'linux-ppc64le', 'linux-s390x', 'linux-x64', 'linux-x86', 'maccatalyst-x64', 'osx-x64', 'win-arm', 'win-arm64', 'win-x86', 'win-x64' ]
      cmd: cd build/osx-arm/{{.SQLITE_OUT_DIR}}/runtimes && powershell -Command "rm {{.ITEM}} -Recurse -Force"
      ignore_error: true

  clean:
    ignore_error: true
    cmds:
    - for: [ build/, bin/, dist/, plugins/, lib/, webserver/ ]
      cmd: powershell -Command "rm -Recurse -Force '{{.ITEM}}'"
    
    - task: container:clean