Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自動デプロイなどを追加 #1

Merged
merged 4 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/ISSUE_TEMPLATE/000-report-bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 'Report Bug'
description: "Report a bug that does not abruptly end a game session or prevent the start of the game."
labels:
- "bug"
body:
- type: input
id: version
attributes:
label: Mod Version
description: Have you checked that the version you are playing is up-to-date before reporting? In some cases, a newer version may have been released, and the bug you are reporting may have been resolved.
placeholder: "v1.0.0"
validations:
required: true
- type: input
id: log
attributes:
label: Error Log
description: Please provide a link to the error log. I recommend [https://mclo.gs/](https://mclo.gs/)
placeholder: "https://mclo.gs/xxxxxxxx"
- type: dropdown
id: playmode
attributes:
label: SinglePlay or Server?
description: How are you playing with this mod?
options:
- Single Player
- Multi Player
- "Don't know"
validations:
required: true
- type: textarea
id: expectation
attributes:
label: Your Expectation
description: What did you try to do, and what did you expect to happen? Attach screenshots if needed.
placeholder: "Example: Trying to craft Foo. Expect to consume 1 Bar and get 1 Foo."
validations:
required: true
- type: textarea
id: actual
attributes:
label: The Reality
description: What happened instead? Attach screenshots if needed.
placeholder: "Example: 1 Foo is crafted but no Bar is consumed."
validations:
required: true
33 changes: 33 additions & 0 deletions .github/actions/build_setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build Setup
description: Setup for standard Java builds

inputs:
update-cache:
description: If cache should be updated
required: false
default: 'false'

runs:
using: 'composite'

steps:
- name: Set up JDK 8 and 17
uses: actions/setup-java@v4
with:
cache: gradle
distribution: 'zulu'
java-version: |
8
17

- name: Setup Gradle
uses: gradle/gradle-build-action@v3
with:
cache-write-only: ${{ inputs.update-cache }}
generate-job-summary: false
gradle-home-cache-includes: |
caches
caches/retro_futura_gradle
notifications
jdks
wrapper
101 changes: 101 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Build and test the mod
name: Build and test

on:
workflow_dispatch:
inputs:
timeout:
description: 'Timeout for runServer (seconds)'
required: false
default: 90
type: number
client-only:
description: 'Do not execute runServer'
required: false
default: false
type: boolean

concurrency:
group: build-and-test-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
build-and-test:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Apply patch to settings.gradle
run: |
if [ -f settings.gradle.patch ]; then
patch -p0 < settings.gradle.patch
fi

- name: Apply patch to gradle.properties
run: sed -i 's/debug_all = false/debug_all = true/g' gradle.properties

- name: Setup Build
uses: ./.github/actions/build_setup

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

- name: Compile the mod
run: ./gradlew --info --scan assemble

- name: Upload Jars
uses: actions/upload-artifact@v4
with:
name: GTExpert-Core
path: build/libs/*.jar
retention-days: 31

- name: Run post-build checks
id: build_mod
run: ./gradlew --info build

- name: Attempt to make a PR fixing spotless errors
if: ${{ failure() && steps.build_mod.conclusion == 'failure' && github.event_name == 'pull_request' && !github.event.pull_request.draft }}
run: |
git reset --hard
git checkout "${PR_BRANCH}"
./gradlew --info spotlessApply || exit 1
git diff --exit-code && exit 1
git config user.name "GitHub Actions"
git config user.email "<>"
git switch -c "${FIXED_BRANCH}"
git commit -am "spotlessApply"
git push --force-with-lease origin "${FIXED_BRANCH}"
gh pr create \
--head "${FIXED_BRANCH}" \
--base "${PR_BRANCH}" \
--title "Spotless apply for branch ${{ github.event.pull_request.head.ref }} for #${{ github.event.pull_request.number }}" \
--body "Automatic spotless apply to fix formatting errors, applies to PR #${{ github.event.pull_request.number }}" \
2>&1 | tee pr-message.log || true
gh pr comment "${PR_BRANCH}" -F pr-message.log || true
shell: bash # ensures set -eo pipefail
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_BRANCH: ${{ github.head_ref }}
FIXED_BRANCH: ${{ github.head_ref }}-spotless-fixes

- name: Run server for ${{ inputs.timeout }} seconds
if: ${{ !inputs.client-only }}
run: |
mkdir -p run
echo "eula=true" > run/eula.txt
# Set a constant seed with a village at spawn
echo "stop" > run/stop.txt
timeout ${{ inputs.timeout }} ./gradlew runServer 2>&1 < run/stop.txt | tee -a server.log || true

- name: Test no errors reported during server run
if: ${{ !inputs.client-only }}
run: |
chmod +x ./scripts/test_no_error_reports.sh
./scripts/test_no_error_reports.sh
43 changes: 43 additions & 0 deletions .github/workflows/buildscript-maintenance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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 ]
paths:
- build.gradle
- settings.gradle
workflow_dispatch: { }

jobs:
buildscript-maintenance:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Ensure build script version is up to date
id: update-buildscript
run: |
new_version="$(date +%s)"
sed --in-place "1s!^//version:.*!//version: $new_version!g" build.gradle
echo "::set-output name=new_version::$new_version"

- name: Create Pull Request
id: create-pull-request
uses: peter-evans/create-pull-request@v6
env:
GITHUB_TOKEN: ${{ secrets.BUILDSCRIPT_MAINTENANCE_TOKEN }}
with:
token: ${{ secrets.BUILDSCRIPT_MAINTENANCE_TOKEN }}
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
add-paths: build.gradle
commit-message: '[ci skip] update build script version to ${{ steps.update-buildscript.outputs.new_version }}'
branch: gha-buildscript-maintenance
title: Update build script version to ${{ steps.update-buildscript.outputs.new_version }}
body: This pull request is created by the buildscript-maintenance workflow
65 changes: 65 additions & 0 deletions .github/workflows/format_java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Runs formatting requirements
name: Java Formatting

on:
push:
branches:
- master
paths: ['src/main/java/**', 'src/test/**']
pull_request:
paths: ['src/main/java/**', 'src/test/**']

concurrency:
group: format-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
formatting:
name: Formatting
runs-on: ubuntu-latest

permissions:
pull-requests: write
contents: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Setup Build
uses: ./.github/actions/build_setup

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

- name: Run Spotless Formatting Check with Gradle
id: build
run: ./gradlew --info spotlessCheck

- name: Attempt to make a PR fixing spotless errors
if: failure()
run: |
git reset --hard
git checkout "${PR_BRANCH}"
./gradlew --info spotlessApply || exit 1
git diff --exit-code && exit 1
git config user.name "GitHub Actions"
git config user.email "<>"
git switch -c "${FIXED_BRANCH}"
git commit -am "spotlessApply"
git push --force-with-lease origin "${FIXED_BRANCH}"
gh pr create \
--head "${FIXED_BRANCH}" \
--base "${PR_BRANCH}" \
--title "Spotless apply for branch ${PR_BRANCH} for #${PR_NUMBER}" \
--body "Automatic spotless apply to fix formatting errors, applies to PR #${PR_NUMBER}" \
2>&1 | tee pr-message.log || true
gh pr comment "${PR_BRANCH}" -F pr-message.log || true
shell: bash # ensures set -eo pipefail
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
PR_NUMBER: ${{ github.event.pull_request.number }}
FIXED_BRANCH: ${{ github.head_ref }}-spotless-fixes
104 changes: 104 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Publishes the project to GitHub Releases, CurseForge, and Modrinth
name: Publish Project

on:
workflow_dispatch:
inputs:
version:
description: 'Mod version'
required: true
release_type:
description: 'Release type'
type: choice
default: 'beta'
options:
- 'release'
- 'beta'
- 'alpha'

env:
# link to the changelog with a format code for the version
CHANGELOG_LOCATION: "Changelog is available [here](https://github.com/${{ github.repository }}/releases/tag/GTExpertCore-v${{ github.event.inputs.version }}-${{ github.event.inputs.release_type }})"
# Version of the mod
FULL_VERSION: "${{ github.event.inputs.version }}-${{ github.event.inputs.release_type }}"
# type of release
NAME: "ImplosionNoBomb"

# Curseforge and Modrinth project IDs
CURSEFORGE_PROJECT_ID: "1094386"
#MODRINTH_PROJECT_ID: "LRBGeIQP"

concurrency:
group: publish-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
publish:
name: Publish
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Check if tag already exists
run: |
if git rev-parse --verify --quiet "v${{ github.event.inputs.version }}"; then
echo "Version ${{ github.event.inputs.version }} already exists, aborting workflow."
exit 1
fi

- name: Set version
run: sed -i "s/modVersion.*=.*/modVersion = ${{ env.FULL_VERSION }}/g" gradle.properties

- name: Commit and push gradle.properties
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Bump version to v${{ env.FULL_VERSION }}"
commit_options: '--no-verify'
file_pattern: gradle.properties
tagging_message: "v${{ env.FULL_VERSION }}"

- name: Setup Build
uses: ./.github/actions/build_setup

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

- name: Build Project
run: ./gradlew --info build

- name: Publish to Curseforge and Modrinth
uses: Kir-Antipov/[email protected]
with:
github-tag: "v${{ env.FULL_VERSION }}"
github-generate-changelog: true
github-draft: false
github-prerelease: false
github-token: ${{ secrets.GITHUB_TOKEN }}
#modrinth-id: ${{ env.MODRINTH_PROJECT_ID }}
#modrinth-token: "${{ secrets.MODRINTH_API_KEY }}"
#modrinth-dependencies: |
# tULldUx4(required)
curseforge-id: ${{ env.CURSEFORGE_PROJECT_ID }}
curseforge-token: "${{ secrets.CURSEFORGE_API_KEY }}"
curseforge-dependencies: |
gregtech-ce-unofficial(required)
files: |
build/libs/!(*-@(dev|sources|javadoc)).jar
build/libs/*-@(sources).jar
build/libs/*-@(dev).jar
name: "${{ env.NAME }}-${{ env.FULL_VERSION }}.jar"
changelog: "Changelog is available [here](https://github.com/${{github.repository}}/blob/master/CHANGELOG.md)"
version: "${{ github.event.inputs.version }}"
version-type: "${{ github.event.inputs.release_type }}"
loaders: |
forge
game-versions: |
1.12.2
java: |
8
retry-attempts: 2
Loading
Loading