Merge pull request #73 from IntellectualSites/renovate/gradle-8.x #267
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 ClipboardConnect | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- labeled | |
jobs: | |
build: | |
# Run on all label events (won't be duplicated) or all push events or on PR syncs not from the same repo | |
if: github.repository_owner == 'IntellectualSites' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Validate Gradle Wrapper | |
uses: gradle/wrapper-validation-action@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
cache: gradle | |
java-version: 21 | |
- name: Clean Build | |
run: ./gradlew clean shadowJar | |
- name: Determine release status | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then | |
echo "STATUS=snapshot" >> $GITHUB_ENV | |
else | |
echo "STATUS=release" >> $GITHUB_ENV | |
fi | |
- name: Archive Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ClipboardConnect Archive | |
path: build/libs/ClipboardConnect-*.jar | |
- name: Publish to hangar | |
if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/main'}} | |
run: ./gradlew publishAllPublicationsToHangar --no-daemon | |
env: | |
HANGAR_SECRET: ${{secrets.HANGAR_KEY}} | |
HANGAR_CHANNEL: "Release" | |
- name: Publish to hangar snapshot | |
if: ${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/main'}} | |
run: ./gradlew publishAllPublicationsToHangar --no-daemon | |
env: | |
HANGAR_SECRET: ${{secrets.HANGAR_KEY}} | |
HANGAR_CHANNEL: "Snapshot" | |
- name: Publish to Modrinth | |
if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/main'}} | |
run: ./gradlew modrinth --no-daemon | |
env: | |
MODRINTH_TOKEN: ${{ secrets.MODRINTH_KEY }} | |
MODRINTH_CHANNEL: "release" | |
SHA_SHORT: ${{steps.vars.outputs.sha_short}} | |
- name: Publish to Modrinth Snapshot | |
if: ${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/main'}} | |
run: ./gradlew modrinth --no-daemon | |
env: | |
MODRINTH_TOKEN: ${{ secrets.MODRINTH_KEY }} | |
MODRINTH_CHANNEL: "beta" |