diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d97df39 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,18 @@ +name: Release + +on: + push: + tags: [v*] + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Run release script + shell: pwsh + run: ./eng/release.ps1 + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} diff --git a/README.md b/README.md index f86aeca..9979adc 100644 --- a/README.md +++ b/README.md @@ -92,11 +92,6 @@ This library is also used in production by [KnowledgePicker](https://knowledgepi As mentioned [above](#how-to-use), only subset of functionality is implemented now, but all contributions are welcome. Feel free to open [issues](https://github.com/knowledgepicker/word-cloud/issues) and [pull requests](https://github.com/knowledgepicker/word-cloud/pulls). -### Creating NuGet package +### Release process -Until we have a CI pipeline, this is how we release new version of the package (don't forget to replace 1.0.0 with the correct version): - -```bash -cd src/KnowledgePicker.WordCloud -dotnet pack -c Release --include-symbols --include-source -p:PackageVersion=1.0.0 -``` +After pushing a tag, GitHub workflow `release.yml` is triggered which builds and publishes the NuGet package. diff --git a/eng/release.ps1 b/eng/release.ps1 new file mode 100644 index 0000000..df53182 --- /dev/null +++ b/eng/release.ps1 @@ -0,0 +1,27 @@ +Set-StrictMode -version 2.0 +$ErrorActionPreference = "Stop" + +Write-Output "Working directory: $pwd" + +# Load current Git tag. +$tag = $(git describe --tags) +Write-Output "Tag: $tag" + +# Parse tag into a three-number version. +$version = $tag.Split('-')[0].TrimStart('v') +Write-Output "Version: $version" + +Push-Location src/KnowledgePicker.WordCloud +try { + # Pack the library. + dotnet pack -c Release --include-symbols --include-source ` + -p:PackageVersion=$version + + # Push the NuGet package. + dotnet nuget push ` + "bin/Release/KnowledgePicker.WordCloud.$version.symbols.nupkg" ` + --source https://api.nuget.org/v3/index.json ` + --api-key $env:NUGET_API_KEY +} finally { + Pop-Location +}