Skip to content

Commit

Permalink
Switch to centralized GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kas-tle authored May 27, 2024
1 parent 9463e1e commit 24e9ee6
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 50 deletions.
81 changes: 39 additions & 42 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,71 +13,68 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
PROJECT: 'geyserconnect'

steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
- name: Checkout repository
# See https://github.com/actions/checkout/commits
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Validate Gradle Wrapper
# See https://github.com/gradle/wrapper-validation-action/commits
uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2

- name: Setup Java
# See https://github.com/actions/setup-java/commits
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 17
distribution: temurin

- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Gradle
# See https://github.com/gradle/actions/commits
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
with:
gradle-home-cache-cleanup: true

- name: Build GeyserConnect
uses: gradle/gradle-build-action@v2
with:
arguments: build
run: ./gradlew build

- name: Archive artifacts
uses: actions/upload-artifact@v3
# See https://github.com/actions/upload-artifact/commits
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: success()
with:
name: GeyserConnect
path: build/libs/GeyserConnect.jar

if-no-files-found: error

- name: Get Version
if: ${{ success() && github.repository == 'GeyserMC/GeyserConnect' && github.ref_name == 'master' }}
id: get-version
run: |
version=$(cat build.gradle | grep -o "version '[0-9\\.]*'" | cut -d" " -f2 | sed "s/'//g")
echo "VERSION=${version}" >> $GITHUB_OUTPUT
- name: Get Release Metadata
if: ${{ success() && github.repository == 'GeyserMC/GeyserConnect' && github.ref_name == 'master' }}
uses: Kas-tle/base-release-action@b863fa0f89bd15267a96a72efb84aec25f168d4c # https://github.com/Kas-tle/base-release-action/releases/tag/main-11
uses: GeyserMC/actions/release@master
id: metadata
with:
appID: ${{ secrets.RELEASE_APP_ID }}
appPrivateKey: ${{ secrets.RELEASE_APP_PK }}
files: |
geyserconnect:build/libs/GeyserConnect.jar
releaseEnabled: false
saveMetadata: true

- name: Update Generated Metadata
if: ${{ success() && github.repository == 'GeyserMC/GeyserConnect' && github.ref_name == 'master' }}
run: |
cat metadata.json
echo
mv metadata.json metadata.json.tmp
version=$(cat build.gradle | grep -o "version '[0-9\\.]*'" | cut -d" " -f2 | sed "s/'//g")
jq --arg project "${PROJECT}" --arg version "${version}" '
.
| .changes |= map({"commit", "summary", "message"})
| .downloads |= map_values({"name", "sha256"})
| {$project, "repo", $version, "number": .build, "changes", "downloads"}
' metadata.json.tmp > metadata.json
cat metadata.json
releaseProject: 'geyserconnect'
releaseVersion: ${{ steps.get-version.outputs.VERSION }}

- name: Publish to Downloads API
if: ${{ success() && github.repository == 'GeyserMC/GeyserConnect' && github.ref_name == 'master' }}
shell: bash
env:
DOWNLOADS_USERNAME: ${{ vars.DOWNLOADS_USERNAME }}
DOWNLOADS_PRIVATE_KEY: ${{ secrets.DOWNLOADS_PRIVATE_KEY }}
DOWNLOADS_SERVER_IP: ${{ secrets.DOWNLOADS_SERVER_IP }}
run: |
# Save the private key to a file
echo "$DOWNLOADS_PRIVATE_KEY" > id_ecdsa
chmod 600 id_ecdsa
# Create the build folder
ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP mkdir -p "~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/"
# Copy over artifacts
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" build/libs/GeyserConnect.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/
# Run the build script
rsync -P -e "ssh -o StrictHostKeyChecking=no -i id_ecdsa" metadata.json $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/uploads/$PROJECT/$GITHUB_RUN_NUMBER/
uses: GeyserMC/actions/upload-release@master
with:
username: ${{ vars.DOWNLOADS_USERNAME }}
privateKey: ${{ secrets.DOWNLOADS_PRIVATE_KEY }}
host: ${{ secrets.DOWNLOADS_SERVER_IP }}
files: |
build/libs/GeyserConnect.jar
28 changes: 20 additions & 8 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,35 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
- name: Checkout repository
# See https://github.com/actions/checkout/commits
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: Validate Gradle Wrapper
# See https://github.com/gradle/wrapper-validation-action/commits
uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2

- name: Setup Java
# See https://github.com/actions/setup-java/commits
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 17
distribution: temurin

- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Gradle
# See https://github.com/gradle/actions/commits
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
with:
cache-read-only: true

- name: Build GeyserConnect
uses: gradle/gradle-build-action@v2
with:
arguments: build
run: ./gradlew build

- name: Archive artifacts
uses: actions/upload-artifact@v3
# See https://github.com/actions/upload-artifact/commits
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: success()
with:
name: GeyserConnect
path: build/libs/GeyserConnect.jar
if-no-files-found: error

0 comments on commit 24e9ee6

Please sign in to comment.