-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (87 loc) · 3.71 KB
/
Copy pathpr.yml
File metadata and controls
98 lines (87 loc) · 3.71 KB
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
name: pull request
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: pr-${{ github.event.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
version:
name: resolve beta version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.resolve.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: resolve
run: |
# Base version lives in Directory.Build.props, as <dd-sdk-ios version>.<binding
# revision>; the PR number and run number make each published prerelease unique, since
# nuget.org never allows a version to be reused.
native=$(sed -n 's:.*<DatadogNativeVersion>\(.*\)</DatadogNativeVersion>.*:\1:p' Directory.Build.props | head -1)
revision=$(sed -n 's:.*<DatadogBindingRevision>\(.*\)</DatadogBindingRevision>.*:\1:p' Directory.Build.props | head -1)
if [ -z "${native}" ] || [ -z "${revision}" ]; then
echo "::error::could not read DatadogNativeVersion/DatadogBindingRevision from Directory.Build.props"
exit 1
fi
version="${native}.${revision}-beta.${{ github.event.number }}.${{ github.run_number }}"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "Building ${version}" >> "$GITHUB_STEP_SUMMARY"
build:
name: build
needs: version
uses: ./.github/workflows/build.yml
with:
version: ${{ needs.version.outputs.version }}
publish:
name: publish beta to nuget.org
needs: [version, build]
runs-on: ubuntu-latest
# Forked pull requests get no OIDC token for this repository, so the exchange would fail with a
# confusing error. Those PRs still build and test; only the publish step is skipped.
if: github.event.pull_request.head.repo.full_name == github.repository
# Must match the Environment on the nuget.org trusted publishing policy for this workflow.
environment: nuget.org
permissions:
contents: read
# Lets the job request the OIDC token that nuget.org exchanges for a short-lived API key.
# Without it the token request fails silently and the login step gets no key.
id-token: write
steps:
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Download packages
uses: actions/download-artifact@v4
with:
name: nuget-packages
path: artifacts
# Deliberately immediately before the push: the issued key is valid for one hour, and each
# OIDC token can be exchanged exactly once.
- name: Authenticate to nuget.org
id: nuget-login
uses: NuGet/login@v1
with:
user: ${{ secrets.NUGET_USER }}
- name: Push to nuget.org
run: |
# Symbol packages are pushed automatically alongside each matching .nupkg. The eleven
# packages depend on each other at an exact version, so they are pushed together - a
# partial push leaves ids that cannot restore.
dotnet nuget push "artifacts/*.nupkg" \
--source https://api.nuget.org/v3/index.json \
--api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" \
--skip-duplicate
- name: Summarise
run: |
{
echo "### Published \`${{ needs.version.outputs.version }}\` to nuget.org"
echo
for package in Core RUM Logs Trace SessionReplay WebViewTracking CrashReporting Flags Profiling Internal OpenTelemetryApi Objc; do
id="DatadogNet.${package}.iOS"
echo "- [${id}](https://www.nuget.org/packages/${id}/${{ needs.version.outputs.version }})"
done
} >> "$GITHUB_STEP_SUMMARY"