You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@casbin.apache.org by hs...@apache.org on 2026/09/17 13:45:11 UTC
(casbin-jcasbin) 03/03: build: derive the Maven version from the release tag
This is an automated email from the ASF dual-hosted git repository.
hsluoyz pushed a commit to branch chore/asf-release-prep
in repository https://gitbox.apache.org/repos/asf/casbin-jcasbin.git
commit b782f25a10dce4b4cbf7bfd14ffdd0e1b2691bba
Author: Yang Luo <hs...@gmail.com>
AuthorDate: Thu Sep 17 21:44:53 2026 +0800
build: derive the Maven version from the release tag
---
.github/scripts/test_verify_release.py | 2 +-
.github/scripts/verify_release.py | 4 ----
.github/workflows/maven-publish.yml | 9 +++------
.github/workflows/release.yml | 8 --------
.gitignore | 4 +++-
BUILDING.md | 4 +++-
RELEASING.md | 16 +++++++++++++---
pom.xml | 26 +++++++++++++++++++++++++-
8 files changed, 48 insertions(+), 25 deletions(-)
diff --git a/.github/scripts/test_verify_release.py b/.github/scripts/test_verify_release.py
index 76dda0a..73c6eb0 100644
--- a/.github/scripts/test_verify_release.py
+++ b/.github/scripts/test_verify_release.py
@@ -117,7 +117,7 @@ class ReleaseVerificationTest(unittest.TestCase):
self.assertEqual(Path('dist/sentinel').read_text(), 'keep')
def test_rejects_invalid_version_before_network(self):
- for version in ('1.0.0-rc1', '../1.0.0', '1.0.1'):
+ for version in ('1.0.0-rc1', '../1.0.0', 'v1.0.0'):
with self.subTest(version=version), patch.object(release, 'download') as network:
with self.assertRaises(ValueError):
release.verify(version, Path('dist'))
diff --git a/.github/scripts/verify_release.py b/.github/scripts/verify_release.py
index 8795f73..bfa5e7e 100644
--- a/.github/scripts/verify_release.py
+++ b/.github/scripts/verify_release.py
@@ -26,7 +26,6 @@ import subprocess
import tarfile
import tempfile
import urllib.request
-import xml.etree.ElementTree as ET
import zipfile
ASF = 'https://downloads.apache.org/incubator/casbin/'
@@ -77,9 +76,6 @@ def verify_signature(home, signature, archive):
def verify(version, output):
if not re.fullmatch(r'[0-9]+\.[0-9]+\.[0-9]+', version):
raise ValueError('Expected final version X.Y.Z')
- pom_version = ET.parse('pom.xml').findtext('{http://maven.apache.org/POM/4.0.0}version')
- if pom_version != version:
- raise ValueError('POM does not match requested version')
commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip()
name = 'apache-casbin-jcasbin-' + version + '-incubating-src'
expected = source_files(subprocess.check_output(['git', 'archive', '--format=tar', '--prefix=' + name + '/', commit]), 'tar')
diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml
index 34a5810..c99c5e3 100644
--- a/.github/workflows/maven-publish.yml
+++ b/.github/workflows/maven-publish.yml
@@ -47,7 +47,7 @@ jobs:
with:
fetch-depth: 0
- - name: Verify the committed release version
+ - name: Verify the requested release version
env:
MAVEN_VERSION: ${{ inputs.maven_version }}
run: |
@@ -55,15 +55,11 @@ jobs:
python3 - <<'PY'
import os
import re
- import xml.etree.ElementTree as ET
requested = os.environ['MAVEN_VERSION']
if not re.fullmatch(r'[0-9]+\.[0-9]+\.[0-9]+', requested):
raise SystemExit('Expected a final Maven release version X.Y.Z')
if os.environ['GITHUB_REF'] != f'refs/tags/v{requested}':
raise SystemExit('Publish only from the matching final release tag after the vote')
- version = ET.parse('pom.xml').getroot().findtext('{http://maven.apache.org/POM/4.0.0}version')
- if version != requested:
- raise SystemExit(f'POM version mismatch: expected {requested}, got {version}')
PY
- name: Verify promoted ASF release before loading signing credentials
@@ -84,8 +80,9 @@ jobs:
- name: Publish Maven
run: |
- mvn -B deploy -DskipTests
+ mvn -B -ntp deploy -DskipTests "-Drevision=${MAVEN_VERSION}"
env:
+ MAVEN_VERSION: ${{ inputs.maven_version }}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
OSSRH_JIRA_USERNAME: ${{ secrets.OSSRH_JIRA_USERNAME }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 0e4b544..fca0a41 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -75,14 +75,6 @@ jobs:
BASE_VERSION="${VERSION%%-rc*}"
# Keep the voted source bytes stable when the same commit is promoted.
BASENAME="apache-casbin-jcasbin-${BASE_VERSION}-incubating-src"
- export BASE_VERSION
- python3 - <<'PY'
- import os
- import xml.etree.ElementTree as ET
- version = ET.parse('pom.xml').getroot().findtext('{http://maven.apache.org/POM/4.0.0}version')
- if version != os.environ['BASE_VERSION']:
- raise SystemExit(f"Commit the release version to pom.xml first: expected {os.environ['BASE_VERSION']}, got {version}")
- PY
PREVIOUS_TAG="$(
{
git tag --list 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$'
diff --git a/.gitignore b/.gitignore
index d5f71ed..aa67f7b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,4 +41,6 @@ hs_err_pid*
target
.idea/
-*.iml
\ No newline at end of file
+*.iml
+# flatten-maven-plugin output
+.flattened-pom.xml
diff --git a/BUILDING.md b/BUILDING.md
index c0e89cf..d3b9b3e 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -42,7 +42,9 @@ Do not use `deploy` when reviewing a release candidate.
Some persistence tests rewrite example policy files. Run tests on a disposable
extraction and preserve the original downloaded archive and its signature.
-Release preparation commits the intended Maven version to `pom.xml`. An RC tag
+The source tree carries the placeholder version `0.0.0`; the real version is
+supplied by the release tag. To build artifacts with a specific version, pass
+`-Drevision=X.Y.Z` (see [RELEASING.md](RELEASING.md)). An RC tag
`vX.Y.Z-rcN` and the corresponding final tag must refer to the reviewed commit.
The source archive name omits the RC number so promotion preserves the voted
bytes. The archive, checksum and signature actually approved by the community
diff --git a/RELEASING.md b/RELEASING.md
index 0484bf5..8d4e35f 100644
--- a/RELEASING.md
+++ b/RELEASING.md
@@ -19,17 +19,27 @@ under the License.
# Releasing JCasbin
-Prepare version, dependency, licensing and workflow changes together in one
+Prepare dependency, licensing and workflow changes together in one
release-preparation PR. Complete the scoped checks before requesting merge.
Use [BUILDING.md](BUILDING.md) for the full Java 8/Maven build. Release-script
tests run with `python3 -m unittest discover -s .github/scripts -p 'test_*.py'`.
The release workflows require Python 3 and GnuPG, provided by Ubuntu runners.
+## Versioning
+
+The version is **not** committed to the source tree. `pom.xml` declares
+`<version>${revision}</version>` with the placeholder `0.0.0`, and the release
+version comes from the git tag: `vX.Y.Z-rcN` and `vX.Y.Z` both map to Maven
+version `X.Y.Z`. The Maven publish job passes `-Drevision=X.Y.Z`, and
+`flatten-maven-plugin` writes the resolved version into the POM that is
+deployed to Maven Central. Nothing in the repository needs to change between
+releases except the tag.
+
## Before creating an RC tag
-1. Check the latest releases/tags and commit the selected `X.Y.Z` in the POM.
+1. Check the latest releases/tags and choose the next `X.Y.Z`.
Resolve relevant dependency updates and legal/source-archive findings in the
- same PR. The approved release scope determines which changes are included.
+ preparation PR. The approved release scope determines which changes are included.
2. After merge, record the exact merged SHA and verify its build. Check the
final source archive with Apache RAT and review LICENSE, NOTICE, DISCLAIMER,
third-party material and any exclusions. New merged bytes need new evidence.
diff --git a/pom.xml b/pom.xml
index 658ad59..89d2e43 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,8 @@ under the License.
<groupId>org.casbin</groupId>
<artifactId>jcasbin</artifactId>
- <version>1.100.0</version>
+ <!-- The real version is supplied at release time with -Drevision=X.Y.Z (see RELEASING.md). -->
+ <version>${revision}</version>
<name>JCasbin Authorization Library</name>
<description>An authorization library that supports access control models like ACL, RBAC, ABAC in Java</description>
@@ -61,6 +62,7 @@ under the License.
</developers>
<properties>
+ <revision>0.0.0</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>2.0.16</slf4j.version>
</properties>
@@ -81,6 +83,28 @@ under the License.
</resource>
</resources>
<plugins>
+ <plugin>
+ <!-- Resolve ${revision} in the POM that gets installed/deployed. -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>flatten-maven-plugin</artifactId>
+ <version>1.7.0</version>
+ <configuration>
+ <flattenMode>ossrh</flattenMode>
+ <updatePomFile>true</updatePomFile>
+ </configuration>
+ <executions>
+ <execution>
+ <id>flatten</id>
+ <phase>process-resources</phase>
+ <goals><goal>flatten</goal></goals>
+ </execution>
+ <execution>
+ <id>flatten-clean</id>
+ <phase>clean</phase>
+ <goals><goal>clean</goal></goals>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@casbin.apache.org
For additional commands, e-mail: commits-help@casbin.apache.org