ST6RI-930 Establish deployment to Maven Central #14
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
| # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
|
Check failure on line 1 in .github/workflows/maven-publish.yml
|
||
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | ||
| # This workflow uses actions that are not certified by GitHub. | ||
| # They are provided by a third-party and are governed by | ||
| # separate terms of service, privacy policy, and support | ||
| # documentation. | ||
| name: Publish Release Build | ||
| on: | ||
| workflow_dispatch: | ||
| release: | ||
| types: [published] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up JDK 21 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '21' | ||
| distribution: 'temurin' | ||
| cache: maven | ||
| - name: Remove -snapshot from version | ||
| run: ./mvnw -B versions:set -DremoveSnapshot=true | ||
| - name: Publish to Github Packages | ||
| run: ./mvnw -B -s .mvn/settings.xml deploy -DskipTests=true | ||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password | ||
| # Releases reuse the central-publish profile, which signs artifacts via maven-gpg-plugin, | ||
| # so the runner needs the private key before deploy. | ||
| - name: Import GPG key for Maven Central release | ||
| if: ${{ secrets.CENTRAL_TOKEN_USERNAME != '' && secrets.CENTRAL_TOKEN_PASSWORD != '' && secrets.MAVEN_GPG_PRIVATE_KEY != '' && secrets.MAVEN_GPG_PASSPHRASE != '' }} | ||
| env: | ||
| MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | ||
| run: | | ||
| printf '%s' "${MAVEN_GPG_PRIVATE_KEY}" | gpg --batch --import | ||
| - name: Publish org.omg.sysml.model release to Maven Central | ||
| if: ${{ secrets.CENTRAL_TOKEN_USERNAME != '' && secrets.CENTRAL_TOKEN_PASSWORD != '' && secrets.MAVEN_GPG_PRIVATE_KEY != '' && secrets.MAVEN_GPG_PASSPHRASE != '' }} | ||
| run: ./mvnw -B -s .mvn/settings.xml -f org.omg.sysml.model/pom.xml deploy -Pcentral-publish,central-release -DskipTests=true -Dgpg.passphrase=${MAVEN_GPG_PASSPHRASE} | ||
| env: | ||
| CENTRAL_TOKEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }} | ||
| CENTRAL_TOKEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }} | ||
| MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | ||
| - name: Upload SysML Library .kpar files | ||
| uses: actions/upload-artifact@v5 | ||
| with: | ||
| name: sysml-library-kpar | ||
| path: sysml.library/output/*.kpar | ||
| release: | ||
| name: Release | ||
| runs-on: ubuntu-latest | ||
| needs: [build] | ||
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
| permissions: | ||
| # Use to sign the release artifacts | ||
| id-token: write | ||
| # Used to upload release artifacts | ||
| contents: write | ||
| # Used to generate artifact attestation | ||
| attestations: write | ||
| steps: | ||
| - uses: actions/download-artifact@v6 | ||
| with: | ||
| name: sysml-library-kpar | ||
| path: kpars | ||
| - name: Generate artifact attestation | ||
| uses: actions/attest-build-provenance@v3 | ||
| with: | ||
| subject-path: 'kpars/*.kpar' | ||
| - name: Create a release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| make_latest: true | ||
| files: | | ||
| kpars/* | ||
| overwrite_files: false | ||
| body: | ||
| append_body: true | ||
| name: ${{ github.event.inputs.tag_name || github.event.release.tag_name }} - SysML v2 Pilot Implementation | ||