Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

name: "Publish Snapshot to Maven"
on:
schedule:
# * is a special character in YAML so you have to quote this string
# this schedules a workflow to run at specific UTC times using POSIX cron syntax -> https://crontab.guru/
# we're publishing a new snapshot every night at 00:00 UTC
- cron: '0 0 * * *'

jobs:
publish-snapshot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
- run: |
./gradlew publishApachePublicationToMavenRepository -PmavenUser=${{ secrets.NEXUS_USER }} -PmavenPassword=${{ secrets.NEXUS_PW }}
23 changes: 17 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/

import groovy.transform.Memoized
import java.util.regex.Matcher
import java.util.regex.Pattern

buildscript {
repositories {
Expand Down Expand Up @@ -557,7 +559,7 @@ project(':iceberg-nessie') {
}

@Memoized
boolean isVersionFileExists() {
boolean versionFileExists() {
return file('version.txt').exists()
}

Expand All @@ -567,19 +569,28 @@ String getVersionFromFile() {
}

String getProjectVersion() {
if (isVersionFileExists()) {
if (versionFileExists()) {
return getVersionFromFile()
}

try {
return gitVersion()
} catch (NullPointerException e) {
throw new Exception("Neither version.txt nor git version exists")
// we're fetching the version from the latest tag (prefixed with 'release-base-'),
// which can look like this: '0.13.0-2-g805400f0.dirty' but we're only interested in the MAJOR.MINOR.PATCH part
String version = gitVersion(prefix: 'release-base-')
Pattern pattern = Pattern.compile("^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?\$")
Matcher matcher = pattern.matcher(version)
if (matcher.matches()) {
// bump the MINOR version and always set the PATCH version to 0
return matcher.group(1) + "." + (Integer.valueOf(matcher.group(2)) + 1) + ".0-SNAPSHOT"
}
return version
} catch (Exception e) {
throw new Exception("Neither version.txt nor git version exists: " + e.getMessage(), e)
}
}

String getJavadocVersion() {
if (isVersionFileExists()) {
if (versionFileExists()) {
return getVersionFromFile()
}

Expand Down