set up releases #26
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| jobs: | |
| publish: | |
| name: Publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Important for versioning extension to work correctly | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 11 | |
| distribution: "temurin" | |
| cache: maven | |
| - name: Install GPG key | |
| run: | | |
| echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode | gpg --batch --import | |
| gpg --list-secret-keys --keyid-format LONG | |
| - name: Set release type | |
| id: release_type | |
| run: | | |
| echo "GitHub ref: $GITHUB_REF" | |
| if [[ $GITHUB_REF == refs/tags/v* ]]; then | |
| echo "IS_RELEASE=true" >> $GITHUB_ENV | |
| echo "This is a release build from tag ${GITHUB_REF#refs/tags/}" | |
| else | |
| echo "IS_RELEASE=false" >> $GITHUB_ENV | |
| echo "This is a snapshot build from branch ${GITHUB_REF#refs/heads/}" | |
| fi | |
| - name: Build code | |
| run: mvn clean verify -DskipTests | |
| - name: Deploy to Maven Central | |
| run: | | |
| if [[ $IS_RELEASE == true ]]; then | |
| echo "Deploying release to Maven Central" | |
| mvn deploy -P sonatype -DskipTests \ | |
| -s ${{ github.workspace }}/.github/settings.xml | |
| else | |
| echo "Deploying snapshot to Maven Central" | |
| mvn deploy -DskipTests \ | |
| -s ${{ github.workspace }}/.github/settings.xml | |
| fi | |
| env: | |
| OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
| OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | |
| GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| VERSIONING_EXTENSION_LOG: true |