Merge pull request #30 from lekman/feature/version-update #10
This file contains 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: "CD: Release and Publish" | |
on: | |
workflow_dispatch: | |
push: | |
# Run on main branch changes and let release-please create | |
# PRs for version bumps and new releases | |
branches: | |
- main | |
paths: | |
- "**/*.cs" | |
- "**/*.cs*" | |
- ".release-please-manifest.json" | |
- "release-please-config.json" | |
- ".github/workflows/cd_release_please.yml" | |
pull_request: | |
# Only run during a PR if the release-please manifest has changed, | |
# meaning that versions are attempting to be updated. | |
types: [opened, synchronize, reopened] | |
paths: | |
- ".release-please-manifest.json" | |
jobs: | |
release-please: | |
name: Release Please | |
# Only run on main, after merge is completed | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "16" | |
- name: Run release-please | |
uses: googleapis/release-please-action@v4 | |
id: release | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
bump-versions: | |
name: Set Version | |
# Only run on pull requests or on feature branches | |
if: github.ref != 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Bump version | |
uses: lekman/release-please-dotnet@v1 | |
with: | |
manifest: ".release-please-manifest.json" | |
branch: ${{ github.head_ref }} | |
publish: | |
name: Publish | |
# Only run on main, after merge is completed | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: "9.0.x" | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build | |
- name: Publish | |
run: dotnet publish -c Release -o ${{ github.workspace }}/publish | |
- name: Publish to Nuget | |
run: dotnet nuget push **/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate |