-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
132 lines (107 loc) · 4.2 KB
/
action.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Common Actions
description: Commonly used actions output for the Oxide project
inputs:
myget_source:
description: "MyGet source to publish to, defaults to https://www.myget.org/f/oxide/api/v2/package"
required: false
default: https://www.myget.org/f/oxide/api/v2/package
myget_api_key:
description: "API key for MyGet package deployment"
required: false
nuget_source:
description: "NuGet source to publish to, defaults to https://{{ github.repository_owner }}/index.json"
required: false
default: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
nuget_api_key:
description: "API key for NuGet package deployment"
required: false
configuration:
description: "Build configuration to use, defaults to Release"
required: false
default: Release
project_path:
description: "Path to the project file"
required: false
solution_path:
description: "Path to the solution file"
required: false
outputs:
project_version:
description: "Get project version"
value: ${{ steps.project_version.outputs.version }}
build_version:
description: "Get build version"
value: ${{ steps.build_version.outputs.version }}
package_version:
description: "Get package version"
value: ${{ steps.package_version.outputs.version }}
meta_version:
description: "Get meta version"
value: ${{ steps.meta_version.outputs.version }}
repo_name:
description: "Get repository name"
value: ${{ steps.repo_name.outputs.name }}
git_short_sha:
description: "Get git commit short SHA"
value: ${{ steps.git_short_sha.outputs.sha }}
runs:
using: "composite"
steps:
- id: project_version
run: |
$xml = [Xml](Get-Content (Get-ChildItem Common.props, *.csproj -Recurse | Select-Object -First 1))
$version = [Version]$xml.Project.PropertyGroup.Version
$version = $version.Substring(0, $version.lastIndexOf('.'))
echo "Project version: $version"
echo "::set-output name=version::$version"
shell: pwsh
- id: build_version
run: |
$version = '${{ steps.project_version.outputs.version }}.${{ github.run_number }} # ex. 1.0.1234
echo "Build version: $version"
echo "::set-output name=version::$version"
shell: pwsh
- id: package_version
run: |
$version = "${{ steps.build_version.outputs.version }}-${{ github.ref_name }}" # ex. 1.0.1234-develop
echo "Package version: $version"
echo "::set-output name=version::$version"
shell: pwsh
- id: meta_version
run: |
$version = "${{ steps.package_version.outputs.version }}+git.${{ steps.git_short_sha.outputs.sha }}" # ex. 1.0.1234-develop+git.91ab23c4
echo "Meta version: $version"
echo "::set-output name=version::$version"
shell: pwsh
- id: git_short_sha
run: |
$sha = "${{ github.sha }}".Substring(0,8)
echo "Git commit short SHA: $sha"
echo "::set-output name=sha::$sha"
shell: pwsh
- id: repo_name
run: |
$name = $(Split-Path ${{ github.repository }} -Leaf)
echo "Repository name is $name
echo "::set-output name=name::$name"
shell: pwsh
- name: Restore dependencies
run: dotnet restore ${{ inputs.solution_path }}
shell: bash
- name: Build solution
run: dotnet build ${{ inputs.solution_path }} --no-restore --configuration ${{ inputs.configuration }}
shell: bash
- name: Run tests
run: dotnet test ${{ inputs.project_path }} --no-build --configuration ${{ inputs.configuration }}
shell: bash
- name: Package for NuGet
run: dotnet pack ${{ inputs.solution_path }} --no-build --configuration ${{ inputs.configuration }} /p:Version=${{ steps.package_version.outputs.version }} -o packages
shell: bash
- name: Push MyGet package
run: |
dotnet nuget push packages/*.nupkg --source ${{ inputs.myget_source }} --skip-duplicate --api-key ${{ inputs.myget_api_key }}
shell: bash
- name: Push NuGet package
run: |
dotnet nuget push packages/*.nupkg --source ${{ inputs.nuget_source }} --skip-duplicate --api-key ${{ inputs.nuget_api_key }}
shell: bash