github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/.github/workflows/release.yml (about) 1 name: Go Tracer Release 2 3 on: 4 workflow_dispatch: 5 secrets: 6 GITHUB_TOKEN: 7 description: 'Github Token' 8 inputs: 9 packageName: 10 description: 'Example: instagorm, instaredis/v2. Use "." to release the core module' 11 required: true 12 default: '.' 13 type: string 14 versionType: 15 description: 'The version to be released: major, minor or patch' 16 required: true 17 default: 'patch' 18 type: choice 19 options: 20 - major 21 - minor 22 - patch 23 asDraft: 24 description: 'Release as draft?' 25 required: true 26 default: true 27 type: boolean 28 29 jobs: 30 do_release: 31 name: Release 32 runs-on: ubuntu-latest 33 steps: 34 - uses: actions/checkout@v3 35 name: Checkout repo 36 with: 37 fetch-depth: 0 38 ssh-key: ${{secrets.PRIVATE_KEY_GO_TRACER_RELEASE}} 39 - name: Release tracer or package 40 id: releaser 41 run: ./release_action.sh 42 shell: bash {0} 43 env: 44 INSTANA_PACKAGE_NAME: ${{ inputs.packageName }} 45 LIB_VERSION_TYPE: ${{ inputs.versionType }} 46 RELEASE_AS_DRAFT: ${{ inputs.asDraft }} 47 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 48 49 - name: Update pkg.go.dev 50 if: "${{ success() && !inputs.asDraft }}" 51 run: | 52 #!/bin/bash 53 54 if [ ${{ steps.releaser.outputs.RELEASE_PACKAGE }} = "go-sensor" ]; then 55 GO_PKG="github.com/instana/go-sensor@${{ steps.releaser.outputs.RELEASE_VERSION }}" 56 else 57 GO_PKG="github.com/instana/go-sensor/instrumentation/${{ steps.releaser.outputs.RELEASE_PACKAGE }}@${{ steps.releaser.outputs.RELEASE_VERSION }}" 58 fi 59 60 mkdir dummy && cd dummy 61 go mod init example.com 62 go get "$GO_PKG" || echo "Error getting package $GO_PKG, but moving forward with next step" 63 cd .. 64 rm -rf dummy 65 66 - name: "Update all instrumentations: create branch" 67 if: "${{ inputs.packageName == '.' }}" 68 id: create-branch 69 run: | 70 CORE_TAG=$(git tag -l "v1.*" | sort -V | tail -n1) 71 72 echo "CORE_TAG=$CORE_TAG" >> $GITHUB_OUTPUT 73 echo "New core version is $CORE_TAG" 74 75 #!/bin/bash 76 77 DEPRECATED_PKGS=".*instaamqp$" 78 79 # List of instrumentation folders 80 LIB_LIST=$(find ./instrumentation -name go.mod -exec dirname {} \; | grep -E -v "$DEPRECATED_PKGS") 81 82 git config user.name "IBM/Instana/Team Go" 83 git config user.email "github-actions@github.com" 84 git checkout update-instrumentations-core/"$CORE_TAG" || git checkout -b update-instrumentations-core/"$CORE_TAG" 85 86 git pull origin "update-instrumentations-core/$CORE_TAG" || echo "Brand new branch. No need to pull from origin." 87 88 # Updates all instrumentations to use the @latest version of the core module 89 for lib in $LIB_LIST 90 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 -; 91 done 92 93 git add . 94 git commit -m "Updating instrumentations to core module $CORE_TAG" 95 96 - name: "Update all instrumentations: push branch upstream" 97 if: "${{ success() && inputs.packageName == '.' }}" 98 uses: ad-m/github-push-action@master 99 with: 100 github_token: ${{ github.token }} 101 branch: update-instrumentations-core/${{ steps.create-branch.outputs.CORE_TAG }} 102 103 - name: "Update all instrumentations: create pull request" 104 if: "${{ success() && inputs.packageName == '.' }}" 105 run: | 106 CORE_TAG=${{ steps.create-branch.outputs.CORE_TAG }} 107 git checkout update-instrumentations-core/"$CORE_TAG" 108 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) 109 env: 110 GH_TOKEN: ${{ github.token }} 111 112 - name: Post on Slack 113 if: "${{ success() && !inputs.asDraft }}" 114 uses: slackapi/slack-github-action@v1.24.0 115 with: 116 channel-id: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }} 117 payload: | 118 { 119 "text": ":mega: *Go Tracer team* : Version ${{ steps.releaser.outputs.RELEASE_VERSION }} of ${{ steps.releaser.outputs.RELEASE_PACKAGE }} :package: has been released.", 120 "blocks": [ 121 { 122 "type": "section", 123 "text": { 124 "type": "mrkdwn", 125 "text": ":mega: *Go Tracer team* : Version ${{ steps.releaser.outputs.RELEASE_VERSION }} of ${{ steps.releaser.outputs.RELEASE_PACKAGE }} :package: has been released." 126 } 127 }, 128 { 129 "type": "divider" 130 }, 131 { 132 "type": "section", 133 "text": { 134 "type": "mrkdwn", 135 "text": "*URL:* <${{ github.event.release.html_url }}|${{ github.event.release.html_url }}>" 136 } 137 } 138 ] 139 } 140 env: 141 SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} 142 SLACK_RELEASE_CHANNEL_ID: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }}