Build and Release the Serverless Compat Java Agent #25
Workflow file for this run
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: Build and Release the Serverless Compat Java Agent | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| publish-package: | |
| description: "Build or Build and Publish?" | |
| required: true | |
| type: choice | |
| default: "Build" | |
| options: | |
| - "Build" | |
| - "Build and Publish" | |
| permissions: {} | |
| jobs: | |
| downloadbinaries: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| package-version: ${{ steps.package.outputs.package-version }} | |
| serverless-compat-version: ${{ steps.serverless-compat-binary.outputs.serverless-compat-version }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - id: package | |
| run: | | |
| PACKAGE_VERSION=$(awk -F '[<>]' '/<version>/{print $3; exit}' pom.xml) | |
| echo "package-version=$PACKAGE_VERSION" >> "$GITHUB_OUTPUT" | |
| - id: serverless-compat-binary | |
| run: | | |
| RESPONSE=$(curl -s "https://api.github.com/repos/datadog/serverless-components/releases") | |
| SERVERLESS_COMPAT_VERSION=$(echo "$RESPONSE" | jq -r --arg pattern "datadog-serverless-compat\/v[0-9]*\.[0-9]*\.[0-9]*" '.[] | select(.tag_name | test($pattern)) | .tag_name' | sort -V | tail -n 1) | |
| echo "Using version ${SERVERLESS_COMPAT_VERSION} of Serverless Compatibility Layer binary" | |
| echo "serverless-compat-version=$(echo "$SERVERLESS_COMPAT_VERSION" | jq -rR 'ltrimstr("sls-")')" >> "$GITHUB_OUTPUT" | |
| curl --output-dir ./temp/ --create-dirs -O -s -L "https://github.com/DataDog/serverless-components/releases/download/${SERVERLESS_COMPAT_VERSION}/datadog-serverless-compat.zip" | |
| unzip ./temp/datadog-serverless-compat.zip -d ./ | |
| - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
| with: | |
| name: bin | |
| path: bin | |
| build: | |
| needs: [downloadbinaries] | |
| runs-on: ubuntu-latest | |
| env: | |
| PACKAGE_VERSION: ${{ needs.downloadbinaries.outputs.package-version }} | |
| SONATYPE_USER: ${{secrets.SONATYPE_USER}} | |
| SONATYPE_PASS: ${{secrets.SONATYPE_PASS}} | |
| GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
| - uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0 | |
| with: | |
| java-version: "21" | |
| distribution: "zulu" | |
| server-id: "nexus" | |
| server-username: "SONATYPE_USER" | |
| server-password: "SONATYPE_PASS" | |
| gpg-private-key: ${{secrets.GPG_SIGNING_KEY}} | |
| gpg-passphrase: "GPG_PASSPHRASE" | |
| - run: mvn -P release clean package | |
| - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
| with: | |
| name: build | |
| path: target/dd-serverless-compat-java-agent-${{ env.PACKAGE_VERSION }}.jar | |
| publish: | |
| if: ${{ github.event.inputs.publish-package == 'Build and Publish' }} | |
| needs: [downloadbinaries] | |
| runs-on: ubuntu-latest | |
| env: | |
| PACKAGE_VERSION: ${{ needs.downloadbinaries.outputs.package-version }} | |
| SONATYPE_USER: ${{secrets.SONATYPE_USER}} | |
| SONATYPE_PASS: ${{secrets.SONATYPE_PASS}} | |
| GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
| - uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0 | |
| with: | |
| java-version: "21" | |
| distribution: "zulu" | |
| server-id: "nexus" | |
| server-username: "SONATYPE_USER" | |
| server-password: "SONATYPE_PASS" | |
| gpg-private-key: ${{secrets.GPG_SIGNING_KEY}} | |
| gpg-passphrase: "GPG_PASSPHRASE" | |
| - run: mvn -P release clean deploy | |
| - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
| with: | |
| name: target | |
| path: target/dd-serverless-compat-java-agent-${{ env.PACKAGE_VERSION }}.jar | |
| release: | |
| if: ${{ github.event.inputs.publish-package == 'Build and Publish' }} | |
| needs: [downloadbinaries, publish] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| env: | |
| PACKAGE_VERSION: ${{ needs.downloadbinaries.outputs.package-version }} | |
| SERVERLESS_COMPAT_VERSION: ${{ needs.downloadbinaries.outputs.serverless-compat-version }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
| - run: | | |
| cp target/dd-serverless-compat-java-agent-${{ env.PACKAGE_VERSION }}.jar target/dd-serverless-compat-java-agent.jar | |
| - uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0 | |
| with: | |
| body: "Uses [${{ env.SERVERLESS_COMPAT_VERSION }}](https://github.com/DataDog/libdatadog/releases/tag/sls-${{ env.SERVERLESS_COMPAT_VERSION }}) of the Serverless Compatibility Layer binary." | |
| draft: true | |
| tag_name: "v${{ env.PACKAGE_VERSION }}" | |
| generate_release_notes: true | |
| make_latest: true | |
| files: | | |
| target/dd-serverless-compat-java-agent-${{ env.PACKAGE_VERSION }}.jar | |
| target/dd-serverless-compat-java-agent.jar | |
| - uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0 | |
| with: | |
| name: Latest | |
| tag_name: download-latest | |
| body: "This release tracks the latest version available, currently **${{ env.PACKAGE_VERSION }}**." | |
| files: | | |
| target/dd-serverless-compat-java-agent.jar |