Skip to content

Commit

Permalink
Merge pull request #40 from vlnevyhosteny/master
Browse files Browse the repository at this point in the history
chore: release-please action
  • Loading branch information
ViolanteCodes authored Oct 13, 2023
2 parents b8c3f2c + 3e50f03 commit 260ab0d
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 12 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/nuget-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: NuGet Publish

on:
push:
branches: [ master ]

env:
NUGET_DIR: ${{ github.workspace }}/nuget
NUGET_ARTIFACT: nuget

jobs:
testing:
if: contains(github.event.head_commit.message, 'chore(release)')
uses: ./.github/workflows/test.yml

pack:
if: contains(github.event.head_commit.message, 'chore(release)')
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]

- name: Setup .NET Core
uses: actions/[email protected]

- run: sed -E -i'.bak' 's:RepositoryCommit>.+</:RepositoryCommit>${{ github.sha }}</:g' ButterCMS/ButterCMS.csproj

- run: dotnet pack --configuration Release --output "${{ env.NUGET_DIR }}"

- uses: actions/[email protected]
with:
name: ${{ env.NUGET_ARTIFACT }}
path: ${{ env.NUGET_DIR }}
if-no-files-found: error
retention-days: 1

validate-nuget:
runs-on: ubuntu-22.04
needs: pack
steps:
- name: Setup .NET Core
uses: actions/[email protected]

- uses: actions/[email protected]
with:
name: ${{ env.NUGET_ARTIFACT }}
path: ${{ env.NUGET_DIR }}

- name: Install nuget validator
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global

- name: Validate nuget package
run: meziantou.validate-nuget-package --excluded-rules Symbols ${{ env.NUGET_DIR }}/*.nupkg

publish:
runs-on: ubuntu-22.04
needs: [validate-nuget, testing]
steps:
- uses: actions/[email protected]
with:
name: ${{ env.NUGET_ARTIFACT }}
path: ${{ env.NUGET_DIR }}

- name: Setup .NET Core
uses: actions/[email protected]

- name: Publish nuget package
run: dotnet nuget push "${{ env.NUGET_DIR }}/*.nupkg" --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json



10 changes: 10 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Pull Request

on:
pull_request:
types: [opened]

jobs:
testing:
uses: ./.github/workflows/test.yml

36 changes: 36 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow opens and updates a pull request with a new package version
# based on code changes.

# The pull request updates the version in ButterCMS/ButterCMS.csproj,
# updates the version in README.md, updates the changelog and creates release tags.

# For more information, see https://github.com/marketplace/actions/release-please-action

on:
push:
branches:
- master

permissions:
contents: write
pull-requests: write

name: release-please

jobs:
testing:
uses: ./.github/workflows/test.yml

release-please:
runs-on: ubuntu-22.04
needs: testing
steps:
- uses: google-github-actions/[email protected]
with:
release-type: simple
package-name: release-please-action
pull-request-title-pattern: 'chore(release): ${version}'
pull-request-header: ':robot: Merge this PR to release a new version'
extra-files: |
README.md
ButterCMS/ButterCMS.csproj
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: Testing

on: [push]
on:
workflow_call:

jobs:
build:

runs-on: ubuntu-latest
unit-tests:
runs-on: ubuntu-22.04
strategy:
matrix:
dotnet-version: [ '7.0.x' ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3.5.3
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install dependencies
Expand Down
18 changes: 13 additions & 5 deletions ButterCMS/ButterCMS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.1</TargetFrameworks>
<OldToolsVersion>2.0</OldToolsVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
<Version>2.0.0</Version>
<FileVersion>2.0.0</FileVersion>
<Version>2.0.0</Version> <!-- {x-release-please-version} -->
<FileVersion>2.0.0</FileVersion> <!-- {x-release-please-version} -->
<Authors>Brandon Nicoll; ButterCMS</Authors>
<Description>API Client for ButterCMS; including both synchronous and asynchronous API endpoint methods.</Description>
<Copyright>Copyright (c) 2020 ButterCMS</Copyright>
Expand All @@ -16,15 +17,22 @@
</PropertyGroup>
<PropertyGroup>
<PackageId>ButterCMS</PackageId>
<PackageVersion>2.0.0</PackageVersion>
<PackageVersion>2.0.0</PackageVersion> <!-- {x-release-please-version} -->
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>ButterCMS CMS</PackageTags>
<PackageLicenseUrl>https://github.com/buttercms/buttercms-csharp/blob/master/LICENSE</PackageLicenseUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/buttercms/buttercms-csharp/</PackageProjectUrl>
<PackageIconUrl>https://avatars0.githubusercontent.com/u/16144259</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageReleaseNotes>Name is now included in pages</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/ButterCMS/buttercms-csharp</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryCommit>commit</RepositoryCommit> <!-- Value is inserted in CI right before publish -->
</PropertyGroup>
<ItemGroup>
<None Include="../misc/icon.png" Pack="true" PackagePath="\" />
<None Include="../LICENSE" Pack="true" PackagePath="\" />
<None Include="../README.md" Pack="true" PackagePath="\" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Contributing

## Release and publish a new SDK version

This SDK uses the [`release-please` GitHub Action](https://github.com/google-github-actions/release-please-action) to automate preparing new versions for release.

When you are ready to release a new SDK version, make sure that all your code changes have been approved and merged into the `master` branch and that your code is working. The `release-please` tool generates a changelog based on **commit messages; these messages should follow the [Conventional Commits](https://conventionalcommits.org) specification in order for the changelog to reflect all code changes accurately**. Otherwise, you would need to update the changelog manually before each release. Note that "chore" will not trigger a release PR. "fix" will create a SemVer Patch, "feat" will create a minor version, and adding a "!" will create a major version, indicating a breaking change. Find more information in the [release-please docs](https://github.com/google-github-actions/release-please-action#how-release-please-works).

The `release-please` action opens and maintains a GitHub pull request with changes relevant to a new version release. Approve this pull request to release a new version of the SDK.

After the release, the new version is automatically published into the npm registry (see the package [here](https://www.npmjs.com/package/buttercms)).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Or by adding the package manually to the project file

```xml
<ItemGroup>
<PackageReference Include="ButterCMS" Version="2.0.0" />
<PackageReference Include="ButterCMS" Version="2.0.0" /> <!-- {x-release-please-version} -->
</ItemGroup>
```

Expand Down
Binary file added misc/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 260ab0d

Please sign in to comment.