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 upload | |
| on: | |
| push: | |
| pull_request: | |
| types: | |
| - opened | |
| - reopened | |
| workflow_dispatch: | |
| release: | |
| types: | |
| - created | |
| env: | |
| USERNAME: ${{ github.actor }} | |
| TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| WLIB_SNAPSHOT: ${{ github.event_name != 'release' }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Get current date | |
| run: echo "WLIB_BUILD_DATE=$(date +'%Y-%m-%d_%H-%M-%S')" >> "$GITHUB_ENV" | |
| - name: Get snapshot number | |
| run: echo "WLIB_SNAPSHOT_NUMBER=$((${{ github.run_number }}+${{ github.run_attempt }}))" >> $GITHUB_ENV | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 21 | |
| distribution: temurin | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Build | |
| run: ./gradlew build | |
| - name: Upload results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: "**/build/libs/*.jar" | |
| name: WLib-${{ env.WLIB_BUILD_DATE }} | |
| if-no-files-found: error | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| if: ${{ github.event_name != 'pull_request' }} | |
| needs: | |
| - build | |
| steps: | |
| - name: Get current date | |
| run: echo "WLIB_BUILD_DATE=$(date +'%Y-%m-%d_%H-%M-%S')" >> "$GITHUB_ENV" | |
| - name: Get snapshot number | |
| run: echo "WLIB_SNAPSHOT_NUMBER=$((${{ github.run_number }}+${{ github.run_attempt }}))" >> $GITHUB_ENV | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 21 | |
| distribution: temurin | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Build this shit again | |
| run: ./gradlew clean build | |
| - name: Upload to the release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| for file in */build/libs/*.jar; do | |
| gh release upload ${{ github.event.release.tag_name }} $file | |
| done | |
| - name: Clean, Build and Publish | |
| run: ./gradle -Pskip_nms=true publish clean build publish |