Party chat #1411
Workflow file for this run
This file contains 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 | |
on: | |
push: | |
branches: [ "**" ] | |
tags: [ "v**" ] | |
pull_request: | |
release: | |
types: [ published ] | |
jobs: | |
build: | |
# Only run on PRs if the source branch is on someone else's repo | |
if: ${{ (github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name) && (github.event.name != 'push' || !startsWith(github.ref, 'refs/tags/') || contains(github.ref, '-beta.')) }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: [ 17 ] | |
fail-fast: true | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: gradle/wrapper-validation-action@v1 | |
- name: JDK ${{ matrix.java }} | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.java }} | |
distribution: 'temurin' | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
# gradle build action can't handle project dir local caches | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
.gradle/loom-cache | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: ${{ runner.os }}-gradle- | |
- name: Build | |
run: ./gradlew build --stacktrace | |
- name: Determine Snapshot Status | |
run: | | |
if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then | |
echo "STATUS=snapshot" >> $GITHUB_ENV | |
else | |
echo "STATUS=release" >> $GITHUB_ENV | |
fi | |
- name: "publish snapshot to sonatype snapshots" | |
if: "${{ env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/2.1' }}" | |
run: ./gradlew publish | |
env: | |
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}" | |
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}" | |
- name: "publish (pre-)release to maven central" | |
if: "${{ env.STATUS == 'release' && github.event_name == 'release' }}" | |
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository | |
env: | |
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}" | |
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}" | |
ORG_GRADLE_PROJECT_signingKey: "${{ secrets.SIGNING_KEY }}" | |
ORG_GRADLE_PROJECT_signingPassword: "${{ secrets.SIGNING_PASSWORD }}" | |
- name: Parse tag | |
if: "${{ github.event_name == 'push' && contains(github.ref, '-beta.') }}" | |
id: vars | |
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} | |
- name: Create changelog and Pre-Release | |
if: "${{ github.event_name == 'push' && contains(github.ref, '-beta.') }}" | |
uses: MC-Machinations/[email protected] | |
with: | |
token: ${{ secrets.RELEASE_TOKEN }} | |
title: CarbonChat ${{ steps.vars.outputs.tag }} | |
pre-release: true | |
files: | | |
build/libs/carbonchat-paper-*.jar | |
build/libs/carbonchat-velocity-*.jar | |
build/libs/carbonchat-fabric-*.jar | |
- name: Publish (Pre-)Release to Modrinth | |
if: "${{ env.STATUS == 'release' && github.event_name == 'release' }}" | |
run: ./gradlew :carbonchat-paper:modrinth :carbonchat-velocity:modrinth :carbonchat-fabric:modrinth | |
env: | |
MODRINTH_TOKEN: "${{ secrets.MODRINTH_TOKEN }}" | |
RELEASE_NOTES: "${{ github.event.release.body }}" | |
- name: Publish (Pre-)Release to Hangar | |
if: "${{ env.STATUS == 'release' && github.event_name == 'release' }}" | |
run: ./gradlew publishAllPublicationsToHangar | |
env: | |
HANGAR_UPLOAD_KEY: "${{ secrets.HANGAR_UPLOAD_KEY }}" | |
RELEASE_NOTES: "${{ github.event.release.body }}" | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Jars | |
path: build/libs/*.jar |