-
Notifications
You must be signed in to change notification settings - Fork 38
149 lines (131 loc) · 5.67 KB
/
release.yml
File metadata and controls
149 lines (131 loc) · 5.67 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
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
147
148
149
name: Go Tracer Release - Public
on:
workflow_dispatch:
inputs:
packageName:
description: 'Example: instagorm, instaredis/v2. Use "." to release the core module'
required: true
default: '.'
type: string
versionType:
description: 'The version to be released: major, minor or patch'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
asDraft:
description: 'Release as draft?'
required: true
default: true
type: boolean
jobs:
do_release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
name: Checkout repo
with:
fetch-depth: 0
ssh-key: ${{secrets.PRIVATE_KEY_GO_TRACER_RELEASE_LATEST}}
ref: main
- name: Release tracer or package
id: releaser
run: ./release_action.sh
shell: bash {0}
env:
INSTANA_PACKAGE_NAME: ${{ inputs.packageName }}
LIB_VERSION_TYPE: ${{ inputs.versionType }}
RELEASE_AS_DRAFT: ${{ inputs.asDraft }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ github.actor }}
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: ${{ github.actor }}
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
- name: Update pkg.go.dev
if: "${{ success() && !inputs.asDraft }}"
run: |
#!/bin/bash
if [ ${{ steps.releaser.outputs.RELEASE_PACKAGE }} = "go-sensor" ]; then
GO_PKG="github.com/instana/go-sensor@${{ steps.releaser.outputs.RELEASE_VERSION }}"
else
GO_PKG="github.com/instana/go-sensor/instrumentation/${{ steps.releaser.outputs.RELEASE_PACKAGE }}@${{ steps.releaser.outputs.RELEASE_VERSION }}"
fi
mkdir dummy && cd dummy
go mod init example.com
go get "$GO_PKG" || echo "Error getting package $GO_PKG, but moving forward with next step"
cd ..
rm -rf dummy
- name: "Update all instrumentations: create branch"
if: "${{ inputs.packageName == '.' }}"
id: create-branch
run: |
#!/bin/bash
CORE_TAG=$(git tag -l "v1.*" | grep -E "v[0-9]+\.[0-9]+\.[0-9]+$" | sort -V | tail -n1)
echo "CORE_TAG=$CORE_TAG" >> $GITHUB_OUTPUT
echo "New core version is $CORE_TAG"
DEPRECATED_PKGS=".*instaamqp$"
# List of instrumentation folders
LIB_LIST=$(find ./instrumentation -name go.mod -exec dirname {} \; | grep -E -v "$DEPRECATED_PKGS")
git checkout update-instrumentations-core/"$CORE_TAG" || git checkout -b update-instrumentations-core/"$CORE_TAG"
git pull origin "update-instrumentations-core/$CORE_TAG" || echo "Brand new branch. No need to pull from origin."
# Updates all instrumentations to use the @latest version of the core module
for lib in $LIB_LIST
do cd "$lib" && echo "Updating: $lib" && go mod edit -droprequire github.com/instana/go-sensor && go get github.com/instana/go-sensor@$CORE_TAG && go mod edit -toolchain=none && go mod tidy && cd -;
done
git add .
git commit -m "Updating instrumentations to core module $CORE_TAG"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ github.actor }}
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: ${{ github.actor }}
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
- name: "Update all instrumentations: push branch upstream"
if: "${{ success() && inputs.packageName == '.' }}"
uses: ad-m/github-push-action@77c5b412c50b723d2a4fbc6d71fb5723bcd439aa # master branch
with:
github_token: ${{ github.token }}
branch: update-instrumentations-core/${{ steps.create-branch.outputs.CORE_TAG }}
- name: "Update all instrumentations: create pull request"
if: "${{ success() && inputs.packageName == '.' }}"
run: |
CORE_TAG=${{ steps.create-branch.outputs.CORE_TAG }}
git checkout update-instrumentations-core/"$CORE_TAG"
gh pr create --title "[public-release] Updating instrumentations to core module $CORE_TAG" --body "This PR updates all instrumented packages to use the latest core module $CORE_TAG." --head $(git branch --show-current)
env:
GH_TOKEN: ${{ github.token }}
- name: Post on Slack
if: "${{ success() && !inputs.asDraft }}"
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 #v1.24.0
with:
channel-id: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }}
payload: |
{
"text": ":mega: *Go Tracer team* : Version ${{ steps.releaser.outputs.RELEASE_VERSION }} of ${{ steps.releaser.outputs.RELEASE_PACKAGE }} :package: has been released.",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":mega: *Go Tracer team* : Version ${{ steps.releaser.outputs.RELEASE_VERSION }} of ${{ steps.releaser.outputs.RELEASE_PACKAGE }} :package: has been released."
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*URL:* <${{ github.event.release.html_url }}|${{ github.event.release.html_url }}>"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_RELEASE_CHANNEL_ID: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }}