File tree Expand file tree Collapse file tree 5 files changed +83
-1
lines changed
Expand file tree Collapse file tree 5 files changed +83
-1
lines changed Original file line number Diff line number Diff line change 1+ name : Auto-merge Dependabot PRs
2+
3+ on :
4+ pull_request :
5+
6+ permissions :
7+ contents : write
8+ pull-requests : write
9+
10+ jobs :
11+ auto-merge :
12+ if : github.actor == 'dependabot[bot]'
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Approve PR
16+ run : gh pr review --approve "$PR_URL"
17+ env :
18+ PR_URL : ${{ github.event.pull_request.html_url }}
19+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
20+
21+ - name : Enable auto-merge
22+ run : gh pr merge --auto --merge "$PR_URL"
23+ env :
24+ PR_URL : ${{ github.event.pull_request.html_url }}
25+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 66 workflow_dispatch :
77
88jobs :
9+ validate-api-spec-version :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v6
13+
14+ - name : Set up JDK
15+ uses : actions/setup-java@v5
16+ with :
17+ distribution : ' temurin'
18+ java-version : ' 25'
19+
20+ - name : Set up Gradle
21+ uses : gradle/actions/setup-gradle@v5
22+ with :
23+ gradle-version : current
24+
25+ - name : Validate apiSpec version is fixed
26+ run : ./gradlew validateApiSpecVersions
27+
928 ci-release :
1029 uses : ./.github/workflows/ci-build-publish.yml
1130 secrets :
Original file line number Diff line number Diff line change @@ -33,3 +33,5 @@ applicationinsights-agent-*.jar
3333
3434.DS_Store
3535* /.DS_Store
36+
37+ .claude
Original file line number Diff line number Diff line change @@ -24,12 +24,16 @@ apply {
2424
2525 from(" $rootDir /gradle/api-test.gradle" )
2626}
27+ configurations {
28+ apiSpec
29+ implementation. extendsFrom apiSpec
30+ }
2731
2832// We MUST keep all dependencies in the build.gradle to allow dependabot to provide version updates
2933// Sadly, dependabot does not track dependencies in the apply-from files
3034dependencies {
3135 // Api spec
32- implementation( " uk.gov.hmcts.cp:api-hmcts-crime-template:2.0.2" )
36+ apiSpec " uk.gov.hmcts.cp:api-hmcts-crime-template:2.0.2"
3337 implementation ' io.swagger.core.v3:swagger-core:2.2.45'
3438
3539
Original file line number Diff line number Diff line change 1+ // Validates that all dependencies in the 'apiSpec' configuration use fixed release versions.
2+ //
3+ // During development, apiSpec dependencies may reference draft versions (e.g. 1.0.7-a3b4c5d)
4+ // which include a short Git SHA suffix. These are useful for testing against unreleased API specs
5+ // but must not be present in release builds.
6+ //
7+ // This task resolves the apiSpec configuration and rejects any version that does not match
8+ // the strict X.Y.Z semver pattern. It is intended to be run as a gate in the release workflow
9+ // to prevent publishing against draft API specs.
10+ //
11+ // Usage: ./gradlew validateApiSpecVersions
12+
13+ tasks. register(' validateApiSpecVersions' ) {
14+ description = ' Validates that the apiSpec dependency uses a fixed release version (no pre-release suffixes)'
15+ group = ' verification'
16+ doLast {
17+ def fixedVersionPattern = ~/ ^\d +\.\d +\.\d +$/
18+ def failures = []
19+ configurations. apiSpec. dependencies. each { dep ->
20+ if (! (dep. version ==~ fixedVersionPattern)) {
21+ failures << " ${ dep.group} :${ dep.name} :${ dep.version} "
22+ }
23+ }
24+ if (failures) {
25+ throw new GradleException (
26+ " apiSpec contains non-fixed versions:\n ${ failures.join('\n ')} \n " +
27+ " Release builds require fixed versions (X.Y.Z). Draft versions (e.g. vX.Y.Z-<short-sha>) are not allowed."
28+ )
29+ }
30+ println " apiSpec dependency version is a valid fixed release version."
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments