Merge pull request #4 from Pinont/dev #20
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: Publish SNAPSHOT | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| types: [ closed ] | |
| branches: [ main ] | |
| jobs: | |
| snapshot: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Extract version | |
| id: version | |
| run: | | |
| VERSION=$(grep -m1 '<version>' pom.xml | sed -E 's/.*<version>([^<]+)<\/version>.*/\1/') | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| if [[ "$VERSION" == *-SNAPSHOT ]]; then | |
| echo "deploy=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "deploy=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Abort (not a SNAPSHOT) | |
| if: steps.version.outputs.deploy != 'true' | |
| run: echo "Version ${{ steps.version.outputs.version }} is not a SNAPSHOT. Skipping deploy." | |
| - name: Set up JDK 23 (generate settings.xml) | |
| if: steps.version.outputs.deploy == 'true' | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '23' | |
| server-id: github | |
| settings-path: ${{ github.workspace }} | |
| - name: Cache Maven | |
| if: steps.version.outputs.deploy == 'true' | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: maven-${{ runner.os }}-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| maven-${{ runner.os }}- | |
| - name: Build (package) | |
| if: steps.version.outputs.deploy == 'true' | |
| run: mvn -B -s $GITHUB_WORKSPACE/settings.xml package | |
| - name: Deploy SNAPSHOT | |
| if: steps.version.outputs.deploy == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: mvn -B -s $GITHUB_WORKSPACE/settings.xml -DskipTests deploy | |
| - name: Create Git Tag | |
| if: steps.version.outputs.deploy == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git tag "v${{ steps.version.outputs.version }}" | |
| git push origin "v${{ steps.version.outputs.version }}" | |
| - name: Summary | |
| run: | | |
| echo "Version: ${{ steps.version.outputs.version }}" | |
| echo "Deployed: ${{ steps.version.outputs.deploy }}" |