Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and push nuget artifacts #3110

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,47 @@ jobs:
with:
name: armada-image-tarballs
path: /tmp/imgs

pack-nuget:
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true

- name: Setup the latest .NET 7 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: '23.3'

- name: Create release tag
id: create-release-tag
run: echo "release_tag=$(git describe --tags --always --dirty --match='v*' 2> /dev/null | sed 's/^v//')" >> $GITHUB_OUTPUT

- name: Pack dotnet clients
env:
RELEASE_TAG: ${{ steps.create-release-tag.outputs.release_tag }}
run: go run github.com/magefile/[email protected] -v download packNuget

- name: Save nupkg artifacts
uses: actions/upload-artifact@v3
with:
name: nupkg-artifacts
path: |
./bin/client/DotNet/G-Research.Armada.Client.${{ steps.create-release-tag.outputs.release_tag }}.nupkg
./bin/client/DotNet/ArmadaProject.Io.Client.${{ steps.create-release-tag.outputs.release_tag }}.nupkg
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,26 @@ jobs:
secrets:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}

push-nuget:
name: Push nuget clients
needs: validate
runs-on: ubuntu-22.04
environment: nuget-release
steps:
- name: Setup the latest .NET 7 SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
jgiannuzzi marked this conversation as resolved.
Show resolved Hide resolved

- name: Download artifact
run: gh run download ${{ github.event.workflow_run.id }} --repo ${{ github.event.workflow_run.repository.full_name }} --name nupkg-artifacts --dir ./bin/client/DotNet
env:
GH_TOKEN: ${{ github.token }}

- name: Push nuget clients
env:
TAG: ${{ github.event.workflow_run.head_branch }}
run: |
VERSION=${TAG#v}
dotnet nuget push ./bin/client/DotNet/G-Research.Armada.Client.$VERSION.nupkg ./bin/client/DotNet/ArmadaProject.Io.Client.$VERSION.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
30 changes: 7 additions & 23 deletions magefiles/dotnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import (
var (
defaultDotnetDockerImg = "mcr.microsoft.com/dotnet/sdk:3.1.417-buster"
releaseTag string
nugetApiKey string
useSystemCerts bool
)

func initializeDotnetRequirements() {
releaseTag = getEnvWithDefault("RELEASE_TAG", "UNKNOWN_TAG")
nugetApiKey = getEnvWithDefault("NUGET_API_KEY", "UNKNOWN_NUGET_API_KEY")
}

func sslCerts() error {
Expand Down Expand Up @@ -96,35 +94,21 @@ func Dotnet() error {
return nil
}

// Pack and push dotnet clients to nuget. Requires RELEASE_TAG and NUGET_API_KEY env vars to be set
func PushNuget() error {
// Pack dotnet clients nuget. Requires RELEASE_TAG env var to be set
func PackNuget() error {
mg.Deps(initializeDotnetRequirements, dotnetSetup, Proto)
fmt.Println("Pushing to Nuget...")
fmt.Println("Pack Nuget...")

dotnetCmd := dotnetCmd()
push := append(dotnetCmd, "dotnet", "pack", "client/DotNet/Armada.Client/Armada.Client.csproj", "-c", "Release", "-p:PackageVersion="+releaseTag, "-o", "./bin/client/DotNet")
output, err := dockerOutput(push...)
build := append(dotnetCmd, "dotnet", "pack", "client/DotNet/Armada.Client/Armada.Client.csproj", "-c", "Release", "-p:PackageVersion="+releaseTag, "-o", "./bin/client/DotNet")
output, err := dockerOutput(build...)
fmt.Println(output)
if err != nil {
return err
}

push = append(dotnetCmd, "dotnet", "nuget", "push", "./bin/client/DotNet/G-Research.Armada.Client."+releaseTag+".nupkg", "-k", nugetApiKey, "-s", "https://api.nuget.org/v3/index.json")
output, err = dockerOutput(push...)
fmt.Println(output)
if err != nil {
return err
}

push = append(dotnetCmd, "dotnet", "pack", "client/DotNet/ArmadaProject.Io.Client/ArmadaProject.Io.Client.csproj", "-c", "Release", "-p:PackageVersion="+releaseTag, "-o", "./bin/client/DotNet")
output, err = dockerOutput(push...)
fmt.Println(output)
if err != nil {
return err
}

push = append(dotnetCmd, "dotnet", "nuget", "push", "./bin/client/DotNet/ArmadaProject.Io.Client."+releaseTag+".nupkg", "-k", nugetApiKey, "-s", "https://api.nuget.org/v3/index.json")
output, err = dockerOutput(push...)
build = append(dotnetCmd, "dotnet", "pack", "client/DotNet/ArmadaProject.Io.Client/ArmadaProject.Io.Client.csproj", "-c", "Release", "-p:PackageVersion="+releaseTag, "-o", "./bin/client/DotNet")
output, err = dockerOutput(build...)
fmt.Println(output)
if err != nil {
return err
Expand Down
Loading