Skip to content

Commit

Permalink
Allow regex patterns in releaseBranchNames (#864)
Browse files Browse the repository at this point in the history
  • Loading branch information
radoslaw-panuszewski authored Nov 25, 2024
1 parent cc1dac9 commit 3d5aa62
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build

on:
on:
pull_request:
workflow_dispatch:
push:
Expand Down Expand Up @@ -31,3 +31,12 @@ jobs:
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Publish to staging repository
run: ./gradlew publishToSonatype currentVersion
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PRIVATE_KEY_PASSWORD: ${{ secrets.GPG_PRIVATE_KEY_PASSWORD }}
2 changes: 0 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {
}

scmVersion {
versionCreator("versionWithBranch")
unshallowRepoOnCI.set(true)
}

group = "pl.allegro.tech.build"
Expand Down
4 changes: 2 additions & 2 deletions docs/configuration/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ All `axion-release-plugin` configuration options:

// doc: Version / releaseOnlyOnReleaseBranches
releaseOnlyOnReleaseBranches = false
releaseBranchNames = ['master', 'main']
releaseBranchNames = ['master', 'main', 'release/.*']
}

All `axion-release-plugin` configuration flags:
Expand Down Expand Up @@ -117,4 +117,4 @@ All `axion-release-plugin` configuration flags:
- only perform a release on branches that match the `releaseBranchNames`
- release.releaseBranchNames
- default: `['master', 'main']`
- a list of branch names that are considered release branches
- a list of regex patterns for release branch names
4 changes: 2 additions & 2 deletions docs/configuration/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ And works well in combination with `releaseBranchNames` option

scmVersion {
releaseOnlyOnReleaseBranches = true
releaseBranchNames = ['main', 'master']
releaseBranchNames = ['main', 'master', 'release/.*']
}

or as command line

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

## Decorating

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ abstract class ReleasePlugin implements Plugin<Project> {
def releaseOnlyOnReleaseBranches = context.scmService().isReleaseOnlyOnReleaseBranches()
def releaseBranchNames = context.scmService().getReleaseBranchNames()
def currentBranch = context.repository().currentPosition().getBranch()
def onReleaseBranch = releaseBranchNames.any { pattern -> currentBranch.matches(pattern) }

def shouldSkipRelease = releaseOnlyOnReleaseBranches && !releaseBranchNames.contains(currentBranch)
def shouldSkipRelease = releaseOnlyOnReleaseBranches && !onReleaseBranch

if (shouldSkipRelease) {
disableReleaseTasks(currentBranch, releaseBranchNames, project)
Expand Down

0 comments on commit 3d5aa62

Please sign in to comment.