Go Tracer Release - Public #592
This file contains hidden or 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 - 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 }} |