Publish Snapshot #15
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
| # This workflow must be manually triggered. It accepts a version and a release type. | |
| # First it sets the version in gradle.properties to the new version and pushes it. | |
| # Then it generates a log, based on commits. | |
| # After that builds a jar and uploads it to curseforge/modrinth/GitHub releases | |
| name: Publish Snapshot | |
| on: | |
| workflow_dispatch: | |
| # Cancel previous jobs if PR gets another push | |
| concurrency: | |
| group: SNAPSHOT-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| with: | |
| token: ${{ secrets.PAT }} | |
| - name: Set snapshot version | |
| id: version | |
| run: | | |
| mod_version=$(grep -E '^[[:space:]]*mod_version[[:space:]]*=' gradle.properties | cut -d'=' -f2 | tr -d '[:space:]') | |
| commit=$(git rev-parse --short HEAD) | |
| echo "Current mod version: -$mod_version-, Last commit: -$commit-" | |
| snapshot_ver="$mod_version-SNAPSHOT+$commit" | |
| echo "snapshot_ver=$snapshot_ver" >> $GITHUB_OUTPUT | |
| # sed -i "s/^mod_version.*/mod_version = $snapshot_ver/" gradle.properties | |
| - name: Setup Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v6 | |
| - name: Read CI info | |
| id: ci | |
| run: | | |
| while IFS='=' read -r key value; do | |
| echo "$key=$value" >> "$GITHUB_OUTPUT" | |
| done < <(./gradlew -q printCiInfo) | |
| - name: Build Project | |
| run: ./gradlew build | |
| - name: Upload Build Artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ModularUI-mc${{ steps.ci.outputs.mc_version }}-${{ steps.version.outputs.snapshot_ver }} | |
| path: build/libs | |
| - name: Publish to maven | |
| run: ./gradlew publish | |
| env: | |
| SNAPSHOT: "true" | |
| MAVEN_USER: ${{ secrets.GTCEU_MAVEN_USER }} | |
| MAVEN_PASSWORD: ${{ secrets.GTCEU_MAVEN_PASSWORD }} |