From 25ed6d6e98eee247aa73704a7980245c5fe147f0 Mon Sep 17 00:00:00 2001 From: Christopher Schuchardt Date: Wed, 14 Feb 2024 04:22:49 -0500 Subject: [PATCH] Added `publish` to `github packages` (#3072) * Added nuget packages source * test * Changed to windows * fixed version * fix * fix nuget * fixed nuget.config * Fixed test * Nuget fixes * git * working release * Added cron job * switch to keep 3 packages versions * Update .github/workflows/main.yml * Update .github/workflows/main.yml Co-authored-by: Shargon * change secret * change delete also --------- Co-authored-by: Jimmy Co-authored-by: Shargon --- .github/workflows/main.yml | 38 +++++++++++++++++++++++ .github/workflows/pkgs-delete.yml | 51 +++++++++++++++++++++++++++++++ NuGet.Config | 1 + 3 files changed, 90 insertions(+) create mode 100644 .github/workflows/pkgs-delete.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bce1dc7c79..4f7696cf6e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,6 +38,44 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: ./coverage/lcov.net7.0.info + PublishGithub: + if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/') + needs: Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Set Version + run: git rev-list --count HEAD | xargs printf 'CI%05d' | xargs -I{} echo 'VERSION_SUFFIX={}' >> $GITHUB_ENV + + - name : Pack (Neo) + run: | + dotnet pack \ + --configuration Release \ + --output ./out \ + --version-suffix ${{ env.VERSION_SUFFIX }} + + - name: Remove Unwanted Files + working-directory: ./out + run: | + rm -v Neo.CLI* + rm -v Neo.GUI* + + - name: Publish to Github Packages + working-directory: ./out + run: | + dotnet nuget push * \ + --source https://nuget.pkg.github.com/neo-project/index.json \ + --api-key "${{ secrets.GITHUB_TOKEN }}" \ + --disable-buffering \ + --no-service-endpoint; + # MyGet isn't working # PublishMyGet: # if: github.ref == 'refs/heads/master' && startsWith(github.repository, 'neo-project/') diff --git a/.github/workflows/pkgs-delete.yml b/.github/workflows/pkgs-delete.yml new file mode 100644 index 0000000000..16855f1070 --- /dev/null +++ b/.github/workflows/pkgs-delete.yml @@ -0,0 +1,51 @@ +name: Nuget Package Cleanup (github) + +on: + schedule: + - cron: '0 0 * * *' # Run every day at 24:00 + +jobs: + delete-pkgs: + name: Delete Old Nuget Packages + runs-on: ubuntu-latest + + steps: + - name: Delete Neo Package + uses: actions/delete-package-versions@v4 + with: + package-name: Neo + package-type: nuget + min-versions-to-keep: 3 + token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Delete Neo.ConsoleService Package + uses: actions/delete-package-versions@v4 + with: + package-name: Neo.ConsoleService + package-type: nuget + min-versions-to-keep: 3 + token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Delete Neo.ConsoleService Package + uses: actions/delete-package-versions@v4 + with: + package-name: Neo.ConsoleService + package-type: nuget + min-versions-to-keep: 3 + token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Delete Neo.Json Package + uses: actions/delete-package-versions@v4 + with: + package-name: Neo.Json + package-type: nuget + min-versions-to-keep: 3 + token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Delete Neo.VM Package + uses: actions/delete-package-versions@v4 + with: + package-name: Neo.VM + package-type: nuget + min-versions-to-keep: 3 + token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/NuGet.Config b/NuGet.Config index 5922e754af..f7ce69db29 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -2,6 +2,7 @@ +