build: add releaserc.json #2
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 Release | |
on: | |
push: | |
branches: | |
- '**' | |
jobs: | |
GetVersionNumber: | |
runs-on: ubuntu-latest | |
outputs: | |
newVersion: ${{ steps.get_version.outputs.newVersion }} | |
tag: ${{ steps.get_version.outputs.tag }} | |
version: ${{ steps.get_version.outputs.version }} | |
channel: ${{ steps.get_version.outputs.channel }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Get branch name | |
id: get_branch | |
run: | | |
branch=${GITHUB_REF#refs/heads/} | |
echo "branch=$branch" >> $GITHUB_OUTPUT | |
echo "prerelease=${branch//\//-}" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_REF: ${{ github.ref }} | |
- name: Replace branch name in .releaserc.json | |
if: steps.get_branch.outputs.branch != 'main' | |
uses: jacobtomlinson/gha-find-replace@master | |
with: | |
find: 'replace-me-feature-branch' | |
replace: '${{ steps.get_branch.outputs.branch }}' | |
include: '.releaserc.json' | |
- name: Replace prerelease name in .releaserc.json | |
if: steps.get_branch.outputs.branch != 'main' | |
uses: jacobtomlinson/gha-find-replace@master | |
with: | |
find: 'replace-me-prerelease' | |
replace: '${{ steps.get_branch.outputs.prerelease }}' | |
include: '.releaserc.json' | |
- name: Get version number | |
id: get_version | |
run: npx --package=semantic-release --package=@semantic-release/commit-analyzer --package=@semantic-release/release-notes-generator --package=@semantic-release/changelog --package=@semantic-release/exec -- semantic-release | |
- name: Print summary if no new version | |
if: steps.get_version.outputs.newVersion != 'true' | |
run: | | |
echo "# Summary" >> $GITHUB_STEP_SUMMARY | |
echo "No new version generated" >> $GITHUB_STEP_SUMMARY | |
- name: Upload release notes | |
if: steps.get_version.outputs.newVersion == 'true' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: change-log | |
path: CHANGELOG.md | |
- name: Print results | |
if: steps.get_version.outputs.newVersion == 'true' | |
run: | | |
echo "# Summary" >> $GITHUB_STEP_SUMMARY | |
echo "Version: ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
echo "Tag: ${{ steps.get_version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY | |
echo "New Version: ${{ steps.get_version.outputs.newVersion }}" >> $GITHUB_STEP_SUMMARY | |
echo "Channel: ${{ steps.get_version.outputs.channel }}" >> $GITHUB_STEP_SUMMARY | |
echo "Type: ${{ steps.get_version.outputs.type }}" >> $GITHUB_STEP_SUMMARY | |
BuildProject: | |
needs: GetVersionNumber | |
if: needs.GetVersionNumber.outputs.newVersion == 'true' | |
runs-on: windows-2019 | |
steps: | |
# First we checkout the source repo | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Get SLN Info | |
id: get_sln_info | |
shell: powershell | |
run: | | |
$solution_file = Get-ChildItem .\*.sln -recurse -Path "$($Env:GITHUB_WORKSPACE)" | |
Write-Output $solution_file | |
echo "SOLUTION_FILE=$($solution_file.BaseName)"| Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
$solution_path = Get-ChildItem *.sln -recurse | |
$solution_path = $solution_path.FullName | |
$solution_path = $solution_path -replace "(?:[^\\]*\\){4}", "" | |
Write-Output $solution_path | |
echo "SOLUTION_PATH=$($solution_path)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append | |
- name: Setup MS Build | |
uses: microsoft/setup-msbuild@v1.1 | |
- name: restore Nuget Packages | |
run: nuget restore .\src\${{ steps.get_sln_info.outputs.SOLUTION_FILE }}.sln | |
- name: Build Solution | |
run: msbuild .\src\${{ steps.get_sln_info.outputs.SOLUTION_FILE }}.sln /p:Platform="Any CPU" /p:Configuration="Debug" /p:Version="${{ needs.GetVersionNumber.outputs.version }}" -m | |
- name: Get release notes | |
uses: actions/download-artifact@v3 | |
with: | |
name: change-log | |
- name: Upload Release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: true | |
artifacts: 'output\*.*(cpz|cplz)' | |
prerelease: ${{ needs.GetVersionNumber.outputs.channel != '' }} | |
tag: ${{ needs.GetVersionNumber.outputs.tag }} | |
commit: ${{ github.sha }} | |
bodyFile: ./CHANGELOG.md | |
- name: Setup Nuget | |
run: | | |
nuget sources add -name github -source https://nuget.pkg.github.com/pepperdash/index.json -username pepperdash -password ${{ secrets.GITHUB_TOKEN }} | |
nuget setApiKey ${{ secrets.GITHUB_TOKEN }} -Source github | |
nuget setApiKey ${{ secrets.NUGET_API_KEY }} -Source https://api.nuget.org/v3/index.json | |
- name: Publish to Nuget | |
run: nuget push .\output\*.nupkg -Source https://api.nuget.org/v3/index.json | |
- name: Publish to Github Nuget | |
run: nuget push .\output\*.nupkg -Source github |