Add publish steps #234
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: CI | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - "v*" | |
| pull_request: | |
| branches: | |
| - master | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.ref_name }}-ci | |
| cancel-in-progress: true | |
| jobs: | |
| release-notes: | |
| name: Create/Update release notes | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-24.04 | |
| if: ${{ github.event_name != 'pull_request' }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v7 | |
| - name: Create/Update Draft | |
| uses: lucacome/draft-release@v2.2.1 | |
| with: | |
| minor-label: "enhancement" | |
| major-label: "change" | |
| publish: ${{ github.ref_type == 'tag' }} | |
| collapse-after: 50 | |
| license: | |
| name: License header check | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Java | |
| uses: actions/setup-java@v6 | |
| with: | |
| distribution: temurin | |
| java-version: '11' | |
| cache: maven | |
| - name: Check license headers | |
| run: make license-check | |
| test: | |
| name: Test | |
| runs-on: ubuntu-24.04 | |
| needs: license | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| with: | |
| # needed by license-maven-plugin, which inspects git history | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Java | |
| uses: actions/setup-java@v6 | |
| with: | |
| distribution: temurin | |
| java-version: '11' | |
| cache: maven | |
| - name: Build and test | |
| run: ./mvnw clean install | |
| - name: Submit dependency graph | |
| uses: advanced-security/maven-dependency-submission-action@v5 | |
| if: github.event_name == 'push' | |
| classpath: | |
| name: Classpath (${{ matrix.profile }}) | |
| runs-on: ubuntu-24.04 | |
| needs: license | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| profile: [nodeps, alldeps] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| with: | |
| # needed by license-maven-plugin, which inspects git history | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Java | |
| uses: actions/setup-java@v6 | |
| with: | |
| distribution: temurin | |
| java-version: '11' | |
| cache: maven | |
| - name: Install dependencies | |
| run: ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V | |
| - name: Run classpath tests | |
| run: make PROFILES=${{ matrix.profile }} classpath | |
| publish: | |
| name: Publish to Maven Central | |
| needs: [test, classpath] | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Java | |
| uses: actions/setup-java@v6 | |
| with: | |
| distribution: temurin | |
| java-version: '11' | |
| cache: maven | |
| server-id: central | |
| server-username: CENTRAL_USERNAME | |
| server-password: CENTRAL_TOKEN | |
| gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
| gpg-passphrase: GPG_PASSPHRASE | |
| - name: Verify tag matches pom version | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| POM_VERSION=$(./mvnw help:evaluate -N -Dexpression=project.version -q -DforceStdout | grep -v '\[') | |
| echo "Tag version: $TAG_VERSION" | |
| echo "POM version: $POM_VERSION" | |
| if [[ "$POM_VERSION" != "$TAG_VERSION" ]]; then | |
| echo "::warning::Tag $TAG_VERSION does not match pom $POM_VERSION (expected if release:prepare not used with v prefix))" | |
| fi | |
| - name: Publish release | |
| env: | |
| CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} | |
| CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| run: ./mvnw --batch-mode -s ./.settings.xml -Prelease -DskipTests deploy | |
| snapshot: | |
| name: Publish snapshot | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| runs-on: ubuntu-24.04 | |
| needs: [test, classpath] | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Java | |
| uses: actions/setup-java@v6 | |
| with: | |
| distribution: temurin | |
| java-version: '11' | |
| cache: maven | |
| server-id: central | |
| server-username: CENTRAL_USERNAME | |
| server-password: CENTRAL_TOKEN | |
| - name: Publish snapshot | |
| env: | |
| CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} | |
| CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }} | |
| run: ./mvnw --batch-mode -s ./.settings.xml -DskipTests deploy |