Skip to content

Commit

Permalink
NH-37575: download agent from GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
cleverchuk committed Jul 2, 2024
1 parent 8a50dc0 commit 412b185
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,60 @@ env:
STAGE_BUCKET: ${{ secrets.STAGE_BUCKET }}

jobs:
github_release:
if: inputs.run_github_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Build agent
run: ./gradlew clean build -x test

- name: Pre-release and upload artifacts
run: |
VERSION=$(unzip -p agent/build/libs/solarwinds-apm-agent.jar META-INF/MANIFEST.MF | grep Implementation-Version | awk '{ print $2 }')
VERSION=$(echo $VERSION | sed 's/[^a-z0-9.-]//g') # remove illegal characters
VERSION="$VERSION-alpha"
echo "Current version is $VERSION"
response=$(curl -fs -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
-d '{"tag_name":"v'"$VERSION"'", "name":"v'"$VERSION"'", "body":"New release: v'"$VERSION"'", "draft":false, "prerelease":true}')
release_id=$(echo "$response" | jq -r '.id')
# Function to upload a file to GitHub release
upload_file_to_release() {
local release_id="$1"
local file_path="$2"
# Extract filename from file path
file_name=$(basename "$file_path")
# Upload file to GitHub release
curl -fs \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file_path" \
"https://uploads.github.com/repos/$GITHUB_REPOSITORY/releases/$release_id/assets?name=$file_name"
}
# Upload file to GitHub release
upload_file_to_release "$release_id" "agent/build/libs/solarwinds-apm-agent.jar"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

s3-stage-upload: # this job uploads the jar to stage s3
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit 412b185

Please sign in to comment.