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
16 changes: 9 additions & 7 deletions .github/workflows/build-and-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
lint-and-test-python:
name: Python Test Suite
name: Lint Python Test Suite
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'push'

Expand All @@ -38,6 +38,7 @@ jobs:
cd test
source venv/bin/activate
../scripts/lint-python.sh ci
- name: Python test

build:
name: Build and Test Go Plugin
Expand All @@ -59,12 +60,13 @@ jobs:
- name: Install dependencies
run: go mod tidy -e || true

- name: Lint Go files
run: |
echo "🔍 Running go fmt..."
go fmt .
echo "🔍 Running go vet..."
go vet .
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: latest

- name: Lint and format Go files
run: ./scripts/lint-go.sh ci

- name: Build binary
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate_plugin_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def generate_plugin_repo_yaml():
binary_info = {
"checksum": checksum,
"platform": platform,
"url": f"{repo_url}/releases/download/v{version}/{filename}"
"url": f"{repo_url}/releases/download/{version}/{filename}"
}
binaries.append(binary_info)
print(f"Added {platform}: {filename} (checksum: {checksum})")
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,19 @@ jobs:
with:
python-version: "3.11"

- name: Set up Node.js for markdownlint
uses: actions/setup-node@v4
with:
node-version: "18"

- name: Install Go dependencies
run: go mod tidy -e || true

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: latest

- name: Lint Go code
run: ./scripts/lint-go.sh ci

Expand Down Expand Up @@ -55,6 +65,9 @@ jobs:
if: steps.check-python.outputs.python_tests_exist == 'true'
run: ./scripts/lint-python.sh ci

- name: Lint Markdown files
run: ./scripts/lint-markdown.sh ci

# TODO: Re-enable Python tests when ready
# - name: Run Python tests
# if: steps.check-python.outputs.python_tests_exist == 'true'
Expand Down Expand Up @@ -90,6 +103,7 @@ jobs:
echo "=================================="
echo "✅ Go code formatting and linting"
echo "✅ Go tests"
echo "✅ Markdown formatting and linting"
if [ "${{ steps.check-python.outputs.python_tests_exist }}" == "true" ]; then
echo "✅ Python code quality checks"
echo "✅ Python tests"
Expand Down
59 changes: 6 additions & 53 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jobs:
- name: Install dependencies
run: go mod tidy -e || true

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: latest

- name: Lint Go files
run: ./scripts/lint-go.sh ci

