Skip to content

Merge pull request #32 from lekman/release-please--branches--main--co… #14

Merge pull request #32 from lekman/release-please--branches--main--co…

Merge pull request #32 from lekman/release-please--branches--main--co… #14

name: "Release Please"
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"
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]
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
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if manifest has changed
id: check_changes
run: |
if git diff --name-only HEAD^ HEAD | grep -q '.release-please-manifest.json'; then
echo "File changed"
echo "file_changed=true" >> $GITHUB_OUTPUT
else
echo "File not changed"
echo "file_changed=false" >> $GITHUB_OUTPUT
fi
- name: Bump versions
uses: lekman/release-please-dotnet@v1
if: steps.check_changes.outputs.file_changed == 'true'
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
- 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