Merge pull request #12 from AkshathSai/dependabot/maven/org.springfra… #44
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 Release | |
| permissions: | |
| contents: write | |
| packages: write | |
| deployments: write | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| # Job for pull request Maven builds | |
| build-for-pr: | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 24 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' # Use the Eclipse Temurin JDK | |
| java-version: '24' | |
| - name: Install dependencies and build | |
| run: mvn clean install | |
| # Job for release builds and publishing artifacts | |
| release: | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 24 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '24' | |
| - name: Cache Maven packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-m2- | |
| - name: Build project | |
| run: mvn clean package -DskipTests | |
| - name: Determine version | |
| id: get_version | |
| run: | | |
| VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
| echo "version=$VERSION" >> $GITHUB_ENV | |
| - name: Create Release | |
| if: github.event_name == 'push' | |
| id: create_release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ github.run_number }} | |
| name: "Release v${{ github.run_number }}" | |
| body: | | |
| Automated release for build #${{ github.run_number }}. | |
| ## Installation Instructions | |
| 1. Download the JAR file to your computer | |
| 2. Open command prompt/terminal | |
| 3. Run the application with: `java -jar addfreetube.jar` | |
| System requirement: Java 24 or higher | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload JAR to release | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: target/addfreetube-0.0.1.jar # Update the JAR name as needed | |
| asset_name: addfreetube.jar | |
| asset_content_type: application/java-archive |