Build #5
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - feat/** | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - macos-latest | |
| - windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: "17" | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Build and test | |
| run: ./gradlew --no-daemon build | |
| - name: Create jlink image | |
| if: github.ref == 'refs/heads/main' | |
| run: ./gradlew --no-daemon jlink | |
| - name: Upload distribution | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: oop-ang-${{ matrix.os }} | |
| path: build/distributions/*.zip | |
| if-no-files-found: error | |
| release: | |
| name: Release | |
| needs: build | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: "17" | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Read version | |
| id: version | |
| run: | | |
| VERSION=$(./gradlew -q properties | grep '^version:' | awk '{print $2}') | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Check existing release | |
| id: check | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| TAG="v${{ steps.version.outputs.version }}" | |
| if gh release view "$TAG" >/dev/null 2>&1; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Download artifacts | |
| if: steps.check.outputs.exists == 'false' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: release-assets | |
| - name: Create tag | |
| if: steps.check.outputs.exists == 'false' | |
| run: | | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git tag "v${{ steps.version.outputs.version }}" | |
| git push origin "v${{ steps.version.outputs.version }}" | |
| - name: Create release | |
| if: steps.check.outputs.exists == 'false' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| files: | | |
| release-assets/**/*.zip | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} |