Updated Actions to deploy packages to GitHub Pkgs and NuGet.org #51
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: Build and Deploy | |
on: | |
push: | |
branches: | |
- release/* | |
- develop | |
- main | |
permissions: | |
contents: write | |
jobs: | |
Build: | |
runs-on: windows-latest | |
outputs: | |
gitversion_semver: ${{ steps.gitversion.outputs.semver }} | |
gitversion_nugetversion: ${{ steps.gitversion.outputs.nugetversion }} | |
steps: | |
- name: Checkout codegit v | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Setup GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x' | |
- name: Execute GitVersion | |
id: gitversion | |
uses: gittools/actions/gitversion/[email protected] | |
- name: Setup NuGet | |
uses: NuGet/[email protected] | |
- name: NuGet restore | |
run: nuget restore | |
- name: Build DotNet | |
run: dotnet build -c Release | |
- name: Pack Projects | |
run: dotnet pack --output artifacts --configuration Release /p:PackageVersion=${{ steps.gitversion.outputs.nugetversion }} | |
- name: Publish Build Artifacts | |
uses: actions/[email protected] | |
with: | |
name: nuget | |
path: ./artifacts/*.nupkg | |
retention-days: 1 | |
overwrite: true | |
Deploy_GitHub_Packages: | |
needs: Build | |
runs-on: windows-latest | |
steps: | |
- name: Download a Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: nuget | |
path: ./artifacts | |
- name: Push NuGet Packages | |
shell: bash | |
run: | | |
shopt -s globstar | |
for PACKAGE_FILE in ./artifacts/*.nupkg; do | |
echo "Pushing $PACKAGE_FILE" | |
dotnet nuget push "$PACKAGE_FILE" --api-key ${{ secrets.GHUB_PAT }} --source ${{ secrets.GROWLER_PACKAGES_JSON }} | |
done | |
Deploy_NuGet-org: | |
needs: Build | |
runs-on: windows-latest | |
steps: | |
- name: Download a Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: nuget | |
path: ./artifacts | |
- name: Push NuGet Packages | |
shell: bash | |
run: | | |
shopt -s globstar | |
for PACKAGE_FILE in ./artifacts/*.nupkg; do | |
echo "Pushing $PACKAGE_FILE" | |
dotnet nuget push "$PACKAGE_FILE" --api-key ${{ secrets.GROWLER_NUGETORG_API_KEY }} --source "https://api.nuget.org/v3/index.json" | |
done | |
# Prepare_Release: | |
# needs: Build | |
# runs-on: windows-latest | |
# outputs: | |
# commit_messages: ${{ steps.commit_messages.outputs.messages }} | |
# gitversion_semver: ${{ needs.Build.outputs.gitversion_semver }} | |
# steps: | |
# - name: Checkout code | |
# uses: actions/[email protected] | |
# with: | |
# fetch-depth: 0 | |
# - name: Get commit messages since last release | |
# id: commit_messages | |
# run: | | |
# git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h - %s" > commit_messages.txt | |
# echo "commit_messages<<EOF" >> $GITHUB_OUTPUT | |
# cat commit_messages.txt >> $GITHUB_OUTPUT | |
# echo "EOF" >> $GITHUB_OUTPUT | |
Create_Release: | |
needs: Build | |
runs-on: windows-latest | |
steps: | |
- name: Display Version number | |
run: echo "version ${{ needs.Build.outputs.gitversion_semver }}" | |
# - name: Create Tag | |
# uses: negz/create-tag@v1 | |
# with: | |
# token: ${{ secrets.GHUB_PAT }} | |
# version: ${{ needs.Build.outputs.gitversion_semver }} | |
# message: ${{ needs.Build.outputs.gitversion_semver }} | |
- name: Create GitHub Release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ needs.Build.outputs.gitversion_semver }} | |
generateReleaseNotes: true | |
# artifacts: "release.tar.gz,foo/*.txt" | |
# body: | | |
# Description of the release | |
# Commit Messages: | |
# ${{ needs.Prepare_Release.outputs.commit_messages }} | |
# Tag_Repo: | |
# needs: Build | |
# runs-on: windows-latest | |
# outputs: | |
# gitversion_semver: ${{ needs.Build.outputs.gitversion_semver }} | |
# steps: | |
# - name: Display Version number | |
# run: echo "version ${{ needs.Deploy_GitHub_Packages.outputs.gitversion_semver }}" | |
# - name: Create Tag | |
# # You may pin to the exact commit or the version. | |
# # uses: negz/create-tag@39bae1e0932567a58c20dea5a1a0d18358503320 | |
# uses: negz/create-tag@v1 | |
# with: | |
# # Github Token | |
# token: ${{ secrets.GHUB_PAT }} | |
# # Version (e.g. v0.1.0) | |
# version: ${{ needs.Build.outputs.gitversion_semver }} | |
# # Tag message | |
# message: ${{ needs.Build.outputs.gitversion_semver }} |