Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 82 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
build:
needs: test
runs-on: ubuntu-24.04
outputs:
stable: ${{ steps.kind.outputs.stable }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
Expand All @@ -33,11 +35,18 @@ jobs:
java-version: '21'
cache: maven
- name: Check the release version
id: kind
run: |
if [[ ! "$RC_PROFILER_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo 'release tags must have the form vMAJOR.MINOR.PATCH, optionally with a prerelease suffix' >&2
exit 1
fi
# Only a stable release gets system packages and is announced to Homebrew, apt and yum.
if [[ "$RC_PROFILER_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "stable=true" >> "$GITHUB_OUTPUT"
else
echo "stable=false" >> "$GITHUB_OUTPUT"
fi
- name: Build and test the jar at the release version
run: |
version="${RC_PROFILER_VERSION#v}"
Expand All @@ -50,22 +59,37 @@ jobs:
test -s "$jar"
test "$(java -jar "$jar" --version)" = "$version"
java -jar "$jar" --help
- name: Package the jar and the launcher
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
if: steps.kind.outputs.stable == 'true'
with:
go-version: '1.26.5'
cache: false
- name: Install nfpm
if: steps.kind.outputs.stable == 'true'
env:
GOBIN: ${{ runner.temp }}/release-tools
run: |
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.48.0
echo "$GOBIN" >> "$GITHUB_PATH"
- name: Test the packaging helpers
run: python3 -m unittest scripts/test_release_package.py
- name: Build the release files
run: |
version="${RC_PROFILER_VERSION#v}"
assets="$RUNNER_TEMP/release-assets"
package="$RUNNER_TEMP/package/rc-profiler-java_$version"
mkdir -p "$assets" "$package"
cp "target/runtimeconditions-java-profiler-$version.jar" "$assets/runtimeconditions-java-profiler-$version.jar"
cp "target/runtimeconditions-java-profiler-$version.jar" "$package/runtimeconditions-java-profiler.jar"
cp distribution/rc-profiler-java README.md LICENSE "$package/"
tar -C "$RUNNER_TEMP/package" -czf "$assets/rc-profiler-java_$version.tar.gz" "rc-profiler-java_$version"
flags=()
if [[ "${{ steps.kind.outputs.stable }}" == true ]]; then flags+=(--system-packages); fi
python3 scripts/release-package.py --version "$RC_PROFILER_VERSION" \
--jar "target/runtimeconditions-java-profiler-$version.jar" \
--output "$RUNNER_TEMP/release-assets" "${flags[@]}"
- name: Check that the archive runs
run: |
version="${RC_PROFILER_VERSION#v}"
mkdir -p "$RUNNER_TEMP/unpacked"
tar -C "$RUNNER_TEMP/unpacked" -xzf "$RUNNER_TEMP/release-assets/rc-profiler-java_$version.tar.gz"
test "$("$RUNNER_TEMP/unpacked/rc-profiler-java_$version/rc-profiler-java" --version)" = "$version"
- name: Install the system packages in clean Ubuntu, Debian and Rocky Linux containers
if: steps.kind.outputs.stable == 'true'
run: scripts/check-packages.sh "$RUNNER_TEMP/release-assets"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-assets
Expand All @@ -84,14 +108,13 @@ jobs:
with:
name: release-assets
path: release-assets
- name: Verify the assets and create checksums
- name: Verify the assets against their checksums
working-directory: release-assets
run: |
version="${RC_PROFILER_VERSION#v}"
test -s "runtimeconditions-java-profiler-$version.jar"
test -s "rc-profiler-java_$version.tar.gz"
sha256sum *.jar *.tar.gz > checksums.txt
sha256sum --check checksums.txt
sha256sum --check SHA256SUMS
- name: Publish the tagged release
working-directory: release-assets
env:
Expand All @@ -108,10 +131,56 @@ jobs:
echo 'refusing to replace an already published release' >&2
exit 1
fi
gh release upload "$RC_PROFILER_VERSION" *.jar *.tar.gz checksums.txt --repo "$GITHUB_REPOSITORY" --clobber
gh release upload "$RC_PROFILER_VERSION" * --repo "$GITHUB_REPOSITORY" --clobber
else
gh release create "$RC_PROFILER_VERSION" *.jar *.tar.gz checksums.txt \
gh release create "$RC_PROFILER_VERSION" * \
--repo "$GITHUB_REPOSITORY" --verify-tag --draft --generate-notes --title "$RC_PROFILER_VERSION"
fi
gh release edit "$RC_PROFILER_VERSION" --repo "$GITHUB_REPOSITORY" \
--draft=false --prerelease="$prerelease" --latest="$latest"

notify-homebrew:
needs: [build, publish]
if: needs.build.outputs.stable == 'true'
runs-on: ubuntu-24.04
environment: package-distribution
permissions:
contents: none
steps:
- name: Check that the dispatch token is configured
id: token
env:
TOKEN: ${{ secrets.HOMEBREW_REPO_DISPATCH_TOKEN }}
run: |
if [ -n "$TOKEN" ]; then echo "present=true" >> "$GITHUB_OUTPUT"; else echo "::notice::HOMEBREW_REPO_DISPATCH_TOKEN is not set, so the Homebrew formula is not updated"; fi
- name: Trigger the Homebrew formula update
if: steps.token.outputs.present == 'true'
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
with:
token: ${{ secrets.HOMEBREW_REPO_DISPATCH_TOKEN }}
repository: runtimeconditions/homebrew-tools
event-type: rc-profiler-java-release-published
client-payload: '{"tag":"${{ github.ref_name }}"}'

notify-linux-packages:
needs: [build, publish]
if: needs.build.outputs.stable == 'true'
runs-on: ubuntu-24.04
environment: package-distribution
permissions:
contents: none
steps:
- name: Check that the dispatch token is configured
id: token
env:
TOKEN: ${{ secrets.HOMEBREW_REPO_DISPATCH_TOKEN }}
run: |
if [ -n "$TOKEN" ]; then echo "present=true" >> "$GITHUB_OUTPUT"; else echo "::notice::HOMEBREW_REPO_DISPATCH_TOKEN is not set, so the apt and yum repositories are not updated"; fi
- name: Trigger the apt and yum repository publication
if: steps.token.outputs.present == 'true'
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
with:
token: ${{ secrets.HOMEBREW_REPO_DISPATCH_TOKEN }}
repository: runtimeconditions/packages
event-type: rc-profiler-java-release-published
client-payload: '{"tag":"${{ github.ref_name }}"}'
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,38 @@ jobs:
java-version: ${{ matrix.java }}
cache: maven
- run: mvn -B -ntp verify

# Builds the deb, rpm and Homebrew formula as a release would, and installs the packages in clean containers that
# have no Java. A release builds them itself, so this is skipped on a tag.
packages:
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
persist-credentials: false
- uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
distribution: temurin
java-version: '21'
cache: maven
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version: '1.26.5'
cache: false
- name: Install nfpm
env:
GOBIN: ${{ runner.temp }}/release-tools
run: |
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.48.0
echo "$GOBIN" >> "$GITHUB_PATH"
- name: Test the packaging helpers
run: python3 -m unittest scripts/test_release_package.py
- name: Build the jar
run: mvn -B -ntp -DskipTests package
- name: Build the packages
run: |
jar=$(ls target/runtimeconditions-java-profiler-*.jar | grep -v original)
python3 scripts/release-package.py --version v0.0.0 --jar "$jar" --output "$RUNNER_TEMP/packages" --system-packages
- name: Install them in clean Ubuntu, Debian and Rocky Linux containers
run: scripts/check-packages.sh "$RUNNER_TEMP/packages"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
target/
__pycache__/
22 changes: 22 additions & 0 deletions distribution/homebrew/rc-profiler-java.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Release template. scripts/release-package.py replaces the version and checksum.
class RcProfilerJava < Formula
desc "Runtime Conditions profiler for Java codebases"
homepage "https://github.com/runtimeconditions/java-rc-profiler"
version "{{VERSION}}"
url "https://github.com/runtimeconditions/java-rc-profiler/releases/download/v#{version}/rc-profiler-java_#{version}.tar.gz"
sha256 "{{SHA256}}"
license "MIT"

depends_on "openjdk@21"

def install
libexec.install "rc-profiler-java", "runtimeconditions-java-profiler.jar"
# The launcher uses JAVA_HOME when it is set and otherwise this JDK.
(bin/"rc-profiler-java").write_env_script libexec/"rc-profiler-java",
Language::Java.overridable_java_home_env("21")
end

test do
assert_match version.to_s, shell_output("#{bin}/rc-profiler-java --version")
end
end
17 changes: 17 additions & 0 deletions distribution/jdk.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"vendor": "Eclipse Temurin",
"version": "21.0.13+9",
"top": "jdk-21.0.13+9",
"platforms": {
"amd64": {
"url": "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.13%2B9/OpenJDK21U-jdk_x64_linux_hotspot_21.0.13_9.tar.gz",
"file": "OpenJDK21U-jdk_x64_linux_hotspot_21.0.13_9.tar.gz",
"sha256": "d7f5d5cf865a2902b70ff549b97586a7d3f234e016f041ab447ea740c7d66d1c"
},
"arm64": {
"url": "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.13%2B9/OpenJDK21U-jdk_aarch64_linux_hotspot_21.0.13_9.tar.gz",
"file": "OpenJDK21U-jdk_aarch64_linux_hotspot_21.0.13_9.tar.gz",
"sha256": "e3522e707fc7dbe2a72c30746b1e7068301a0213ecd213d4491f35a14eb55578"
}
}
}
17 changes: 17 additions & 0 deletions distribution/nfpm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: rc-profiler-java
arch: ${GOARCH}
platform: linux
version: ${PACKAGE_VERSION}
release: 1
section: utils
priority: optional
maintainer: Runtime Conditions <maintainers@runtimeconditions.io>
description: Runtime Conditions profiler for Java codebases, with its own Java runtime
vendor: Runtime Conditions
homepage: https://github.com/runtimeconditions/java-rc-profiler
license: MIT
contents:
- src: usr
dst: /usr
type: tree
umask: 0o022
48 changes: 48 additions & 0 deletions scripts/check-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
# Install the built packages in clean containers and run the profiler.
#
# scripts/check-packages.sh PACKAGE_DIR [FIXTURES_DIR]
#
# The containers have no Java, so this proves that the packages carry their own runtime.
# FIXTURES_DIR defaults to src/test/resources, which holds generated binding packages and workloads.
set -eu

packages=$(cd "${1:?usage: check-packages.sh PACKAGE_DIR [FIXTURES_DIR]}" && pwd)
fixtures=$(cd "${2:-$(dirname "$0")/../src/test/resources}" && pwd)

# Runs inside the container, after the package is installed.
check='
set -eu
if command -v java >/dev/null 2>&1; then echo "java is on PATH, the test would prove nothing" >&2; exit 1; fi
version=$(rc-profiler-java --version --json)
echo "$version" | grep -q "\"coreSchemas\":\[\"0.4.0\"\]"
profile=$(rc-profiler-java profile generate --project /fixtures/workloads/owned --classpath /fixtures/packages/owned-kind-interface --name owned --workload-uri https://example.test/owned)
echo "$profile" | grep -q "^ - kind: service"
'

run() {
image=$1
install=$2
docker pull -q "$image" >/dev/null
if docker run --rm -v "$packages:/packages:ro" -v "$fixtures:/fixtures:ro" "$image" \
sh -c "set -e; $install >/dev/null 2>&1; $check" >/dev/null 2>&1; then
echo "$image: ok"
else
echo "$image: FAILED" >&2
return 1
fi
}

arch=$(uname -m)
case $arch in
x86_64) deb=amd64; rpm=x86_64 ;;
aarch64|arm64) deb=arm64; rpm=aarch64 ;;
*) echo "unsupported architecture $arch" >&2; exit 1 ;;
esac

for image in ubuntu:24.04 debian:12; do
run "$image" "apt-get install -y /packages/rc-profiler-java_*_$deb.deb"
done
for image in rockylinux:8 rockylinux:9; do
run "$image" "dnf install -y /packages/rc-profiler-java-*.$rpm.rpm"
done
Loading
Loading