Skip to content

Commit

Permalink
Merge pull request #2 from DrParadox7/master
Browse files Browse the repository at this point in the history
Implement ExampleMod from SinTh0r4s
  • Loading branch information
jss2a98aj committed Aug 2, 2023
2 parents 297abe3 + dcc392e commit cfbed60
Show file tree
Hide file tree
Showing 25 changed files with 1,360 additions and 26 deletions.
27 changes: 27 additions & 0 deletions .github/scripts/test-no-error-reports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
if [[ -d "run/crash-reports" ]]; then
echo "Crash reports detected:"
cat $directory/*
exit 1
fi

if grep --quiet "Fatal errors were detected" server.log; then
echo "Fatal errors detected:"
cat server.log
exit 1
fi

if grep --quiet "The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED" server.log; then
echo "Server force stopped:"
cat server.log
exit 1
fi

if grep --quiet 'Done .+ For help, type "help" or "?"' server.log; then
echo "Server didn't finish startup:"
cat server.log
exit 1
fi

echo "No crash reports detected"
exit 0

10 changes: 10 additions & 0 deletions .github/scripts/update-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if [ ! -z $(git diff --name-only HEAD HEAD~1 | grep build.gradle) ]; then
new_version="$(date +%s)"
sed --in-place "s!^//version:.*!//version: $new_version!g" build.gradle
git add build.gradle
git commit -m "[ci skip] update build script version to $new_version"
git push
echo "Updated buildscript version to $new_version";
else
echo "Ignored buildscript version update: no changes detected"
fi
45 changes: 45 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Build and test

on:
pull_request:
branches: [ master, main ]
push:
branches: [ master, main ]

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Setup the workspace
run: ./gradlew setupCIWorkspace

- name: Build the mod
run: ./gradlew build

- name: Run server for 1.5 minutes
run: |
mkdir run
echo "eula=true" > run/eula.txt
timeout 90 ./gradlew runServer | tee --append server.log || true
- name: Test no errors reported during server run
run: |
chmod +x .github/scripts/test-no-error-reports.sh
.github/scripts/test-no-error-reports.sh
24 changes: 24 additions & 0 deletions .github/workflows/buildscript-maintenance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This workflow only meant for the source mod you shouldn't bring it into your own project

name: Buildscript maintenance

on:
push:
branches: [ master, main ]

jobs:
buildscript-maintenance:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: setup git config
run: |
git config user.name "GitHub CI Bot"
git config user.email "<>"
- name: Ensure build script version is up to date
run: .github/scripts/update-version.sh
72 changes: 72 additions & 0 deletions .github/workflows/release-packages-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Release latest starter and migration packages

on:
push:
branches: [ master, main ]

jobs:
zip-and-release-packages:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Prepare release folder
run: |
mkdir packages
- name: Zip starter
uses: montudor/action-zip@v1
with:
args: >
zip -r packages/starter.zip . \
\
-x "*.git/*" \
\
-x ".github/scripts/update-version.sh" \
-x ".github/workflows/buildscript-maintenance.yml" \
-x ".github/workflows/release-packages-latest.yml" \
-x ".github/workflows/release-packages-tags.yml" \
\
-x "*docs/*" \
-x "README.md" \
-x "LICENSE" \
\
-x "starter.zip" \
-x "migration.zip"
- name: Zip migration
uses: montudor/action-zip@v1
with:
args: >
zip -r packages/migration.zip . \
\
-x "*.git/*" \
\
-x ".github/scripts/update-version.sh" \
-x ".github/workflows/buildscript-maintenance.yml" \
-x ".github/workflows/release-packages-latest.yml" \
-x ".github/workflows/release-packages-tags.yml" \
\
-x "*docs/*" \
-x "*src/*" \
-x "LICENSE" \
-x "README.md" \
\
-x "starter.zip" \
-x "migration.zip"
- name: Update latest tag
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest-packages"
prerelease: false
title: "Latest starter and migration packages"
files: packages/*
73 changes: 73 additions & 0 deletions .github/workflows/release-packages-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This workflow only meant for the source mod you shouldn't bring it into your own project

name: Release starter and migration packages

on:
push:
tags:
- '*'

jobs:
zip-and-release-packages:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Prepare release folder
run: |
mkdir packages
- name: Zip starter
uses: montudor/action-zip@v1
with:
args: >
zip -r packages/starter.zip . \
\
-x "*.git/*" \
\
-x ".github/scripts/update-version.sh" \
-x ".github/workflows/buildscript-maintenance.yml" \
-x ".github/workflows/release-packages-latest.yml" \
-x ".github/workflows/toolchain-compatibility.yml" \
\
-x "*docs/*" \
-x "README.md" \
-x "LICENSE" \
\
-x "starter.zip" \
-x "migration.zip"
- name: Zip migration
uses: montudor/action-zip@v1
with:
args: >
zip -r packages/migration.zip . \
\
-x "*.git/*" \
\
-x ".github/scripts/update-version.sh" \
-x ".github/workflows/buildscript-maintenance.yml" \
-x ".github/workflows/release-packages-latest.yml" \
-x ".github/workflows/release-packages-tags.yml" \
-x ".github/workflows/toolchain-compatibility.yml" \
\
-x "*docs/*" \
-x "*src/*" \
-x "LICENSE" \
-x "README.md" \
\
-x "starter.zip" \
-x "migration.zip"
- name: Release under current tag
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.RELEASE_VERSION }}-packages"
prerelease: false
title: "${{ env.RELEASE_VERSION }} starter and migration packages"
files: packages/*
61 changes: 61 additions & 0 deletions .github/workflows/release-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Release tagged build

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Setup the workspace
run: ./gradlew setupCIWorkspace

- name: Build the mod
run: ./gradlew build

- name: Release under current tag
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
prerelease: false
title: "${{ env.RELEASE_VERSION }}"
files: build/libs/*.jar

- name: Set repository owner and name
run: |
echo "REPOSITORY_OWNER=${GITHUB_REPOSITORY%/*}" >> $GITHUB_ENV
echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: Publish package
run: ./gradlew publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ARTIFACT_GROUP_ID: com.github.${{ env.REPOSITORY_OWNER }}
ARTIFACT_ID: "${{ env.REPOSITORY_NAME }}"
ARTIFACT_VERSION: "${{ env.RELEASE_VERSION }}"
REPOSITORY_NAME: "${{ env.REPOSITORY_NAME }}"
REPOSITORY_OWNER: "${{ env.REPOSITORY_OWNER }}"

31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.gradle
.settings
/.idea/
/run/
/build/
/eclipse/
.classpath
.project
/bin/
/config/
/crash-reports/
/logs/
options.txt
/saves/
usernamecache.json
banned-ips.json
banned-players.json
eula.txt
ops.json
server.properties
servers.dat
usercache.json
whitelist.json
/out/
*.iml
*.ipr
*.iws
src/main/resources/mixins.*.json
*.bat
*.DS_Store
!gradlew.bat
21 changes: 21 additions & 0 deletions LICENSE-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit cfbed60

Please sign in to comment.