Skip to content

maven-release

maven-release #99

Workflow file for this run

name: maven-release
concurrency: dev-build
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 2 15 * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@6c3b1c91e8873ae0c705b0709f957c7a6a5eaf10
with:
disable-sudo: true
egress-policy: audit #outbound hosts constantly subject to change by action providers
- uses: actions/checkout@cd7d8d697e10461458bc61a30d094dc601a8b017
- name: Set up JDK 17
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9
with:
java-version: 17
distribution: 'temurin'
- name: Create Maven release
id: mvnrel
run: |
git config --global user.email "jens.dibbern@gmail.com"
git config --global user.name "datengaertnerei"
export OSM_IMPORT_FILE=https://github.com/datengaertnerei/test-data-service/raw/develop/data/osm-small.pbf
export MVNVER=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT//')
export PRSOURCE="PR-${MVNVER}"
export RELBRANCH="RB-${MVNVER}"
echo $RELTAG
git branch $RELBRANCH
git checkout $RELBRANCH
chmod u+x ./mvnw
echo "Maven Release Prepare"
./mvnw clean release:prepare
echo "Maven Release Perform"
./mvnw release:perform
# omit maven release leftovers
git stash
# merge tag to main
git checkout "V${MVNVER}"
git switch -c $PRSOURCE
git push origin $PRSOURCE
# preserve branch and tag info
echo "release_branch=$RELBRANCH" >> $GITHUB_OUTPUT
echo "releasetag=V${MVNVER}" >> $GITHUB_OUTPUT
echo "prsource=$PRSOURCE" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
id: rel
uses: Roang-zero1/github-create-release-action@57eb9bdce7a964e48788b9e78b5ac766cb684803
with:
release_title: "Release ${{ steps.mvnrel.outputs.releasetag }}"
created_tag: ${{ steps.mvnrel.outputs.releasetag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create pull request - must run with a different GH token to allow merge check action trigger
- name: Create pull request to main
id: cpr_main
run: gh pr create --base $BASE --head $HEAD --title "$TITLE" --body "$BODY"
env:
GITHUB_TOKEN: ${{ secrets.REL_SECRET }}
HEAD: ${{ steps.mvnrel.outputs.prsource }}
BASE: master
TITLE: "Merge ${{ steps.mvnrel.outputs.prsource }} to main"
BODY: ":crown: *An automated PR*"
# Create pull request - must run with a different GH token to allow merge check action trigger
- name: Create pull request to dev
id: cpr_dev
run: gh pr create --base $BASE --head $HEAD --title "$TITLE" --body "$BODY"
env:
GITHUB_TOKEN: ${{ secrets.REL_SECRET }}
HEAD: ${{ steps.mvnrel.outputs.release_branch }}
BASE: develop
TITLE: "Merge ${{ steps.mvnrel.outputs.release_branch }} to dev"
BODY: ":crown: *An automated PR*"