Fixed join notification bug #84
This file contains 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 project and create GitHub Release | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Fetch all history for all tags and branches | |
- name: Set up JDK 16 | |
uses: actions/setup-java@v2 | |
with: | |
distribution: adopt | |
java-version: 16 | |
- name: Set up Maven | |
uses: stCarolas/setup-maven@v4.2 | |
with: | |
maven-version: 3.8.1 | |
- name: Get version from pom.xml | |
id: version | |
run: echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV | |
- name: Check if tag exists | |
id: tag_exists | |
run: | | |
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then | |
echo "TAG_EXISTS=true" >> $GITHUB_ENV | |
else | |
echo "TAG_EXISTS=false" >> $GITHUB_ENV | |
fi | |
- name: Exit if tag exists | |
if: env.TAG_EXISTS == 'true' | |
run: echo "Tag v${{ env.VERSION }} already exists. Skipping build and release." | |
- name: Fetch commit messages | |
if: env.TAG_EXISTS == 'false' | |
id: fetch_commits | |
run: | | |
git fetch --tags | |
LAST_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --max-count=1)) | |
COMMIT_MESSAGES=$(git log $LAST_TAG..HEAD --pretty=format:"- %s") | |
echo "COMMIT_MESSAGES<<EOF" >> $GITHUB_ENV | |
echo "Full Changelog:" >> $GITHUB_ENV | |
echo "" >> $GITHUB_ENV | |
echo "$COMMIT_MESSAGES" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Build project | |
if: env.TAG_EXISTS == 'false' | |
run: mvn package -B | |
- name: List files in target directory | |
if: env.TAG_EXISTS == 'false' | |
run: ls -al ./target/ | |
- name: Create Release | |
if: env.TAG_EXISTS == 'false' | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: v${{ env.VERSION }} | |
release_name: Release ${{ env.VERSION }} | |
body: ${{ env.COMMIT_MESSAGES }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Upload Release Asset | |
if: env.TAG_EXISTS == 'false' | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./target/UltimateBingo-${{ env.VERSION }}.jar | |
asset_name: UltimateBingo-${{ env.VERSION }}.jar | |
asset_content_type: application/java-archive | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |