-
Notifications
You must be signed in to change notification settings - Fork 11
146 lines (124 loc) · 5.74 KB
/
create_version_bump_PR.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Create version bump PR
on:
workflow_dispatch:
inputs:
version:
description: 'Next Version Number (x.y.zzz).'
required: true
tracer_version:
description: 'Next Version Number (x.y.z). To be used for a tracer version bump.'
required: false
update_agent:
description: 'Update the agent as well'
type: boolean
required: false
default: false
repository_dispatch:
types: [dd-trace-dotnet-release]
jobs:
bump_version:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
steps:
- name: "Set Variables"
id: "set_variables"
run: |
if [[ ! -z "${{ github.event.inputs.version }}" ]]; then
echo "::set-output name=version::${{ github.event.inputs.version }}"
echo "::set-output name=tracer_version::${{ github.event.inputs.tracer_version }}"
elif [[ ! -z "${{ github.event.client_payload.version }}" ]]; then
TRACERVERSION=${{ github.event.client_payload.version }}
echo "Version received from dd-trace-dotnet: $TRACERVERSION"
TRACERVERSION=${TRACERVERSION:1}
echo "Version received once normalized: $TRACERVERSION"
echo "::set-output name=version::${TRACERVERSION}00"
echo "::set-output name=tracer_version::$TRACERVERSION"
else
echo "Error. Versions weren't provided in input."
exit 1
fi
- name: Checkout
uses: actions/checkout@v2
- name: "Get last agent release"
id: last_release
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: DataDog
repo: datadog-agent
excludes: prerelease, draft
- name: "Modify build-packages"
id: "versions"
run: |
versionRegex="[0-9]*.[0-9]*.[0-9]*"
splitVersionRegex="([0-9]+).([0-9]+).([0-9]+)"
CURRENTVERSION="$(grep -o -e RELEASE_VERSION\=\"$versionRegex dotnet/build-packages.sh | sed 's/RELEASE_VERSION="//')"
echo Current version is: $CURRENTVERSION
VERSION=${{ steps.set_variables.outputs.version }}
echo Bumping extension version to $VERSION
sed -i -e "s/RELEASE_VERSION=\"$CURRENTVERSION\"/RELEASE_VERSION=\"$VERSION\"/g" dotnet/build-packages.sh
echo Replaced release version in file.
PR_BODY="Bumps the release version to $VERSION"
TRACER_VERSION=${{steps.set_variables.outputs.tracer_version}}
if [ -n "$TRACER_VERSION" ]; then
CURRENT_TRACER_VERSION="$(grep -o -e dd-trace-dotnet/releases/download/v$versionRegex dotnet/build-packages.sh | sed 's#dd-trace-dotnet/releases/download/v##')"
echo Current tracer version is: $CURRENT_TRACER_VERSION
echo Bumping tracer version to $TRACER_VERSION
sed -i -e "s#dd-trace-dotnet/releases/download/v$CURRENT_TRACER_VERSION#dd-trace-dotnet/releases/download/v$TRACER_VERSION#" dotnet/build-packages.sh
echo Replaced release version in file.
PR_BODY="$PR_BODY, updates the tracer version to: $TRACER_VERSION "
fi
if [ "${{ github.event.inputs.update_agent }}" == "true" ]; then
CURRENT_AGENT_VERSION="$(grep -o -e agent-binaries-$versionRegex dotnet/build-packages.sh | sed 's/agent-binaries-//')"
AGENT_VERSION=${{ steps.last_release.outputs.release }}
echo Current agent version is: $CURRENT_AGENT_VERSION
echo "Latest Agent version: $AGENT_VERSION"
major=0
minor=0
build=0
agent_major=0
agent_minor=0
agent_build=0
if [[ $CURRENT_AGENT_VERSION =~ $splitVersionRegex ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
build="${BASH_REMATCH[3]}"
fi
if [[ $AGENT_VERSION =~ $splitVersionRegex ]]; then
agent_major="${BASH_REMATCH[1]}"
agent_minor="${BASH_REMATCH[2]}"
agent_build="${BASH_REMATCH[3]}"
fi
if [[ $agent_major > $major ]]; then
newAgentAvailable=1
elif [[ $agent_minor > $minor ]]; then
newAgentAvailable=1
elif [[ $agent_build > $build ]]; then
newAgentAvailable=1
fi
if [[ "$newAgentAvailable" == "1" ]]; then
echo Updating agent version
sed -i -e "s/agent-binaries-$CURRENT_AGENT_VERSION/agent-binaries-$AGENT_VERSION/" dotnet/build-packages.sh
sed -i -e "s/agent-binaries-$CURRENT_AGENT_VERSION/agent-binaries-$AGENT_VERSION/" dotnet/build-packages-dev.sh
echo Replaced agent version in file.
PR_BODY="$PR_BODY, and updates the agent version to: $AGENT_VERSION"
fi
fi
PR_BODY="$PR_BODY."
echo "::set-output name=version::$VERSION"
echo "::set-output name=tracer_version::$TRACER_VERSION"
echo "::set-output name=pr_body::$PR_BODY"
- name: Create Pull Request
id: pr
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: "version-bump-${{steps.versions.outputs.version}}"
commit-message: "[.Net Version Bump] Bump to v${{steps.versions.outputs.version}}"
delete-branch: true
title: "[.Net Version Bump] Bump to v${{steps.versions.outputs.version}}"
body: "${{steps.versions.outputs.pr_body}}"
- name: Display output
run: |
echo "Pull Request Number - ${{ steps.pr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.pr.outputs.pull-request-url }}"