Update check-for-changes.yml #58
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: Create release | |
on: | |
pull_request: | |
types: [closed] | |
branches: | |
- develop | |
env: | |
PROJECT_PATH: 'Pipeline.csproj' | |
PACKAGE_OUTPUT_DIRECTORY: ${{ github.workspace }}/output | |
TAG_NAME: ${{ github.event.release.tag_name }} | |
NUGET_SOURCE_URL: 'https://api.nuget.org/v3/index.json' | |
jobs: | |
build: | |
environment: | |
name: 'NuGet' | |
url: https://www.nuget.org/packages/PipelineBasic | |
if: github.event.action == 'closed' && github.event.pull_request.merged == true | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: π Checkout repo | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: π§ Setup .NET Core | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 5.0.x | |
- name: βοΈ Get previous tag. | |
id: version | |
run: | | |
lastTag=`git tag -l --sort=-creatordate --format='%(refname:short)' | head -n 1` | |
echo "::set-output name=tag::$lastTag" | |
- name: βοΈ Bump if alpha. | |
id: bump-with-alpha | |
uses: actions/github-script@v3 | |
with: | |
result-encoding: string | |
script: | | |
const incoming = "${{steps.version.outputs.tag}}" | |
console.log("Incoming Tag: " + incoming) | |
if(incoming.includes('alpha')) { | |
const oldNum = incoming.match(/alpha[.]*(\d+)/)[1] | |
const newNum = parseInt(oldNum)+1 | |
const newTag = incoming.replace(/alpha.*\d+/, `alpha.${newNum}`) | |
console.log("New Tag: " + newTag) | |
return newTag | |
} | |
else { | |
const newTag =incoming +'-alpha.0' | |
console.log("New Tag: " + newTag) | |
return newTag | |
} | |
- name: π§ Restore nuget with dotnet | |
run: dotnet restore ${{ env.PROJECT_PATH }} | |
- name: 𧱠Build project | |
run: dotnet build ${{ env.PROJECT_PATH }} --no-restore --configuration Release -p:Version=${{ steps.bump-with-alpha.outputs.result }} | |
- name: π¦ Create the package | |
run: dotnet pack ${{ env.PROJECT_PATH }} --no-restore --no-build --configuration Release -p:PackageVersion=${{ steps.bump-with-alpha.outputs.result }} --output ${{ env.PACKAGE_OUTPUT_DIRECTORY }} | |
- name: π Publish the package | |
run: dotnet nuget push ${{ env.PACKAGE_OUTPUT_DIRECTORY }}/*.nupkg --skip-duplicate -k ${{ secrets.NUGET_API_KEY }} -s ${{ env.NUGET_SOURCE_URL }} | |
- name: π Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.bump-with-alpha.outputs.result }} | |
release_name: ${{ steps.bump-with-alpha.outputs.result }} | |
body: | | |
## Title | |
${{ github.event.pull_request.title }} | |
## Body | |
${{ github.event.pull_request.body }} | |
draft: false | |
prerelease: false | |
- name: 7Zip artifact | |
run: 7z a -t7z -mx=9 artifact.7z ./bin/Debug/net5.0 | |
- name: Upload server binaries to release | |
uses: svenstaro/upload-release-action@v1-release | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ steps.bump-with-alpha.outputs.result }} | |
file: artifact.7z | |
asset_name: artifact |