command registration shorter #2
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 release | |
| on: [push, workflow_dispatch] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup up JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v5 | |
| with: | |
| cache-read-only: ${{ github.ref != 'refs/heads/master' }} | |
| - name: Read version from gradle.properties | |
| id: gradle_props | |
| run: | | |
| VERSION=$(grep "^version" gradle.properties | cut -d'=' -f2 | tr -d '[:space:]') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Create tag if not exists | |
| run: | | |
| VERSION=${{ steps.gradle_props.outputs.version }} | |
| if git rev-parse "$VERSION" >/dev/null 2>&1; then | |
| echo "Tag already exists" | |
| else | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git tag $VERSION | |
| git push origin $VERSION -o ci.skip | |
| fi | |
| - name: Make gradlew executable | |
| run: chmod +x ./gradlew | |
| - name: Build with Gradle | |
| run: ./gradlew build | |
| - name: Upload JAR as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Test-${{ steps.gradle_props.outputs.version }} | |
| path: build/libs/*.jar | |
| - name: Create or Update Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ${{ steps.gradle_props.outputs.version }} | |
| files: build/libs/*.jar | |
| tag_name: ${{ steps.gradle_props.outputs.version }} | |
| generate_release_notes: true | |
| fail_on_unmatched_files: false | |
| draft: false | |
| prerelease: ${{ contains(steps.gradle_props.outputs.version, 'beta') || contains(steps.gradle_props.outputs.version, 'alpha') || contains(steps.gradle_props.outputs.version, 'SNAPSHOT') }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |