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

Merge pr, preview, and release workflows into one and publish to GitHub packages #211

Merged
merged 1 commit into from
Feb 27, 2024
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
82 changes: 60 additions & 22 deletions .github/workflows/preview.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
name: Publish Preview
name: Build

on:
push:
# branches:
# - main
tags:
- '*'
paths-ignore:
- README.md
- '**/README.md'
- LICENSE
- CHANGELOG.md
- docs/**
pull_request:
branches:
- main
paths-ignore:
- README.md
- '**/README.md'
- LICENSE
- CHANGELOG.md
- docs/**
workflow_dispatch:
inputs:
reason:
description: 'Reason for running the action'
required: false
default: 'Pre-Release'
private:
description: 'Whether to publish to the private feed'
required: false
default: 'true'
public:
description: 'Whether to publish to the public NuGet feed'
required: false
default: 'false'
schedule:
- cron: '0 1 * * *' # daily at 1am UTC

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1

jobs:
Build:
runs-on: ubuntu-latest
name: Build

steps:
- name: Checkout
Expand Down Expand Up @@ -74,10 +84,12 @@ jobs:
path: ${{ github.workspace }}/drop/*
name: drop

PrivateFeed:
# TODO: remove support for Azure Artifacts once we have migrated all packages to GitHub Packages
AzureArtifacts:
runs-on: ubuntu-latest
needs: Build
if: ${{ github.event.inputs.private == 'true' }}
name: Publish (Azure Artifacts)
if: ${{ (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags') }}

steps:
- uses: actions/download-artifact@v4
Expand All @@ -89,21 +101,21 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
source-url: ${{ secrets.PRIVATE_FEED_URL }}
source-url: "https://pkgs.dev.azure.com/tingle/_packaging/tingle/nuget/v3/index.json"
env:
NUGET_AUTH_TOKEN: ${{ secrets.PRIVATE_FEED_API_KEY }}

- name: Publish to private feed
# if: startsWith(github.ref, 'refs/tags/')
- name: Publish to pkgs.dev.azure.com/tingle
run: >
dotnet nuget push "${{ github.workspace }}/drop/*"
-k ${{ secrets.PRIVATE_FEED_API_KEY }}
--skip-duplicate

PublicFeed:
GitHubPackages:
runs-on: ubuntu-latest
needs: Build
if: ${{ github.event.inputs.public == 'true' }}
name: Publish (GitHub Packages)
if: ${{ (github.ref == 'refs/heads/main') || startsWith(github.ref, 'refs/tags') }}

steps:
- uses: actions/download-artifact@v4
Expand All @@ -115,12 +127,38 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to nuget.pkg.github.com
run: >
dotnet nuget push "${{ github.workspace }}/drop/*"
-k ${{ secrets.GITHUB_TOKEN }}
--skip-duplicate

NugetOrg:
runs-on: ubuntu-latest
needs: [AzureArtifacts, GitHubPackages]
name: Publish (Nuget.org)
if: ${{ startsWith(github.ref, 'refs/tags') }}

steps:
- uses: actions/download-artifact@v4
with:
name: drop
path: ${{ github.workspace }}/drop

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_API_KEY }}

- name: Publish to NuGet.org
# if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/')
run: >
dotnet nuget push "${{ github.workspace }}/drop/*"
-k ${{ secrets.NUGET_API_KEY }}
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Cleanup

on:
workflow_dispatch:
schedule:
- cron: '0 0 */14 * *' # every 14 days

jobs:
cleanup-updater:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
suite:
- { name: 'Tingle.AspNetCore.Authentication' }
- { name: 'Tingle.AspNetCore.Authorization' }
- { name: 'Tingle.AspNetCore.DataProtection.MongoDB' }
- { name: 'Tingle.AspNetCore.JsonPatch.NewtonsoftJson' }
- { name: 'Tingle.AspNetCore.Tokens' }
- { name: 'Tingle.Extensions.Caching.MongoDB' }
- { name: 'Tingle.Extensions.DataAnnotations' }
- { name: 'Tingle.Extensions.Http' }
- { name: 'Tingle.Extensions.Http.Authentication' }
- { name: 'Tingle.Extensions.JsonPatch' }
- { name: 'Tingle.Extensions.PhoneValidators' }
- { name: 'Tingle.Extensions.Processing' }
- { name: 'Tingle.Extensions.PushNotifications' }
- { name: 'Tingle.Extensions.Serilog' }

steps:
- name: Delete old ${{ matrix.suite.name }} packages
uses: actions/delete-package-versions@v5
with:
package-name: ${{ matrix.suite.name }}
package-type: 'nuget'
min-versions-to-keep: 10
delete-only-pre-release-versions: true
42 changes: 0 additions & 42 deletions .github/workflows/pr.yml

This file was deleted.

81 changes: 0 additions & 81 deletions .github/workflows/release.yml

This file was deleted.