Update Gradle actions #760
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: Run tests and publish snapshot to Maven on push | |
| on: [push] | |
| jobs: | |
| test_and_publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| loader: [forge, fabric, common] | |
| env: | |
| INCLUDE_DEFAULT_PLUGINS: false | |
| MOREMCMETA_MAVEN_USER: ${{ secrets.MOREMCMETA_MAVEN_USER }} | |
| MOREMCMETA_MAVEN_PASS: ${{ secrets.MOREMCMETA_MAVEN_PASS }} | |
| steps: | |
| - uses: actions/checkout@3ba5ee6fac7e0e30e2ea884e236f282d3a775891 | |
| - uses: actions/setup-java@308abcba03229002f0055e17d79d00c32fca160f | |
| with: | |
| java-version: 21 | |
| distribution: temurin | |
| - name: Determine mod version from branch or tag name | |
| id: mod_version | |
| uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 | |
| with: | |
| script: | | |
| const ref = context.payload.ref; | |
| const branchOrTag = ref.substring(ref.lastIndexOf('/') + 1); | |
| return branchOrTag + '-prerelease'; | |
| result-encoding: string | |
| - name: Ensure Gradle wrapper is executable | |
| run: chmod +x ./gradlew | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@245c8a24de79c0dbeabaf19ebcbbd3b2c36f278d | |
| - name: Run tests | |
| run: ./gradlew :${{ matrix.loader }}:test | |
| - name: Publish snapshot to GitHub Packages | |
| run: ./gradlew :${{ matrix.loader }}:build :${{ matrix.loader }}:publish | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| MOD_VERSION: ${{ steps.mod_version.outputs.result }} |