Build and Release Plugin #4
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 Plugin | |
| on: | |
| workflow_dispatch: # Manually triggered workflow | |
| jobs: | |
| build-master: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| artifact_master_path: ${{ steps.upload_master.outputs.artifact-path }} | |
| steps: | |
| - name: Check out master branch | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: master | |
| - name: Gradle Wrapper Verification | |
| uses: gradle/wrapper-validation-action@v1 | |
| - name: Set executable permissions for gradlew | |
| run: chmod +x ./gradlew | |
| - name: Setup JDK for Java 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Build Plugin for Master (1.21.4) | |
| uses: gradle/gradle-build-action@v2 | |
| with: | |
| arguments: build | |
| - name: Upload artifact for master branch (1.21.4) | |
| id: upload_master | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: LightningPop-master | |
| path: build/libs/LightningPop-*.jar | |
| build-2b: | |
| needs: build-master | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| artifact_2b_path: ${{ steps.upload_2b.outputs.artifact-path }} | |
| steps: | |
| - name: Check out 2b branch | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: 2b | |
| - name: Gradle Wrapper Verification | |
| uses: gradle/wrapper-validation-action@v1 | |
| - name: Set executable permissions for gradlew | |
| run: chmod +x ./gradlew | |
| - name: Setup JDK for Java 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Build Plugin for 2b (1.20.4) | |
| uses: gradle/gradle-build-action@v2 | |
| with: | |
| arguments: build | |
| - name: Upload artifact for 2b branch (1.20.4) | |
| id: upload_2b | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: LightningPop-2b | |
| path: build/libs/LightningPop-*.jar | |
| release: | |
| needs: [build-master, build-2b] | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Check out the repository | |
| uses: actions/checkout@v3 | |
| - name: Download build artifact (master) | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: LightningPop-master | |
| path: LightningPop-master | |
| - name: Download build artifact (2b) | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: LightningPop-2b | |
| path: LightningPop-2b | |
| - name: Get and increment latest tag | |
| id: get_tag | |
| run: | | |
| # Fetch all tags | |
| git fetch --tags | |
| # Get the latest tag | |
| latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) | |
| echo "Latest tag: $latest_tag" | |
| # Remove 'v' prefix and split version into parts | |
| version=${latest_tag#v} | |
| IFS='.' read -r major minor patch <<< "$version" | |
| # Increment patch version by 1 | |
| new_patch=$((patch + 1)) | |
| new_minor=$minor | |
| new_major=$major | |
| # Check if patch exceeds 9 | |
| if [ "$new_patch" -gt 9 ]; then | |
| new_patch=0 | |
| new_minor=$((minor + 1)) | |
| fi | |
| # Check if minor exceeds 9 | |
| if [ "$new_minor" -gt 9 ]; then | |
| new_minor=0 | |
| new_major=$((major + 1)) | |
| fi | |
| new_tag="v$new_major.$new_minor.$new_patch" | |
| echo "New tag: $new_tag" | |
| echo "new_tag=$new_tag" >> $GITHUB_ENV | |
| - name: Create and push new tag | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "actions@github.com" | |
| git tag ${{ env.new_tag }} | |
| git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} ${{ env.new_tag }} | |
| - name: Create GitHub Release | |
| uses: "marvinpinto/action-automatic-releases@latest" | |
| with: | |
| repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
| automatic_release_tag: "${{ env.new_tag }}" | |
| prerelease: false | |
| files: | | |
| LightningPop-master/LightningPop-*.jar | |
| LightningPop-2b/LightningPop-*.jar |