Adjust GitHub action with better release name #10
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: [dev] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| environment: deployment | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v4 | |
| - name: setup java | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 21 | |
| distribution: 'temurin' | |
| - name: cache maven packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| - name: build with maven | |
| run: mvn --batch-mode --update-snapshots verify | |
| - name: rename artifact | |
| run: mv target/Database-*.jar Database.jar | |
| - name: set short sha | |
| run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> "$GITHUB_ENV" | |
| - name: create release | |
| id: create_release | |
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/dev' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: Database-${{ env.SHORT_SHA }} | |
| name: Release ${{ env.SHORT_SHA }} | |
| draft: false | |
| prerelease: false | |
| files: Database.jar | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: deploy to maven | |
| run: mvn deploy -s settings.xml | |
| env: | |
| REPO_USERNAME: ${{ secrets.REPO_USERNAME }} | |
| REPO_PASSWORD: ${{ secrets.REPO_PASSWORD }} |