Skip to content

Commit 3d5aa62

Browse files
Allow regex patterns in releaseBranchNames (#864)
1 parent cc1dac9 commit 3d5aa62

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Build
22

3-
on:
3+
on:
44
pull_request:
55
workflow_dispatch:
66
push:
@@ -31,3 +31,12 @@ jobs:
3131
uses: codecov/codecov-action@v5
3232
with:
3333
token: ${{ secrets.CODECOV_TOKEN }}
34+
35+
- name: Publish to staging repository
36+
run: ./gradlew publishToSonatype currentVersion
37+
env:
38+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
39+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
40+
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
41+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
42+
GPG_PRIVATE_KEY_PASSWORD: ${{ secrets.GPG_PRIVATE_KEY_PASSWORD }}

.github/workflows/publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
12-
with:
13-
fetch-depth: 0
1412
- name: Set up JDK
1513
uses: actions/setup-java@v4
1614
with:

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ plugins {
1313
}
1414

1515
scmVersion {
16-
versionCreator("versionWithBranch")
16+
unshallowRepoOnCI.set(true)
1717
}
1818

1919
group = "pl.allegro.tech.build"

docs/configuration/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ All `axion-release-plugin` configuration options:
7676

7777
// doc: Version / releaseOnlyOnReleaseBranches
7878
releaseOnlyOnReleaseBranches = false
79-
releaseBranchNames = ['master', 'main']
79+
releaseBranchNames = ['master', 'main', 'release/.*']
8080
}
8181

8282
All `axion-release-plugin` configuration flags:
@@ -117,4 +117,4 @@ All `axion-release-plugin` configuration flags:
117117
- only perform a release on branches that match the `releaseBranchNames`
118118
- release.releaseBranchNames
119119
- default: `['master', 'main']`
120-
- a list of branch names that are considered release branches
120+
- a list of regex patterns for release branch names

docs/configuration/version.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,12 @@ And works well in combination with `releaseBranchNames` option
295295

296296
scmVersion {
297297
releaseOnlyOnReleaseBranches = true
298-
releaseBranchNames = ['main', 'master']
298+
releaseBranchNames = ['main', 'master', 'release/.*']
299299
}
300300

301301
or as command line
302302

303-
./gradlew release -Prelease.releaseOnlyOnReleaseBranches -Prelease.releaseBranchNames=main,release
303+
./gradlew release -Prelease.releaseOnlyOnReleaseBranches -Prelease.releaseBranchNames="main,master,release/.*"
304304

305305
## Decorating
306306

src/main/groovy/pl/allegro/tech/build/axion/release/ReleasePlugin.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ abstract class ReleasePlugin implements Plugin<Project> {
9999
def releaseOnlyOnReleaseBranches = context.scmService().isReleaseOnlyOnReleaseBranches()
100100
def releaseBranchNames = context.scmService().getReleaseBranchNames()
101101
def currentBranch = context.repository().currentPosition().getBranch()
102+
def onReleaseBranch = releaseBranchNames.any { pattern -> currentBranch.matches(pattern) }
102103

103-
def shouldSkipRelease = releaseOnlyOnReleaseBranches && !releaseBranchNames.contains(currentBranch)
104+
def shouldSkipRelease = releaseOnlyOnReleaseBranches && !onReleaseBranch
104105

105106
if (shouldSkipRelease) {
106107
disableReleaseTasks(currentBranch, releaseBranchNames, project)

0 commit comments

Comments
 (0)