|
1 | | -VERSION --try 0.8 |
2 | | -IMPORT github.com/poshcode/tasks |
3 | | -FROM mcr.microsoft.com/dotnet/sdk:9.0 |
4 | | -WORKDIR /work |
| 1 | +VERSION 0.8 |
| 2 | +IMPORT github.com/poshcode/tasks:feature/ld AS tasks |
| 3 | +FROM mcr.microsoft.com/dotnet/sdk:10.0 |
| 4 | +WORKDIR /earth |
5 | 5 |
|
6 | 6 | ARG --global EARTHLY_GIT_ORIGIN_URL |
7 | 7 | ARG --global EARTHLY_BUILD_SHA |
8 | 8 | ARG --global EARTHLY_GIT_BRANCH |
9 | 9 | # These are my common paths, used in my shared /Tasks repo |
10 | | -ARG --global OUTPUT_ROOT=/Modules |
11 | | -ARG --global TEST_ROOT=/Tests |
12 | | -ARG --global TEMP_ROOT=/temp |
| 10 | +ARG --global IB_OUTPUT_ROOT=/Modules |
| 11 | +ARG --global IB_TEST_RESULTS_ROOT=/TestResults |
| 12 | +ARG --global IB_TEMP_ROOT=/temp |
13 | 13 | # These are my common build args, used in my shared /Tasks repo |
14 | | -ARG --global MODULE_NAME=ModuleBuilder |
15 | | -ARG --global CONFIGURATION=Release |
| 14 | +ARG --global IB_MODULE_NAME=ModuleBuilder |
| 15 | +ARG --global IB_CONFIGURATION=Release |
16 | 16 |
|
17 | 17 |
|
18 | 18 | bootstrap: |
19 | 19 | # Dotnet tools and scripts installed by PSGet |
20 | 20 | ENV PATH=$HOME/.dotnet/tools:$HOME/.local/share/powershell/Scripts:$PATH |
21 | | - RUN mkdir /Tasks \ |
| 21 | + RUN mkdir /Tasks $IB_OUTPUT_ROOT $IB_TEST_RESULTS_ROOT $IB_TEMP_ROOT \ |
22 | 22 | && git config --global user.email "Jaykul@HuddledMasses.org" \ |
23 | 23 | && git config --global user.name "Earthly Build" |
24 | 24 | # I'm using Invoke-Build tasks from this other repo which rarely changes |
25 | 25 | COPY tasks+tasks/* /Tasks |
26 | 26 | # Dealing with dependencies first allows earthly (docker) to cache layers for us |
27 | 27 | # So the dependency cache only re-builds when you change the list in these files |
28 | | - COPY build.requires.psd1 . |
29 | | - # COPY *.csproj . |
30 | | - RUN ["pwsh", "-File", "/Tasks/_Bootstrap.ps1", "-RequiresPath", "build.requires.psd1"] |
| 28 | + COPY build.* . |
| 29 | + COPY --if-exists dotnet-tools.json . |
| 30 | + COPY --if-exists .config/dotnet-tools.json . |
| 31 | + # COPY --if-exists **/*.csproj . |
| 32 | + RUN ["pwsh", "-File", "/Tasks/scripts/Invoke-Build.ps1", "Initialize", "build.build.ps1"] |
31 | 33 |
|
32 | 34 | build: |
33 | 35 | FROM +bootstrap |
34 | | - RUN mkdir $OUTPUT_ROOT $TEST_ROOT $TEMP_ROOT |
35 | 36 | # make sure you have output folders (like bin, obj, Modules) in .earthlyignore |
36 | 37 | # NOTE: we copy .git because we use GitVersion in the build to calculate the version |
37 | 38 | # To avoid that, we could pass the version as an ARG |
38 | 39 | COPY . . |
39 | | - RUN ["pwsh", "-Command", "Invoke-Build", "-Task", "Build", "-File", "Build.build.ps1"] |
| 40 | + RUN ["pwsh", "-File", "/Tasks/scripts/Invoke-Build.ps1", "Build", "build.build.ps1"] |
40 | 41 |
|
41 | 42 | # SAVE ARTIFACT [--keep-ts] [--keep-own] [--if-exists] [--force] <src> [<artifact-dest-path>] [AS LOCAL <local-path>] |
42 | | - SAVE ARTIFACT $OUTPUT_ROOT/$MODULE_NAME AS LOCAL ./Modules/$MODULE_NAME |
| 43 | + SAVE ARTIFACT $IB_OUTPUT_ROOT/$IB_MODULE_NAME AS LOCAL ./Output/$IB_MODULE_NAME |
43 | 44 |
|
44 | 45 | test: |
45 | 46 | FROM +build |
46 | | - SAVE ARTIFACT $OUTPUT_ROOT/$MODULE_NAME AS LOCAL ./Modules/$MODULE_NAME |
47 | | - TRY |
48 | | - RUN ["pwsh", "-Command", "Invoke-Build", "-Task", "Test", "-File", "Build.build.ps1"] |
49 | | - FINALLY |
| 47 | + SAVE ARTIFACT $IB_OUTPUT_ROOT/$IB_MODULE_NAME AS LOCAL ./Output/$IB_MODULE_NAME |
| 48 | + # TRY |
| 49 | + RUN ["pwsh", "-File", "/Tasks/scripts/Invoke-Build.ps1", "Test", "build.build.ps1"] |
| 50 | + # FINALLY |
50 | 51 | # re-output the build output so we can rely on running just +test locally |
51 | | - SAVE ARTIFACT /Tests/coverage.xml AS LOCAL ./Modules/coverage.xml |
52 | | - END |
53 | | - SAVE ARTIFACT /Tests AS LOCAL ./Modules/$MODULE_NAME-TestResults |
| 52 | + # SAVE ARTIFACT /Tests/ModuleBuilder/coverage.xml AS LOCAL ./Output/testresults/ModuleBuilder/coverage.xml |
| 53 | + # END |
| 54 | + SAVE ARTIFACT $IB_TEST_RESULTS_ROOT AS LOCAL ./Output/testresults/ |
54 | 55 | all: |
55 | 56 | # If we only reference with FROM (or COPY) the outputs will not be produced |
56 | 57 | BUILD +test |
57 | 58 | FROM +build |
58 | 59 | RUN --push --secret NUGET_API_KEY --secret PSGALLERY_API_KEY -- \ |
59 | | - pwsh -Command Invoke-Build -Task Push -File Build.build.ps1 -Verbose |
| 60 | + pwsh -File /Tasks/scripts/Invoke-Build.ps1 Push build.build.ps1 -Verbose |
0 commit comments