Skip to content

CI release

CI release #8

Workflow file for this run

name: CI release
on:
workflow_dispatch:
inputs:
nextVersion:
required: false
description: "Next version (optional)"
jobs:
build:
name: Release and next iteration
runs-on: ubuntu-latest
steps:
# Checkout the source code of the project
- name: Checkout
uses: actions/checkout@v4
# Setup the jdk using version 11 of Adoptium Temurin
- name: Setup java 11 using Adoptium Temurin
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
# Setup postgis test DB
- uses: SPalominos/[email protected]
with:
psql_version: '9.6'
pgis_version: '2.5'
docker_image: 'postgis/postgis'
db_password: 'orbisgis'
db_user: 'orbisgis'
db_name: 'orbisgis_db'
# Configure git user in order to sign release with OrbisGIS user.
- name: Configure Git User
run: |
git config user.email "[email protected]"
git config user.name OrbisGIS
#Install the GPG secret key
- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
# Test build
- name: Build test
run: mvn -ntp clean validate compile test javadoc:test-javadoc javadoc:jar
# Create the release :
# - move from Snapshot version to Release
# - commit and tag release
# - move to next Snapshot
# - upload release to maven repo
- name: Release
run: |
VERSION=${{ github.event.inputs.nextVersion }}
mvn \
-ntp \
--batch-mode \
-P deploy \
-Dmaven.test.skip=true \
-P standalone,integration \
release:prepare release:perform \
-Dusername=$GITHUB_ACTOR -Dpassword=$GITHUB_TOKEN ${VERSION:+"-DdevelopmentVersion="$VERSION"-SNAPSHOT"}
env:
MAVEN_USERNAME: ${{ secrets.MVN_CENTRAL_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PASSWORD }}
# Export the last git tag into env.
- name: Export env values
run: echo "GIT_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
# Make the Github release from the last created tag. Write in its body the content of the changelog file.
- name: Make Github release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ env.GIT_TAG }}
release: ${{ env.GIT_TAG }}
bodyFile: "docs/CHANGELOG.md"
draft: false
prerelease: false
artifacts: "h2gis-dist/target/h2gis-standalone-bin.zip"
# Clear the changelog file and add its header
- name: Clear changelog
run: |
echo "## Changelog for v$( mvn help:evaluate -Dexpression=project.version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }' | cut -d- -f1)" > docs/CHANGELOG.md
git commit -a -m "Empty changelog."
git push origin master
# If the version change is a major or minor, create a branch from the previous tag for future revisions.
- name: Branch fork
run: |
GIT_TAG="${GIT_TAG:1}"
CUR_TAG="$( mvn help:evaluate -Dexpression=project.version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }' | cut -d- -f1)"
SPLIT0=(${GIT_TAG//./ })
SPLIT1=(${CUR_TAG//./ })
if [ "${SPLIT0[0]}" = "${SPLIT1[0]}" ] && [ "${SPLIT0[1]}" = "${SPLIT1[1]}" ]; then
echo "Revision change"
else
echo "Minor or Major change"
BRANCH="${SPLIT0[0]}.${SPLIT0[1]}.X"
git checkout -b "$BRANCH" "v${GIT_TAG}"
mvn versions:set -DnewVersion="${SPLIT0[0]}.${SPLIT0[1]}.$((${SPLIT0[2]}+1))-SNAPSHOT"
git commit -a -m "Set next version."
git push -u origin "$BRANCH"
fi