Skip to content

Update read PR

Update read PR #69

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