Skip to content

Commit

Permalink
Fix Pushing
Browse files Browse the repository at this point in the history
Change PSGALLERY_API_KEY
  • Loading branch information
Jaykul committed Nov 13, 2023
1 parent 838a666 commit 744f6ef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: CI

on:
push:
branches: [ main ]
push: {}
pull_request:
branches: [ main ]

Expand All @@ -14,16 +13,24 @@ jobs:
steps:
- uses: earthly/actions-setup@v1
with:
# version: v0.7.21
github-token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0

- name: earthly +all
run: earthly --strict +all
- name: earthly +test
if: github.ref != 'refs/heads/main'
run: earthly --strict +test

- name: earthly +push
if: github.ref == 'refs/heads/main'
run: earthly --push --secret NUGET_API_KEY= --secret PSGALLERY_API_KEY --strict +all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}

- uses: actions/upload-artifact@v3
with:
Expand Down
26 changes: 15 additions & 11 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ IMPORT github.com/poshcode/tasks
FROM mcr.microsoft.com/dotnet/sdk:7.0
WORKDIR /work

ARG --global EARTHLY_GIT_ORIGIN_URL
ARG --global EARTHLY_BUILD_SHA
ARG --global EARTHLY_GIT_BRANCH
# These are my common paths, used in my shared /Tasks repo
Expand All @@ -12,8 +13,8 @@ ARG --global TEMP_ROOT=/temp
# These are my common build args, used in my shared /Tasks repo
ARG --global MODULE_NAME=Pansies
ARG --global CONFIGURATION=Release
ARG --global PSMODULE_PUBLISH_KEY
ARG --global NUGET_API_KEY
# ARG --global PSMODULE_PUBLISH_KEY
# ARG --global NUGET_API_KEY

worker:
# Dotnet tools and scripts installed by PSGet
Expand All @@ -27,38 +28,41 @@ worker:
# So the dependency cach only re-builds when you add a new dependency
COPY RequiredModules.psd1 .
COPY *.csproj .
RUN ["pwsh", "--file", "/Tasks/_Bootstrap.ps1", "-RequiredModulesPath", "RequiredModules.psd1"]
RUN ["pwsh", "-File", "/Tasks/_Bootstrap.ps1", "-RequiredModulesPath", "RequiredModules.psd1"]

build:
FROM +worker
RUN mkdir $OUTPUT_ROOT $TEST_ROOT $TEMP_ROOT
COPY . .
# make sure you have bin and obj in .earthlyignore, as their content from context might cause problems
RUN ["pwsh", "--command", "Invoke-Build", "-Task", "Build", "-File", "Build.build.ps1"]
RUN ["pwsh", "-Command", "Invoke-Build", "-Task", "Build", "-File", "Build.build.ps1"]

# SAVE ARTIFACT [--keep-ts] [--keep-own] [--if-exists] [--force] <src> [<artifact-dest-path>] [AS LOCAL <local-path>]
SAVE ARTIFACT $OUTPUT_ROOT/$MODULE_NAME AS LOCAL ./Modules/$MODULE_NAME

test:
# If we run a target as a reference in FROM or COPY, it's outputs will not be produced
BUILD +build
FROM +build
# make sure you have bin and obj in .earthlyignore, as their content from context might cause problems
RUN ["pwsh", "--command", "Invoke-Build", "-Task", "Test", "-File", "Build.build.ps1"]
RUN ["pwsh", "-Command", "Invoke-Build", "-Task", "Test", "-File", "Build.build.ps1"]

# SAVE ARTIFACT [--keep-ts] [--keep-own] [--if-exists] [--force] <src> [<artifact-dest-path>] [AS LOCAL <local-path>]
SAVE ARTIFACT $TEST_ROOT AS LOCAL ./Modules/$MODULE_NAME-TestResults

pack:
BUILD +build # So that we get the build artifact too
FROM +build
RUN ["pwsh", "--command", "Invoke-Build", "-Task", "Pack", "-File", "Build.build.ps1", "-Verbose"]
BUILD +test # So that we get the module artifact from build too
FROM +test
RUN ["pwsh", "-Command", "Invoke-Build", "-Task", "Pack", "-File", "Build.build.ps1", "-Verbose"]
SAVE ARTIFACT $OUTPUT_ROOT/publish/*.nupkg AS LOCAL ./Modules/$MODULE_NAME-Packages/

publish:
FROM +build
RUN ["pwsh", "--command", "Invoke-Build", "-Task", "Publish", "-File", "Build.build.ps1", "-Verbose"]
push:
FROM +pack
RUN --push --secret NUGET_API_KEY --secret PSGALLERY_API_KEY -- \
pwsh -Command Invoke-Build -Task Push -File Build.build.ps1 -Verbose

all:
# BUILD +build
BUILD +test
BUILD +pack
BUILD +push

0 comments on commit 744f6ef

Please sign in to comment.