Skip to content

Post release - livingdoc-maven-plugin - ci skip #97

Post release - livingdoc-maven-plugin - ci skip

Post release - livingdoc-maven-plugin - ci skip #97

name: Build and Deploy
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
permissions:
contents: write
pages: write
id-token: write
jobs:
check:
runs-on: ubuntu-latest
outputs:
annotations-status: ${{ steps.annotations-check.outputs.annotations-status }}
plugin-status: ${{ steps.plugin-check.outputs.plugin-status }}
steps:
- uses: actions/checkout@v3
- name: Detect production files changes
id: changes
uses: dorny/paths-filter@v2
with:
filters: |
annotations:
- 'livingdoc-annotations/src/**'
- 'livingdoc-annotations/pom.xml'
plugin:
- 'livingdoc-maven-plugin/src/**'
- 'livingdoc-maven-plugin/pom.xml'
- name: Save annotations project production files changes status
id: annotations-check
run: |
status="skip"
if [ "${{ steps.changes.outputs.annotations }}" == "true" ]; then
status="deploy"
fi
echo "annotations-status=$status" >> $GITHUB_OUTPUT
- name: Save plugin project production files changes status
id: plugin-check
run: |
status="skip"
if [ "${{ steps.changes.outputs.plugin }}" == "true" ]; then
status="deploy"
fi
echo "plugin-status=$status" >> $GITHUB_OUTPUT
livingdoc-annotations:
runs-on: ubuntu-latest
needs: check
if: "needs.check.outputs.annotations-status == 'deploy' && !contains(github.event.head_commit.message, 'ci skip')"
steps:
- uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.ACTION_BOT_SECRET_KEY }}
- name: Set up java
uses: actions/setup-java@v3
with:
java-version: 19
distribution: adopt
cache: maven
server-id: ossrh
server-username: OSS_SONATYPE_USERNAME
server-password: OSS_SONATYPE_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Create maven release version
if: ${{ github.event_name == 'push' }}
working-directory: ./livingdoc-annotations
run: mvn -f pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion} versions:commit
- name: Deploy
working-directory: ./livingdoc-annotations
run: mvn deploy -P release -DskipTests=true
env:
OSS_SONATYPE_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}
OSS_SONATYPE_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Create and commit next dev version
if: ${{ github.event_name == 'push' }}
working-directory: ./livingdoc-annotations
run: mvn -f pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}-SNAPSHOT versions:commit
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Post release - livingdoc-annotations - ci skip
livingdoc-maven-plugin:
runs-on: ubuntu-latest
needs: check
if: "needs.check.outputs.plugin-status == 'deploy' && !contains(github.event.head_commit.message, 'ci skip')"
steps:
- uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.ACTION_BOT_SECRET_KEY }}
- name: Set up java
uses: actions/setup-java@v3
with:
java-version: 19
distribution: adopt
cache: maven
server-id: ossrh
server-username: OSS_SONATYPE_USERNAME
server-password: OSS_SONATYPE_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Create maven release version
if: ${{ github.event_name == 'push' }}
run: |
mvn -f livingdoc-maven-plugin/pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion} versions:commit
mvn -f livingdoc-examples/pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion} versions:commit
- name: Deploy
working-directory: ./livingdoc-maven-plugin
run: mvn --batch-mode --update-snapshots deploy -P release -X
env:
OSS_SONATYPE_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}
OSS_SONATYPE_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Save artefacts for next jobs
uses: actions/upload-artifact@v3
with:
name: livingdoc-maven-plugin-artifact
path: |
livingdoc-maven-plugin/target/livingdoc-maven-plugin-*.jar
livingdoc-maven-plugin/target/livingdoc-maven-plugin-*.pom
retention-days: 1
- name: Create next dev version
if: ${{ github.event_name == 'push' }}
run: |
mvn -f livingdoc-maven-plugin/pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}-SNAPSHOT versions:commit
mvn -f livingdoc-examples/pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}-SNAPSHOT versions:commit
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Post release - livingdoc-maven-plugin - ci skip
tests_java_plugin:
runs-on: ubuntu-latest
needs:
- check
- livingdoc-maven-plugin
if: "needs.check.outputs.plugin-status == 'deploy' && github.event_name == 'pull_request'"
strategy:
matrix:
version: [11, 15, 17]
env:
folder: livingdoc-examples
steps:
- uses: actions/checkout@v3
- name: Set up java
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.version }}
distribution: adopt
cache: maven
- name: Prepare to install livingdoc-maven-plugin artifact locally
working-directory: ./livingdoc-maven-plugin
run: |
ARTIFACT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
ARTIFACT_PATH=~/.m2/repository/ch/ifocusit/livingdoc/livingdoc-maven-plugin/$ARTIFACT_VERSION/
echo ::set-env name=ARTIFACT_PATH::$ARTIFACT_PATH
echo ::set-env name=LIVINGDOC-MAVEN-PLUGIN_VERSION::$ARTIFACT_VERSION
- name: Install livingdoc-maven-plugin artifact locally
uses: actions/download-artifact@v3
with:
name: livingdoc-maven-plugin-artifact
path: ${{ env.ARTIFACT_PATH }}
- name: Test ${{ matrix.version }}
working-directory: ./livingdoc-maven-plugin/src/nonreg/example-java-x
run: |
sed -i -e "s/\${env.LIVINGDOC-MAVEN-PLUGIN_VERSION}/${{ env.LIVINGDOC-MAVEN-PLUGIN_VERSION }}/g" pom.xml
mvn --batch-mode --update-snapshots verify
env:
JAVA_VERSION: ${{ matrix.version }}
LIVINGDOC-MAVEN-PLUGIN_VERSION: ${{ env.LIVINGDOC-MAVEN-PLUGIN_VERSION }}