Manual Package Publishing #41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Manual Package Publishing" | |
on: | |
workflow_dispatch: | |
inputs: | |
package-version: | |
description: "Package Version" | |
required: true | |
localstack-client-version: | |
description: "LocalStack Client Version" | |
required: true | |
package-source: | |
type: choice | |
description: Package Source | |
required: true | |
default: "github" | |
options: | |
- nuget | |
- github | |
package-id: | |
type: choice | |
description: Package Id | |
required: true | |
default: "LocalStack.Client" | |
options: | |
- LocalStack.Client | |
- LocalStack.Client.Extensions | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
DOTNET_NOLOGO: true | |
jobs: | |
publish-manual: | |
name: "Publish to ${{ github.event.inputs.package-source }}" | |
runs-on: ubuntu-22.04 | |
env: | |
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: "Checkout" | |
uses: actions/checkout@v4 | |
- name: "Setup .NET SDK" | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
8.0.x | |
9.0.x | |
- name: "Cache NuGet packages" | |
uses: actions/cache@v4 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json', '**/*.csproj', '**/Directory.Packages.props') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- name: "Make build script executable" | |
run: chmod +x ./build.sh | |
- name: "Build & Test" | |
run: ./build.sh --target tests --skipFunctionalTest true | |
- name: "Print Package Information" | |
run: | | |
echo "📦 Package: ${{ github.event.inputs.package-id }}" | |
echo "🏷️ Version: ${{ github.event.inputs.package-version }}" | |
echo "🎯 Target: ${{ github.event.inputs.package-source }}" | |
echo "🔗 Repository: ${{ github.repository }}" | |
- name: "Setup GitHub Packages Configuration" | |
if: ${{ github.event.inputs.package-source == 'github' }} | |
run: | | |
echo "🔐 Adding GitHub Packages authentication..." | |
dotnet nuget add source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json \ | |
--name github-packages \ | |
--username ${{ github.actor }} \ | |
--password ${{ secrets.GITHUB_TOKEN }} \ | |
--store-password-in-clear-text | |
echo "📝 Backing up original nuget.config..." | |
cp nuget.config nuget.config.backup | |
echo "🔧 Using GitHub-optimized nuget.config..." | |
cp .github/nuget.config nuget.config | |
- name: "Prepare Extensions Project" | |
if: ${{ github.event.inputs.package-id == 'LocalStack.Client.Extensions' }} | |
run: | | |
./build.sh --target nuget-prepare-extensions \ | |
--package-source ${{ github.event.inputs.package-source }} \ | |
--package-id ${{ github.event.inputs.package-id }} \ | |
--client-version ${{ github.event.inputs.localstack-client-version }} | |
- name: "Pack NuGet Package" | |
run: | | |
./build.sh --target nuget-pack \ | |
--package-source ${{ github.event.inputs.package-source }} \ | |
--package-id ${{ github.event.inputs.package-id }} \ | |
--package-version ${{ github.event.inputs.package-version }} | |
- name: "Publish to GitHub Packages" | |
if: ${{ github.event.inputs.package-source == 'github' }} | |
run: | | |
./build.sh --target nuget-push \ | |
--package-source github \ | |
--package-id ${{ github.event.inputs.package-id }} \ | |
--package-version ${{ github.event.inputs.package-version }} \ | |
--package-secret ${{ secrets.GITHUB_TOKEN }} | |
- name: "Publish to NuGet.org" | |
if: ${{ github.event.inputs.package-source == 'nuget' }} | |
run: | | |
./build.sh --target nuget-push \ | |
--package-source nuget \ | |
--package-id ${{ github.event.inputs.package-id }} \ | |
--package-version ${{ github.event.inputs.package-version }} \ | |
--package-secret ${{ secrets.NUGET_API_KEY }} | |
- name: "Upload Package Artifacts" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "packages-${{ github.event.inputs.package-id }}-${{ github.event.inputs.package-version }}" | |
path: | | |
artifacts/*.nupkg | |
artifacts/*.snupkg | |
retention-days: 30 |