OSSRH Migration #9
Workflow file for this run
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: Build and Deploy | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| pull_request: | |
| branches: [ "master" ] | |
| release: | |
| types: [ "published" ] | |
| permissions: | |
| contents: write | |
| packages: write | |
| concurrency: | |
| group: main-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| build-jar: | |
| name: jar / ${{ matrix.os }} / ${{ matrix.jdk-version }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| jdk-version: [ 21 ] | |
| os: [ ubuntu-latest, macos-latest, windows-latest ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set Up JDK ${{ matrix.jdk-version }} | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ matrix.jdk-version }} | |
| distribution: 'temurin' | |
| server-id: 'sonatype' # id central-publishing-maven-plugin | |
| server-username: SONATYPE_USERNAME # env name for central-publishing-maven-plugin user var | |
| server-password: SONATYPE_PASSWORD # env name for central-publishing-maven-plugin pass var | |
| - name: Set Up Maven | |
| uses: stCarolas/setup-maven@v5 | |
| with: | |
| maven-version: 3.8.9 | |
| - name: Cache Maven repository | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| - name: Import GPG Key | |
| uses: crazy-max/ghaction-import-gpg@v6 | |
| with: | |
| gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Setup Maven Revision | |
| shell: bash | |
| run: echo "project_revision=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV | |
| - name: Update Maven Revision to include sha and snapshot | |
| if: github.event_name != 'release' | |
| shell: bash | |
| run: | | |
| base_revision=$(echo "${{ env.project_revision }}" | sed 's/-SNAPSHOT$//') | |
| echo "project_revision=${base_revision}-${GITHUB_SHA::6}-SNAPSHOT" >> $GITHUB_ENV | |
| - name: Maven Build and Verify Jar | |
| run: mvn -V -B -e -ff -ntp -P github,release-sign-artifacts -Drevision="${{ env.project_revision }}" clean verify | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: runner.os == 'Linux' | |
| continue-on-error: true | |
| with: | |
| name: LitFX-${{ env.project_revision }} | |
| path: | | |
| ./**/target/*.pom | |
| ./**/target/*.jar | |
| ./**/target/*.asc | |
| retention-days: 10 | |
| if-no-files-found: error | |
| - name: Deploy Github Package | |
| if: runner.os == 'Linux' && (github.ref == 'refs/heads/master' || github.event_name == 'release') | |
| continue-on-error: true | |
| # LitFX is an invalid artifactId per GH Packages, using -fn to allow others to upload | |
| run: mvn -V -B -e -fn -ntp -P github,release-sign-artifacts -Drevision="${{ env.project_revision }}" deploy | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Deploy Sonatype Package | |
| if: runner.os == 'Linux' && (github.ref == 'refs/heads/master' || github.event_name == 'release') | |
| run: mvn -V -B -e -ff -ntp -P sonatype,release-sign-artifacts -Drevision=${{ env.project_revision }} deploy | |
| env: | |
| SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | |
| SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} |