github action generate version #9
Workflow file for this run
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 | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v2 | |
| with: | |
| java-version: '11' | |
| distribution: 'adopt' | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| # Set version from tag | |
| - name: Set version from tag | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| mvn versions:set -DnewVersion=${TAG_VERSION} -DgenerateBackupPoms=false | |
| # Run Maven to package the project | |
| - name: Build with Maven | |
| run: mvn clean package -DskipTests | |
| # Upload the JAR as a release asset | |
| - name: Upload JAR to GitHub Releases | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: target/TestingBotTunnel-*.jar | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |