Skip to content

Merge pull request #15 from anddone-kit/dependabot/nuget/src/AndDoneS… #10

Merge pull request #15 from anddone-kit/dependabot/nuget/src/AndDoneS…

Merge pull request #15 from anddone-kit/dependabot/nuget/src/AndDoneS… #10

Workflow file for this run

name: Publish Package (Production)
on:
push:
branches:
- main
jobs:
mirror-and-publish:
runs-on: ubuntu-latest
# limit this to running only on our private repo to avoid duplicate action when we push to the public repo
if: github.repository == 'AndDone-LLC/AndDone-SecureAPI-ClientLibrary-DotNet-private'
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Debug repo access
run: |
echo "PUBLIC_REPO value: ${{ vars.PUBLIC_REPO }}"
curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: token ${{ secrets.CLIENT_LIBRARY_NUGET_AUTH_TOKEN }}" \
https://api.github.com/repos/${{ vars.PUBLIC_REPO }}
# ── Mirror to Public Repo ──────────────────────────────────
- name: Push to public repo
run: |
git remote add public https://x-access-token:${{ secrets.CLIENT_LIBRARY_NUGET_AUTH_TOKEN }}@github.com/${{ vars.PUBLIC_REPO }}.git
git push public main --force
# ── Build & Publish to Public Account ──────────────────────
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Authenticate GitHub Packages
run: |
dotnet nuget remove source githubanddone --configfile src/AndDoneSecureClientLibrary/nuget.config
dotnet nuget add source \
--username ${{ github.repository_owner }} \
--password ${{ secrets.CLIENT_LIBRARY_NUGET_AUTH_TOKEN }} \
--store-password-in-clear-text \
--name githubanddone \
--configfile src/AndDoneSecureClientLibrary/nuget.config \
"https://nuget.pkg.github.com/AndDone-LLC/index.json"
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run tests
run: dotnet test --configuration Release --no-restore --no-build
- name: Pack
run: dotnet pack --configuration Release --no-build --output ./nupkg /p:RepositoryUrl=https://github.com/anddone-kit/AndDone-SecureAPI-ClientLibrary-DotNet.git
- name: Push to GitHub Packages (Public)
run: |
PUBLIC_OWNER=$(echo "${{ vars.PUBLIC_REPO }}" | cut -d'/' -f1)
dotnet nuget push ./nupkg/*.nupkg \
--api-key ${{ secrets.CLIENT_LIBRARY_NUGET_AUTH_TOKEN }} \
--source "https://nuget.pkg.github.com/$PUBLIC_OWNER/index.json" \
--skip-duplicate