Pack and publish #159
Workflow file for this run
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: Pack and publish | |
on: | |
release: | |
types: | |
- published | |
jobs: | |
release-nugets: | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
environment: |- | |
${{ | |
contains(github.event.release.tag_name, 'preview') && 'test' | |
|| contains(github.event.release.tag_name, 'rc') && 'staging' | |
|| 'prod' | |
}} | |
steps: | |
- name: Validate tag | |
run: | | |
echo "Validating that the tag is in the correct format" | |
echo "${{ github.event.release.tag_name }}" | grep -P '^v(\d+)\.(\d+)\.(\d+)(-(preview|rc)\d+$|$)' | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install dotnet8 | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
8.0.x | |
- name: Install deps | |
run: | | |
dotnet restore | |
- name: Extract release notes | |
id: extract-notes | |
run: echo "${{ github.event.release.body }}" > RELEASE_NOTES.md | |
- name: Build | |
run: | | |
dotnet build --configuration Release --no-restore -p:Deterministic=true -p:BuildNumber=${{ github.run_number }} | |
- name: Pack | |
run: | | |
dotnet pack AppLibDotnet.sln --configuration Release --no-restore --no-build \ | |
-p:Deterministic=true -p:BuildNumber=${{ github.run_number }} \ | |
-p:PackageReleaseNotes="$(cat RELEASE_NOTES.md)" | |
- name: Versions | |
run: | | |
dotnet --version | |
- name: Publish | |
run: | | |
dotnet nuget push src/**/bin/Release/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} |