Skip to content

Release

Release #4

Workflow file for this run

# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release, e.g. 2.1.0 (make sure to execute on this on the release branch)'
required: true
base:
description: 'Base Version. e.g. 2.1'
required: true
jobs:
fix-version:
# if: ${{ github.repository == 'geosolutions-it/geostore' && github.ref != 'master' }}
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-latest
steps:
- name: Check branch
if: ${{ github.repository != 'geosolutions-it/geostore' || github.ref == 'master' }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('This workflow can not run on master branch')
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
cache: maven
- name: Fix versions, commit and push new tag
run: |
# fix versions to ${{ inputs.version }}
mvn versions:set -DnewVersion=${{ inputs.version }} -DgenerateBackupPoms=false # set versions
mvn versions:set-property -Dproperty=geostore-version -DnewVersion=${{ inputs.version }} # set geostore-version property
mvn versions:use-releases # check to not use SNAPSHOTs
# script will go here
echo "Initializing git"
# Optional
git config user.name github-actions
git config user.email [email protected]
# Commit changes
find . -name 'pom.xml' | xargs git add
git commit -m "Version Release ${{ inputs.version }}"
git tag v${{ inputs.version }} # create tag
git push origin ${{ github.ref_name }} --tags
- name: Build with Maven
run: mvn -B clean install -Pextjs,h2_disk,auditing
- name: Set up Maven Repository
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
server-id: geosolutions
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish package
run: mvn clean install deploy -Ppostgres,extjs
env:
MAVEN_USERNAME: ${{ secrets.GS_MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.GS_MAVEN_PASSWORD }}
- name: Restore Snapshots
run: |
# restore versions to ${{ inputs.base }}-SNAPSHOT
mvn versions:set -DnewVersion=${{ inputs.base }}-SNAPSHOT -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=geostore-version -DnewVersion=${{ inputs.base }}-SNAPSHOT # set geostore-version property
find . -name 'pom.xml' | xargs git add
git commit -m "Restore snapshots from ${{ inputs.version }} to ${{ inputs.base }}-SNAPSHOT"
git tag ${VERSION} # create tag
git push origin ${{ github.ref_name }}
echo "Snapshots version restored"
release:
runs-on: ubuntu-latest
needs: fix-version
concurrency: release-${{ github.ref }}
steps:
- name: create_release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: "v${{ inputs.version }}"
name: "${{ inputs.version }}"
generate_release_notes: true
draft: false
prerelease: false