forked from open-telemetry/opentelemetry-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (88 loc) · 3.29 KB
/
publish-packages-1.0.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
#################################################
################### IMPORTANT ###################
# DON'T RENAME THIS FILE UNLESS WE START
# RELEASING THE VERSION 2.*
################### IMPORTANT ###################
#################################################
name: Build, pack, and publish to MyGet
on:
workflow_dispatch:
push:
tags:
- 'core-*'
- 'coreunstable-*'
- 'Instrumentation.*-'
schedule:
- cron: '0 0 * * *' # once in a day at 00:00
permissions:
contents: write
jobs:
build-pack-publish:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
# Note: By default GitHub only fetches 1 commit. MinVer needs to find
# the version tag which is typically NOT on the first commit so we
# retrieve them all.
fetch-depth: 0
ref: ${{ github.ref || 'main' }}
- name: Setup dotnet
uses: actions/setup-dotnet@v4
- name: dotnet restore
run: dotnet restore OpenTelemetry.proj -p:RunningDotNetPack=true
- name: dotnet build
run: dotnet build OpenTelemetry.proj --configuration Release --no-restore -p:Deterministic=true -p:BuildNumber=${{ github.run_number }} -p:RunningDotNetPack=true
- name: dotnet pack
run: dotnet pack OpenTelemetry.proj --configuration Release --no-restore --no-build -p:PackTag=${{ github.ref_type == 'tag' && github.ref_name || '' }}
- name: Publish Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ github.ref_name }}-packages
path: '**/bin/**/*.*nupkg'
- name: Publish MyGet
run: |
nuget setApiKey ${{ secrets.MYGET_TOKEN }} -Source https://www.myget.org/F/opentelemetry/api/v2/package
nuget push **/bin/**/*.nupkg -Source https://www.myget.org/F/opentelemetry/api/v2/package
- name: Create GitHub Release Draft
if: github.ref_type == 'tag'
shell: pwsh
run: |
$packages = (Get-ChildItem -Path src/*/bin/Release/*.nupkg).Name
$notes = ''
$firstPackageVersion = ''
foreach ($package in $packages)
{
$match = [regex]::Match($package, '(.*)\.(\d+\.\d+\.\d+.*?)\.nupkg')
$packageName = $match.Groups[1].Value
$packageVersion = $match.Groups[2].Value
if ($firstPackageVersion -eq '')
{
$firstPackageVersion = $packageVersion
}
$notes +=
@"
* NuGet: [$packageName v$packageVersion](https://www.nuget.org/packages/$packageName/$packageVersion)
See [CHANGELOG](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/src/$packageName/CHANGELOG.md) for details.
"@
}
if ($firstPackageVersion -match '-alpha' -or $firstPackageVersion -match '-beta' -or $firstPackageVersion -match '-rc')
{
gh release create ${{ github.ref_name }} `
--title ${{ github.ref_name }} `
--verify-tag `
--notes "$notes" `
--prerelease `
--draft
}
else
{
gh release create ${{ github.ref_name }} `
--title ${{ github.ref_name }} `
--verify-tag `
--notes "$notes" `
--latest `
--draft
}
env:
GH_TOKEN: ${{ github.token }}