-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (84 loc) · 3.38 KB
/
create-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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