Go Tracer Release #301
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |