-
Notifications
You must be signed in to change notification settings - Fork 39
142 lines (125 loc) · 5.08 KB
/
release.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
name: Go Tracer Release
on:
workflow_dispatch:
secrets:
GITHUB_TOKEN:
description: 'Github Token'
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@v3
name: Checkout repo
with:
fetch-depth: 0
ssh-key: ${{secrets.PRIVATE_KEY_GO_TRACER_RELEASE}}
- 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 }}
- 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: |
CORE_TAG=$(git tag -l "v1.*" | sort -V | tail -n1)
echo "CORE_TAG=$CORE_TAG" >> $GITHUB_OUTPUT
echo "New core version is $CORE_TAG"
#!/bin/bash
DEPRECATED_PKGS=".*instaamqp$"
# List of instrumentation folders
LIB_LIST=$(find ./instrumentation -name go.mod -exec dirname {} \; | grep -E -v "$DEPRECATED_PKGS")
git config user.name "IBM/Instana/Team Go"
git config user.email "[email protected]"
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" && go mod edit -droprequire github.com/instana/go-sensor && go get github.com/instana/go-sensor@$CORE_TAG && go mod tidy && cd -;
done
git add .
git commit -m "Updating instrumentations to core module $CORE_TAG"
- name: "Update all instrumentations: push branch upstream"
if: "${{ success() && inputs.packageName == '.' }}"
uses: ad-m/github-push-action@master
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 "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/[email protected]
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 }}