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, Publish to Updater, and Publish API Package | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: updater | |
if: ${{ !github.event.pull_request.head.repo.fork }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Build with Gradle | |
uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7 | |
with: | |
arguments: :shadowJar | |
- name: Upload build files artifact | |
uses: actions/upload-artifact@v2.3.1 | |
with: | |
# Artifact name | |
name: build-files | |
# A file, directory or wildcard pattern that describes what to upload | |
path: 'build/*' | |
# The desired behavior if no files are found using the provided path. | |
if-no-files-found: error | |
retention-days: 2 | |
# - name: Download changelogs | |
# run: | | |
# curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}" > changelogs.bb | |
# curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}&format=html" > changelogs.html | |
# - name: Deploy to Polymart | |
# env: | |
# POLYMART_TOKEN: ${{ secrets.POLYMART_TOKEN }} | |
# MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} | |
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
# run: | | |
# export VERSION=`cat build.gradle.kts | grep "version " | awk -F'"' '{print $2}'` | |
# file build/libs/ajLeaderboards-$VERSION.jar | |
# curl --no-progress-meter -F "file=@build/libs/ajLeaderboards-$VERSION.jar" -F api_key=$POLYMART_TOKEN -F resource_id="2726" -F version="$VERSION" -F title="v$VERSION" -F message="$(cat changelogs.bb)" "https://api.polymart.org/v1/postUpdate" | |
# curl --no-progress-meter -A "AJUPDATER/1.0" -H "Authorization: $MODRINTH_TOKEN" -F data="{\"project_id\": \"C9BKEl8Y\", \"version_number\": \"$VERSION\", \"name\": \"v$VERSION\", \"changelog\": \"$(cat changelogs.html)\", \"file_parts\": [\"file\"], \"version_type\": \"release\", \"loaders\": [\"paper\", \"spigot\"], \"featured\": true, \"game_versions\": $(curl https://ajg0702.us/pl/updater/mc-versions.php), \"dependencies\": [], \"primary_file\": \"file\"}" -F "file=@build/libs/ajLeaderboards-$VERSION.jar" "https://api.modrinth.com/v2/version" | |
# curl -v --no-progress-meter -H "Content-Type: application/json" --request POST -d "{\"content\": \"<@&861713403080999003>\", \"embeds\": [{\"title\": \"${{ github.event.repository.name }} v$VERSION\", \"description\": \"Changelogs\n\n$(curl "https://ajg0702.us/pl/updater/changelogs.php?project=${{ github.repository }}&format=markdown")\n\n[Modrinth](https://modrinth.com/plugin/ajleaderboards/version/$VERSION)\n[Polymart](https://polymart.org/resource/ajleaderboards.2726/updates)\", \"color\": 14845503, \"thumbnail\": {\"url\": \"https://ajg0702.us/pl/icons/${{ github.event.repository.name }}.png\"}}]}" "$DISCORD_WEBHOOK" | |
- name: Upload to updater (plugin-updates) | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
VERSION=`cat build.gradle.kts | grep "version " | awk -F'"' '{print $2}'` | |
cd build/libs/ | |
echo -n "{ \"message\": \"Plugin Update: $(echo ajLeaderboards-*.jar) (jar)\", \"content\": \"" > file_upload.json | |
base64 ajLeaderboards-*.jar >> file_upload.json | |
echo -n "\" }" >> file_upload.json | |
curl -X PUT -H "Authorization: Bearer $GH_TOKEN" -H "Content-Type: application/json" -d @file_upload.json "https://api.github.com/repos/ajgeiss0702/plugin-updates/contents/jars/free/$(echo ajLeaderboards*.jar)" | |
SHA=`curl -H "Authorization: Bearer $GH_TOKEN" -s "https://api.github.com/repos/ajgeiss0702/plugin-updates/contents/plugins/ajLeaderboards.json" | jq -r '.sha'` | |
NEW_JSON="{ \"latest\": \"$VERSION\", \"premium\": false }" | |
curl -X PUT -H "Authorization: Bearer $GH_TOKEN" -H "Content-Type: application/json" -d "{ \"message\": \"Plugin Update: $(echo ajLeaderboards-*.jar) (json)\", \"content\": \"$(echo $NEW_JSON | base64)\", \"sha\": \"$SHA\" }" "https://api.github.com/repos/ajgeiss0702/plugin-updates/contents/plugins/ajLeaderboards.json" | |
- name: Publish API to repo | |
env: | |
REPO_TOKEN: ${{ secrets.REPO_TOKEN }} | |
uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7 | |
with: | |
arguments: publish --stacktrace |