|
| 1 | +# Extract BOM Versions Action |
| 2 | + |
| 3 | +Fetches the Spring Cloud release train BOM (`pom.xml`) directly from GitHub |
| 4 | +and exports all version properties (entries ending in `.version`) as both |
| 5 | +action outputs and environment variables for use in subsequent workflow steps. |
| 6 | + |
| 7 | +Supports both the public OSS BOM (`spring-cloud-release`) and the private |
| 8 | +commercial BOM (`spring-cloud-release-commercial`). |
| 9 | + |
| 10 | +## Usage |
| 11 | + |
| 12 | +### OSS (public repo — no token required) |
| 13 | + |
| 14 | +```yaml |
| 15 | +- name: Extract versions from Spring Cloud BOM |
| 16 | + id: extract-versions |
| 17 | + uses: spring-cloud/spring-cloud-github-actions/.github/actions/extract-bom-versions@main |
| 18 | + with: |
| 19 | + ref: '2023.0.x' |
| 20 | + |
| 21 | +# Access as a JSON output via fromJSON() |
| 22 | +- name: Print Spring Boot version |
| 23 | + run: | |
| 24 | + echo "Spring Boot: ${{ fromJSON(steps.extract-versions.outputs.versions)['spring-boot'] }}" |
| 25 | +
|
| 26 | +# Or use the exported environment variables directly in shell steps |
| 27 | +- name: Update POM versions |
| 28 | + run: | |
| 29 | + mvn versions:set -DnewVersion=$RELEASE_TRAIN_VERSION |
| 30 | + mvn versions:set-property -Dproperty=spring-boot.version -DnewValue=$SPRING_BOOT_VERSION |
| 31 | +``` |
| 32 | +
|
| 33 | +### Commercial (private repo — token required) |
| 34 | +
|
| 35 | +```yaml |
| 36 | +- name: Extract versions from commercial Spring Cloud BOM |
| 37 | + id: extract-versions |
| 38 | + uses: spring-cloud/spring-cloud-github-actions/.github/actions/extract-bom-versions@main |
| 39 | + with: |
| 40 | + ref: '2023.0.x' |
| 41 | + commercial: 'true' |
| 42 | + token: ${{ secrets.COMMERCIAL_GITHUB_TOKEN }} |
| 43 | +``` |
| 44 | +
|
| 45 | +## Inputs |
| 46 | +
|
| 47 | +| Input | Required | Default | Description | |
| 48 | +|-------|----------|---------|-------------| |
| 49 | +| `ref` | No | `main` | Branch, tag, or SHA to fetch the BOM from (e.g. `2023.0.x`, `2024.0.x`). | |
| 50 | +| `commercial` | No | `false` | When `true`, fetches from `spring-cloud-release-commercial`. A `token` with access to that private repo must be supplied. | |
| 51 | +| `token` | No* | `github.token` | GitHub token for fetching the BOM. *Required when `commercial` is `true`. | |
| 52 | + |
| 53 | +## Outputs |
| 54 | + |
| 55 | +| Output | Description | |
| 56 | +|--------|-------------| |
| 57 | +| `versions` | JSON object of all extracted versions keyed by project name, e.g. `{"spring-boot":"3.2.3","spring-cloud-config":"4.1.1"}` | |
| 58 | + |
| 59 | +## Environment Variables |
| 60 | + |
| 61 | +In addition to the `versions` JSON output, each extracted version is also |
| 62 | +exported as an environment variable for convenience in shell steps. |
| 63 | + |
| 64 | +Naming convention: `{PROJECT_NAME}_VERSION` (upper snake case) |
| 65 | + |
| 66 | +| BOM property | Environment variable | |
| 67 | +|--------------|----------------------| |
| 68 | +| `<version>` (release train) | `RELEASE_TRAIN_VERSION` | |
| 69 | +| `<spring-boot.version>` | `SPRING_BOOT_VERSION` | |
| 70 | +| `<spring-cloud-config.version>` | `SPRING_CLOUD_CONFIG_VERSION` | |
| 71 | +| `<spring-cloud-gateway.version>` | `SPRING_CLOUD_GATEWAY_VERSION` | |
| 72 | +| `<spring-cloud-kubernetes.version>` | `SPRING_CLOUD_KUBERNETES_VERSION` | |
| 73 | +| *(and so on for every `.version` property in the BOM)* | | |
| 74 | + |
| 75 | +## Development |
| 76 | + |
| 77 | +### Prerequisites |
| 78 | + |
| 79 | +- Node.js 20+ |
| 80 | +- npm |
| 81 | + |
| 82 | +### Setup |
| 83 | + |
| 84 | +```bash |
| 85 | +cd .github/actions/extract-bom-versions |
| 86 | +npm install |
| 87 | +``` |
| 88 | + |
| 89 | +### Running Unit Tests |
| 90 | + |
| 91 | +Unit tests use Jest and run entirely locally — no GitHub Actions context needed: |
| 92 | + |
| 93 | +```bash |
| 94 | +npm test |
| 95 | +
|
| 96 | +# With coverage report |
| 97 | +npm run test:coverage |
| 98 | +``` |
| 99 | + |
| 100 | +### Building the Dist Bundle |
| 101 | + |
| 102 | +The `dist/index.js` bundle **must be rebuilt and committed** whenever |
| 103 | +`src/index.js` is changed. The `dist-up-to-date` CI job will fail on PRs |
| 104 | +if you forget. |
| 105 | + |
| 106 | +```bash |
| 107 | +npm run build |
| 108 | +git add dist/index.js |
| 109 | +git commit -m "chore: rebuild dist" |
| 110 | +``` |
| 111 | + |
| 112 | +### Integration Testing |
| 113 | + |
| 114 | +Push your branch to GitHub and the `Test - Extract BOM Versions` workflow will |
| 115 | +run automatically, executing the full integration test against the real |
| 116 | +Spring Cloud BOM. |
0 commit comments