🚀 #103: Add github-actions script to create release automatically #140
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: .NET | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
working-directory: ./src/sika/ | |
- name: Build | |
run: dotnet build --no-restore | |
working-directory: ./src/sika/ | |
- name: Publish to NuGet | |
uses: brandedoutcast/publish-nuget@v2.5.2 | |
with: | |
PROJECT_FILE_PATH: "src/sika/sika.csproj" | |
VERSION_REGEX: '<AssemblyVersion>(.*)<\/AssemblyVersion>' | |
NUGET_KEY: ${{secrets.NUGET_KEY}} | |
if: github.event_name != 'pull_request' | |
- name: Retrieve version | |
id: proj_version | |
uses: KageKirin/get-csproj-version@v0 | |
with: | |
file: src/sika/sika.csproj | |
xpath: '//PropertyGroup/AssemblyVersion' | |
- name: Create release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
VERSION: ${{ steps.proj_version.version }} | |
run: | | |
gh release create "v$VERSION" \ | |
--repo="$GITHUB_REPOSITORY" \ | |
--generate-notes |