github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/.github/workflows/update-instrumentations-release.yml (about) 1 # This workflow releases all instrumented packages updated to point to the latest core module. 2 # It should run in the main branch after the PR created by the `Go Tracer Release` workflow is merged to main. 3 4 name: Release all updated instrumentations 5 6 on: 7 pull_request: 8 branches: 9 - main 10 types: 11 - closed 12 13 jobs: 14 release_instrumentations: 15 name: Release instrumentations 16 runs-on: ubuntu-latest 17 if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'update-instrumentations-core') 18 steps: 19 - uses: actions/checkout@v3 20 name: Checkout repo 21 with: 22 fetch-depth: 0 23 ssh-key: ${{secrets.PRIVATE_KEY_GO_TRACER_RELEASE}} 24 - name: Release all packages 25 id: release-packages 26 run: | 27 CORE_TAG=$(git tag -l "v1.*" | sort -V | tail -n1) 28 29 git config user.name "IBM/Instana/Team Go" 30 git config user.email "github-actions@github.com" 31 32 EXCLUDED_DIRS="\/.*\/example" 33 DEPRECATED_PKGS=".*instaamqp$" 34 35 LIB_LIST=$(find ./instrumentation -name go.mod -exec dirname {} \; | grep -E -v "$EXCLUDED_DIRS" | grep -E -v "$DEPRECATED_PKGS") 36 37 TAGS="" 38 for lib in $LIB_LIST 39 do LIB_PATH="$(echo "$lib" | sed 's/\.\///')" 40 41 # Expected to find something like: instrumentation/instaredis/v1.5.0 42 # This option will be used if the instrumentation has no v2 subfolder 43 TAG_TO_SEARCH="$LIB_PATH/v[0-1].*" 44 45 # Expected to identify packages with subfolders. eg: instrumentation/instaredis/v2 46 NEW_VERSION_FOLDER=$(echo "$lib" | grep -E "/v[2-9].*") 47 48 # If NEW_VERSION_FOLDER has something we update TAG_TO_SEARCH 49 if [ -n "$NEW_VERSION_FOLDER" ]; then 50 # Expected to be a version. eg: 1.5.0 51 NEW_MAJOR_VERSION=$(echo "$NEW_VERSION_FOLDER" | sed "s/.*v//") 52 53 # Expected to be tag name with major version higher than 1. eg: instrumentation/instaredis/v2.1.0 54 PATH_WITHOUT_V=$(echo "$LIB_PATH" | sed "s/\/v[0-9]*//") 55 TAG_TO_SEARCH="$PATH_WITHOUT_V/v$NEW_MAJOR_VERSION.*" 56 fi 57 58 VERSION=$(git tag -l "$TAG_TO_SEARCH" | sort -V | tail -n1 | sed "s/.*v//") 59 60 if [ -z "$VERSION" ]; then 61 VERSION="0.0.0" 62 fi 63 64 MINOR_VERSION=$(echo "$VERSION" | sed -En 's/[0-9]+\.([0-9]+)\.[0-9]+/\1/p') 65 MAJOR_VERSION=$(echo "$VERSION" | sed -En 's/([0-9]+)\.[0-9]+\.[0-9]+/\1/p') 66 MINOR_VERSION=$((MINOR_VERSION+1)) 67 NEW_VERSION="$MAJOR_VERSION.$MINOR_VERSION.0" 68 69 # Updates the minor version in version.go 70 sed -i -E "s/[0-9]+\.[0-9]+\.[0-9]+/${NEW_VERSION}/" "$lib"/version.go | tail -1 71 72 # Tags to be created after version.go is merged to the main branch with the new version 73 PATH_WITHOUT_V=$(echo "$LIB_PATH" | sed "s/\/v[0-9]*//") 74 TAGS="$TAGS $PATH_WITHOUT_V/v$MAJOR_VERSION.$MINOR_VERSION.0" 75 done 76 77 echo "TAGS=$TAGS" >> "$GITHUB_OUTPUT" 78 79 # Commit all version.go files to the main branch 80 git add ./instrumentation/**/version.go 81 git add ./instrumentation/**/**/version.go 82 git commit -m "Updated instrumented packages with core module $CORE_TAG" 83 git push origin @ 84 85 echo "Creating tags for each instrumentation" 86 87 for t in $TAGS 88 do git tag "$t" && git push origin "$t" 89 done 90 91 # Release every instrumentation 92 for t in $TAGS 93 do gh release create "$t" \ 94 --title "$t" \ 95 --notes "Updated instrumentation with the latest version of go-sensor core module $CORE_TAG.<br/><br/> --auto-generated--" 96 done 97 shell: bash {0} 98 env: 99 GH_TOKEN: ${{ github.token }} 100 101 - name: Update pkg.go.dev 102 run: | 103 #!/bin/bash 104 105 mkdir dummy && cd dummy 106 go mod init example.com 107 echo "get packages..." 108 109 for t in ${{ steps.release-packages.outputs.TAGS }} 110 do go get github.com/instana/go-sensor/$(echo "$t" | sed 's/\/v/@v/') || echo "Error getting package $t, but moving forward..." 111 done 112 113 cd .. 114 rm -rf dummy