Skip to content

Commit d13ea35

Browse files
committed
Upgrade to Tasks v2
1 parent c0e5012 commit d13ea35

4 files changed

Lines changed: 27 additions & 42 deletions

File tree

Build.build.ps1 renamed to build.build.ps1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#Requires -Modules @{ ModuleName = 'InvokeBuild'; ModuleVersion = '5.14.0' }
21
<#
32
.SYNOPSIS
43
./project.build.ps1
@@ -19,10 +18,7 @@ param(
1918

2019
## Self-contained build script - can be invoked directly or via Invoke-Build
2120
if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
22-
Write-Information "Bootstrap Build Dependencies" -Tag "InvokeBuild"
23-
. (Convert-Path ../*BuildTasks/scripts/Bootstrap.ps1)
24-
25-
Invoke-Build -File $MyInvocation.MyCommand.Path @PSBoundParameters -Result Result
21+
. (Convert-Path ../../[tT]asks/scripts/Invoke-Build.ps1) -File $MyInvocation.MyCommand.Path @PSBoundParameters -Result Result
2622

2723
if ($Result.Error) {
2824
$Error[-1].ScriptStackTrace | Out-Host

build.earth

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,60 @@
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
55

66
ARG --global EARTHLY_GIT_ORIGIN_URL
77
ARG --global EARTHLY_BUILD_SHA
88
ARG --global EARTHLY_GIT_BRANCH
99
# 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
1313
# 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
1616

1717

1818
bootstrap:
1919
# Dotnet tools and scripts installed by PSGet
2020
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 \
2222
&& git config --global user.email "Jaykul@HuddledMasses.org" \
2323
&& git config --global user.name "Earthly Build"
2424
# I'm using Invoke-Build tasks from this other repo which rarely changes
2525
COPY tasks+tasks/* /Tasks
2626
# Dealing with dependencies first allows earthly (docker) to cache layers for us
2727
# 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"]
3133

3234
build:
3335
FROM +bootstrap
34-
RUN mkdir $OUTPUT_ROOT $TEST_ROOT $TEMP_ROOT
3536
# make sure you have output folders (like bin, obj, Modules) in .earthlyignore
3637
# NOTE: we copy .git because we use GitVersion in the build to calculate the version
3738
# To avoid that, we could pass the version as an ARG
3839
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"]
4041

4142
# 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
4344

4445
test:
4546
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
5051
# 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/
5455
all:
5556
# If we only reference with FROM (or COPY) the outputs will not be produced
5657
BUILD +test
5758
FROM +build
5859
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

build.requires.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
PSScriptAnalyzer = ":[1.21.0, 2.0)"
99
InvokeBuild = ":[5.10.4, 6.0)"
1010
GitHubActions = ":[1.1.0, 2.0)"
11+
ConvertToSARIF = ":[1.0.0, 2.0)"
1112
}

dotnet-tools.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)