Add HDF5 Java bindings to Maven #1
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: Test Maven Deployment | ||
# Manual workflow for testing Maven deployment to HDFGroup packages | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
test_mode: | ||
description: 'Test mode' | ||
type: choice | ||
options: | ||
- dry-run | ||
- live-deployment | ||
required: true | ||
default: dry-run | ||
target_repository: | ||
description: 'Maven repository target' | ||
type: choice | ||
options: | ||
- github-packages | ||
- maven-central-staging | ||
required: false | ||
default: github-packages | ||
permissions: | ||
contents: read | ||
packages: write | ||
jobs: | ||
test-maven-deployment: | ||
name: Test Maven Deployment to HDFGroup Packages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Display test configuration | ||
run: | | ||
echo "=== Maven Deployment Test Configuration ===" | ||
echo "Test Mode: ${{ inputs.test_mode }}" | ||
echo "Target Repository: ${{ inputs.target_repository }}" | ||
echo "GitHub Actor: ${{ github.actor }}" | ||
echo "Repository: ${{ github.repository }}" | ||
echo "Expected packages URL: https://github.com/HDFGroup/hdf5/packages" | ||
echo "" | ||
- name: Check repository permissions | ||
run: | | ||
echo "=== Repository Permission Check ===" | ||
# Check if this is running on HDFGroup repo | ||
if [[ "${{ github.repository }}" != "HDFGroup/hdf5" ]]; then | ||
echo "⚠️ WARNING: Running on fork (${{ github.repository }})" | ||
echo " Packages will not be published to HDFGroup/hdf5" | ||
echo " Only permission testing will work" | ||
else | ||
echo "✓ Running on HDFGroup/hdf5 repository" | ||
fi | ||
# Check if we have packages permission | ||
echo "Checking packages permission..." | ||
if [[ "${{ github.token }}" != "" ]]; then | ||
echo "✓ GITHUB_TOKEN is available" | ||
else | ||
echo "❌ GITHUB_TOKEN not available" | ||
fi | ||
- name: Test GitHub Packages API access | ||
run: | | ||
echo "=== Testing GitHub Packages API Access ===" | ||
# Test basic API access | ||
echo "Testing GitHub API access..." | ||
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
"https://api.github.com/user" | jq '.login // "API_ERROR"' | ||
# Test packages API access | ||
echo "Testing GitHub Packages API access..." | ||
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
"https://api.github.com/users/HDFGroup/packages?package_type=maven" \ | ||
| jq 'length // "API_ERROR"' || echo "No packages found yet" | ||
- name: Generate test Maven artifacts | ||
run: | | ||
echo "=== Generating Test Maven Artifacts ===" | ||
# Create test directory structure | ||
mkdir -p test-artifacts/maven-staging-artifacts-linux-x86_64 | ||
# Create a minimal test JAR file | ||
mkdir -p temp-jar/org/hdfgroup/test | ||
echo 'package org.hdfgroup.test; public class TestClass { }' > temp-jar/org/hdfgroup/test/TestClass.java | ||
# Compile and create JAR | ||
cd temp-jar | ||
javac org/hdfgroup/test/TestClass.java | ||
jar cf ../test-artifacts/maven-staging-artifacts-linux-x86_64/jarhdf5-2.0.0-test.jar org/hdfgroup/test/TestClass.class | ||
cd .. | ||
# Create a test POM file | ||
cat > test-artifacts/maven-staging-artifacts-linux-x86_64/pom.xml << 'EOF' | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.hdfgroup</groupId> | ||
<artifactId>hdf5-java</artifactId> | ||
<version>2.0.0-test</version> | ||
<name>HDF5 Java Test</name> | ||
<description>Test artifact for HDF5 Java Maven deployment</description> | ||
</project> | ||
EOF | ||
# Upload as artifact for the deployment workflow | ||
echo "Test artifacts created:" | ||
find test-artifacts -type f -exec ls -la {} \; | ||
- name: Upload test artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: maven-staging-artifacts-linux-x86_64 | ||
path: test-artifacts/maven-staging-artifacts-linux-x86_64/ | ||
- name: Call Maven deployment workflow | ||
uses: ./.github/workflows/maven-deploy.yml | ||
with: | ||
file_base: "hdf5-test" | ||
preset_name: "test" | ||
repository_url: ${{ inputs.target_repository == 'github-packages' && 'https://maven.pkg.github.com/HDFGroup/hdf5' || 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/' }} | ||
repository_id: ${{ inputs.target_repository == 'github-packages' && 'github' || 'ossrh' }} | ||
deploy_snapshots: false | ||
dry_run: ${{ inputs.test_mode == 'dry-run' }} | ||
secrets: | ||
MAVEN_USERNAME: ${{ inputs.target_repository == 'github-packages' && github.actor || secrets.MAVEN_CENTRAL_USERNAME }} | ||
MAVEN_PASSWORD: ${{ inputs.target_repository == 'github-packages' && secrets.GITHUB_TOKEN || secrets.MAVEN_CENTRAL_PASSWORD }} | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
- name: Validate deployment results | ||
if: inputs.test_mode == 'live-deployment' | ||
run: | | ||
echo "=== Validating Deployment Results ===" | ||
# Wait for packages to be processed | ||
echo "Waiting 30 seconds for packages to be processed..." | ||
sleep 30 | ||
# Check GitHub Packages for the deployed artifact | ||
if [[ "${{ inputs.target_repository }}" == "github-packages" ]]; then | ||
echo "Checking GitHub Packages..." | ||
packages=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
"https://api.github.com/users/HDFGroup/packages?package_type=maven") | ||
echo "Available packages:" | ||
echo "$packages" | jq '.[] | {name: .name, html_url: .html_url}' | ||
# Check for our test package | ||
if echo "$packages" | jq -r '.[].name' | grep -q "hdf5-java"; then | ||
echo "✓ hdf5-java package found in GitHub Packages" | ||
else | ||
echo "⚠️ hdf5-java package not found in GitHub Packages" | ||
fi | ||
fi | ||
- name: Display next steps | ||
run: | | ||
echo "=== Test Results and Next Steps ===" | ||
if [[ "${{ inputs.test_mode }}" == "dry-run" ]]; then | ||
echo "🧪 DRY RUN COMPLETED" | ||
echo "" | ||
echo "✓ Permission configuration tested" | ||
echo "✓ Workflow logic validated" | ||
echo "✓ No actual artifacts deployed" | ||
echo "" | ||
echo "Next steps:" | ||
echo "1. If no errors above, run with 'live-deployment' mode" | ||
echo "2. Check https://github.com/HDFGroup/hdf5/packages for deployed artifacts" | ||
echo "3. Test consuming the artifacts in a sample Maven project" | ||
else | ||
echo "🚀 LIVE DEPLOYMENT COMPLETED" | ||
echo "" | ||
echo "Check deployment results at:" | ||
echo "- GitHub Packages: https://github.com/HDFGroup/hdf5/packages" | ||
echo "- Workflow logs above for any deployment errors" | ||
echo "" | ||
echo "Next steps:" | ||
echo "1. Run full release workflow with deploy_maven=true" | ||
echo "2. Test end-to-end user experience with deployed artifacts" | ||
fi |