create-release-version script is no longer needed #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Default | |
on: | |
push: | |
branches: | |
- '**' | |
release: | |
types: [ published ] | |
jobs: | |
# --------------------------------------------------------------------------- | |
build-and-test: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
outputs: | |
version: ${{ steps.extract-version.outputs.version }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Download Maven Cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Setup JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 11 | |
distribution: corretto | |
- name: Extract Version | |
id: extract-version | |
run: | | |
if [[ "${{ github.event_name == 'release'}}" = "true" ]]; then | |
VERSION=$(git describe --tags | cut -d v -f2) | |
else | |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout); | |
fi | |
echo "Detected version = $VERSION" | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Set Release Version | |
if: ${{ github.event_name == 'release' }} | |
run: | | |
git config user.email "actions@github.com" | |
git config user.name "GitHub Actions" | |
RELEASE_VERSION="${{ steps.extract-version.outputs.version }}" | |
mvn -B versions:set "-DnewVersion=$RELEASE_VERSION" versions:commit | |
git commit -am "[skip ci] set release version $RELEASE_VERSION" | |
git push origin HEAD:master | |
TAG_NAME="v$RELEASE_VERSION" | |
git tag -f $TAG_NAME | |
git push origin -f --tags | |
- name: Maven Build | |
run: mvn -B verify -Pci | |
- name: Upload Plugin Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: target | |
path: target/*.jar | |
retention-days: 2 | |
prepare-next-snapshot: | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'release' }} | |
steps: | |
- name: Checkout Source | |
uses: actions/checkout@v4 | |
- name: Download Maven Cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Setup JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 11 | |
distribution: corretto | |
- name: Prepare next Snapshot Version | |
run: | | |
git config user.email "actions@github.com" | |
git config user.name "GitHub Actions" | |
git pull origin HEAD | |
VERSION="${{ needs.build-and-test.outputs.version }}" | |
MAJOR_VERSION=$(echo "$VERSION" | cut -d . -f1) | |
MINOR_VERSION=$(echo "$VERSION" | cut -d . -f2) | |
INCREMENT_VERSION=$(echo "$VERSION" | cut -d . -f3) | |
NEXT_INCREMENT_VERSION=$((INCREMENT_VERSION + 1)) | |
NEXT_SNAPSHOT_VERSION="$MAJOR_VERSION.$MINOR_VERSION.$NEXT_INCREMENT_VERSION-SNAPSHOT" | |
mvn -B versions:set "-DnewVersion=$NEXT_SNAPSHOT_VERSION" versions:commit | |
git commit -am "[skip ci] set development version $NEXT_SNAPSHOT_VERSION" | |
git push origin HEAD:master | |
notify-slack: | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Notify Slack | |
uses: iRoachie/slack-github-actions@v2.3.2 | |
env: | |
SLACK_WEBHOOK_URL: ${{ vars.LP_SLACK_WEBHOOK_URL }} | |
with: | |
status: ${{ job.status }} |