Expand Down Expand Up @@ -151,59 +156,7 @@ jobs:
dist/*
plugin-repo-entry.yml
plugin-repo-summary.txt
body: |
## CF CLI Java Plugin ${{ github.event.inputs.version }}

Plugin for profiling Java applications and getting heap and thread-dumps.

## Changes

$(cat release_changelog.txt || echo "No changelog available")

## Installation

### Installation via CF Community Repository

Make sure you have the CF Community plugin repository configured or add it via:
```bash
cf add-plugin-repo CF-Community http://plugins.cloudfoundry.org
```

Trigger installation of the plugin via:
```bash
cf install-plugin -r CF-Community "java"
```

### Manual Installation

Download this specific release (${{ github.event.inputs.version }}) and install manually:

```bash
# on Mac arm64
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/${{ github.event.inputs.version }}/cf-cli-java-plugin-macos-arm64
# on Windows x86
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/${{ github.event.inputs.version }}/cf-cli-java-plugin-windows-amd64
# on Linux x86
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/${{ github.event.inputs.version }}/cf-cli-java-plugin-linux-amd64
```

Or download the latest release:

```bash
# on Mac arm64
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/latest/download/cf-cli-java-plugin-macos-arm64
# on Windows x86
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/latest/download/cf-cli-java-plugin-windows-amd64
# on Linux x86
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/latest/download/cf-cli-java-plugin-linux-amd64
```

**Note:** On Linux and macOS, if you get a permission error, run `chmod +x [cf-cli-java-plugin]` on the plugin binary.
On Windows, the plugin will refuse to install unless the binary has the `.exe` file extension.

You can verify that the plugin is successfully installed by looking for `java` in the output of `cf plugins`.

**Build Timestamp**: ${{ steps.timestamp.outputs.timestamp }}
body_path: release_notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
108 changes: 87 additions & 21 deletions .github/workflows/update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,58 @@ def update_version_in_go_file(file_path, major, minor, build):
"""Update the version in the Go plugin metadata."""
with open(file_path, 'r') as f:
content = f.read()

# Pattern to match the Version struct in PluginMetadata
pattern = r'(Version: plugin\.VersionType\s*{\s*Major:\s*)\d+(\s*,\s*Minor:\s*)\d+(\s*,\s*Build:\s*)\d+(\s*,\s*})'

replacement = rf'\g<1>{major}\g<2>{minor}\g<3>{build}\g<4>'

new_content = re.sub(pattern, replacement, content)

if new_content == content:
print(f"Warning: Version pattern not found or not updated in {file_path}")
return False

with open(file_path, 'w') as f:
f.write(new_content)

print(f"✅ Updated version to {major}.{minor}.{build} in {file_path}")
return True

def process_readme_changelog(readme_path, version):
"""Process the README changelog section for the release."""
with open(readme_path, 'r') as f:
content = f.read()

# Look for the snapshot section
snapshot_pattern = rf'## {re.escape(version)}-snapshot\s*\n'
match = re.search(snapshot_pattern, content)

if not match:
print(f"Error: README.md does not contain a '## {version}-snapshot' section")
return False, None

# Find the content of the snapshot section
start_pos = match.end()

# Find the next ## section or end of file
next_section_pattern = r'\n## '
next_match = re.search(next_section_pattern, content[start_pos:])

if next_match:
end_pos = start_pos + next_match.start()
section_content = content[start_pos:end_pos].strip()
else:
section_content = content[start_pos:].strip()

# Remove the "-snapshot" from the header
new_header = f"## {version}"
updated_content = re.sub(snapshot_pattern, new_header + '\n\n', content)

# Write the updated README
with open(readme_path, 'w') as f:
f.write(updated_content)

print(f"✅ Updated README.md: converted '## {version}-snapshot' to '## {version}'")
return True, section_content

Expand All @@ -75,20 +75,77 @@ def is_rc_version(version_str):
"""Return True if the version string ends with -rc or -rcN."""
return bool(re.match(r"^\d+\.\d+\.\d+-rc(\d+)?$", version_str))

def generate_release_notes(version, changelog_content):
"""Generate complete release notes file."""
release_notes = f"""## CF CLI Java Plugin {version}

Plugin for profiling Java applications and getting heap and thread-dumps.

## Changes

{changelog_content}

## Installation

### Installation via CF Community Repository

Make sure you have the CF Community plugin repository configured or add it via:
```bash
cf add-plugin-repo CF-Community http://plugins.cloudfoundry.org
```

Trigger installation of the plugin via:
```bash
cf install-plugin -r CF-Community "java"
```

### Manual Installation

Download this specific release ({version}) and install manually:

```bash
# on Mac arm64
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/{version}/cf-cli-java-plugin-macos-arm64
# on Windows x86
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/{version}/cf-cli-java-plugin-windows-amd64
# on Linux x86
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/{version}/cf-cli-java-plugin-linux-amd64
```

Or download the latest release:

```bash
# on Mac arm64
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/latest/download/cf-cli-java-plugin-macos-arm64
# on Windows x86
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/latest/download/cf-cli-java-plugin-windows-amd64
# on Linux x86
cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/latest/download/cf-cli-java-plugin-linux-amd64
```

**Note:** On Linux and macOS, if you get a permission error, run `chmod +x [cf-cli-java-plugin]` on the plugin binary.
On Windows, the plugin will refuse to install unless the binary has the `.exe` file extension.

You can verify that the plugin is successfully installed by looking for `java` in the output of `cf plugins`.
"""

with open("release_notes.md", 'w') as f:
f.write(release_notes)

def main():
if len(sys.argv) != 4:
print("Usage: update_version.py <major> <minor> <build>")
print("Example: update_version.py 4 1 0")
sys.exit(1)

try:
major = int(sys.argv[1])
minor = int(sys.argv[2])
build = int(sys.argv[3])
except ValueError:
print("Error: Version numbers must be integers")
sys.exit(1)

version = f"{major}.{minor}.{build}"
version_arg = f"{major}.{minor}.{build}" if (major + minor + build) != 0 else sys.argv[1]
# Accept any -rc suffix, e.g. 4.0.0-rc, 4.0.0-rc1, 4.0.0-rc2
Expand Down Expand Up @@ -117,29 +174,38 @@ def main():
section_content = content[start_pos:].strip()
with open(changelog_file, 'w') as f:
f.write(section_content)

# Generate full release notes for RC
generate_release_notes(sys.argv[1], section_content)

print(f"✅ RC release: Changelog for {base_version} saved to {changelog_file}")
print(f"✅ RC release: Full release notes saved to release_notes.md")
sys.exit(0)

go_file = Path("cf_cli_java_plugin.go")
readme_file = Path("README.md")
changelog_file = Path("release_changelog.txt")

# Update Go version
success = update_version_in_go_file(go_file, major, minor, build)
if not success:
sys.exit(1)

# Process README changelog
success, changelog_content = process_readme_changelog(readme_file, version)
if not success:
sys.exit(1)

# Write changelog content to a file for the workflow to use
with open(changelog_file, 'w') as f:
f.write(changelog_content)


# Generate full release notes
generate_release_notes(version, changelog_content)

print(f"✅ Version updated successfully to {version}")
print(f"✅ Changelog content saved to {changelog_file}")
print(f"✅ Full release notes saved to release_notes.md")

if __name__ == "__main__":
main()
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ counterfeiter

# Built binaries
build/
pkg/

# built project binary (go build)
cf-java-plugin
Expand All @@ -49,4 +50,7 @@ test/snapshots/
*.hprof

# Build artifacts
dist
dist

# go
pkg
Loading