-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f786ae7
commit 550e156
Showing
1 changed file
with
12 additions
and
210 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,217 +13,19 @@ on: | |
- 'CurseForge' | ||
- 'Modrinth' | ||
- 'Github' | ||
- 'CurseForge and Modrinth' | ||
- 'CurseForge and Github' | ||
- 'Modrinth and Github' | ||
commitish: | ||
description: 'Commit id' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
BRANCH_NAME: "${{ github.ref_name }}" | ||
NAME: "BetterLineBreak" | ||
MODRINTH_ID: "zp6DtFf2" | ||
CURSEFORGE_ID: "960082" | ||
CURSEFORGE_FORGE_DEPENDENCIES: "" | ||
CURSEFORGE_FABRIC_DEPENDENCIES: | | ||
cloth-config(required) | ||
modmenu(required) | ||
# BetterLineBreakに限り、1.14.4かどうかで依存関係が変化する | ||
CURSEFORGE_FABRIC114_DEPENDENCIES: | | ||
cloth-config(required) | ||
modmenu(required) | ||
auto-config-updated-api(required) | ||
MODRINTH_FORGE_DEPENDENCIES: "" | ||
MODRINTH_FABRIC_DEPENDENCIES: | | ||
cloth-config(required) | ||
modmenu(required) | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # これが無いと正しくタグの存在を判定できない模様 | ||
|
||
- name: 環境変数の動的構築 | ||
run: | | ||
echo "MC_VERSION=${{ env.BRANCH_NAME }}" | sed "s/\/.*//" >> $GITHUB_ENV | ||
echo "MOD_LOADER=${{ env.BRANCH_NAME }}" | sed "s/=.*\//=/" >> $GITHUB_ENV | ||
cat "CHANGELOG.md" | tr -d '\r\n' | sed -r "s/[^-]*-[^-]*-([^]]*).*/RELEASE_VERSION=\1\n/" >> $GITHUB_ENV | ||
if [ -z "${{ github.event.inputs.commitish }}" ]; then | ||
echo "COMMITISH=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV | ||
else | ||
echo "COMMITISH=${{ github.event.inputs.commitish }}" >> $GITHUB_ENV | ||
fi | ||
- name: 環境変数の動的構築2 | ||
run: | | ||
echo "TAG_NAME=${{ env.MC_VERSION }}-${{ env.MOD_LOADER }}-${{ env.RELEASE_VERSION }}" >> $GITHUB_ENV | ||
- name: modの依存関係の動的構築 | ||
id: dependencies | ||
run: | | ||
{ | ||
echo 'CURSEFORGE<<EOF' | ||
if [[ "${{ env.MOD_LOADER }}" == fabric ]]; then | ||
# BetterLineBreakに限り、1.14.4かどうかで依存関係が変化する | ||
if [[ "${{ env.MC_VERSION }}" == 1.14.* ]]; then | ||
echo "${{ env.CURSEFORGE_FABRIC114_DEPENDENCIES }}" | ||
else | ||
echo "${{ env.CURSEFORGE_FABRIC_DEPENDENCIES }}" | ||
fi | ||
else | ||
echo "${{ env.CURSEFORGE_FORGE_DEPENDENCIES }}" | ||
fi | ||
echo -e "\nEOF" | ||
} >> $GITHUB_OUTPUT | ||
{ | ||
echo 'MODRINTH<<EOF' | ||
if [[ "${{ env.MOD_LOADER }}" == fabric ]]; then | ||
echo "${{ env.MODRINTH_FABRIC_DEPENDENCIES }}" | ||
else | ||
echo "${{ env.MODRINTH_FORGE_DEPENDENCIES }}" | ||
fi | ||
echo -e "\nEOF" | ||
} >> $GITHUB_OUTPUT | ||
- name: CHANGELOGの中身(先頭のみ)取得 | ||
id: changelog | ||
run: | | ||
{ | ||
echo 'CHANGELOG<<EOF' | ||
cat "CHANGELOG.md" | tr -d '\r\n' | awk 'BEGIN{FS="###"}{printf $2}' | sed -r -e "s/ \[[^)]*\) - ....-..-..//" -e "s/\.- /.\n- /g" | ||
echo -e "\nEOF" | ||
} >> $GITHUB_OUTPUT | ||
- name: Check properties | ||
run: | | ||
echo "MC_VERSION" "${{ env.MC_VERSION }}" | ||
echo "MOD_LOADER" "${{ env.MOD_LOADER }}" | ||
echo "RELEASE_VERSION" "${{ env.RELEASE_VERSION }}" | ||
echo "TAG_NAME" "${{ env.TAG_NAME }}" | ||
echo "COMMITISH" "${{ env.COMMITISH }}" | ||
echo "CHANGELOG" "${{ steps.changelog.outputs.CHANGELOG }}" | ||
echo "CURSEFORGE_DEPENDENCIES" "${{ steps.dependencies.outputs.CURSEFORGE }}" | ||
echo "MODRINTH_DEPENDENCIES" "${{ steps.dependencies.outputs.MODRINTH }}" | ||
if [[ "${{ env.MC_VERSION }}" != *"."* ]]; then | ||
echo 'Invalid MC version "${{ env.MC_VERSION }}", aborting workflow.' | ||
exit 1 | ||
fi | ||
if [ "${{ env.MOD_LOADER }}" != "forge" ] && [ "${{ env.MOD_LOADER }}" != "fabric" ]; then | ||
echo 'Invalid mod loader "${{ env.MOD_LOADER }}", aborting workflow.' | ||
exit 1 | ||
fi | ||
if [ -z "${{ env.RELEASE_VERSION }}" ]; then | ||
echo 'Invalid release version "${{ env.RELEASE_VERSION }}", aborting workflow.' | ||
exit 1 | ||
fi | ||
- name: Check if tag already exists | ||
if: ${{ contains(github.event.inputs.mod_platform, 'Github') }} | ||
run: | | ||
if git rev-parse --verify --quiet "${{ env.TAG_NAME }}"; then | ||
echo "Tag ${{ env.TAG_NAME }} already exists, aborting workflow." | ||
exit 1 | ||
fi | ||
# gradle.propertiesの書き換えはしないかも | ||
# - name: Set version | ||
# run: sed -i "s/modVersion.*=.*/modVersion = ${{ env.RELEASE_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.RELEASE_VERSION }}" | ||
# commit_options: '--no-verify' | ||
# file_pattern: gradle.properties | ||
# tagging_message: "v${{ env.RELEASE_VERSION }}" | ||
|
||
- name: Setup Build | ||
uses: ./.github/actions/build_setup | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build Project | ||
run: ./gradlew --scan --build-cache --info --stacktrace build | ||
|
||
- name: Publish to CurseForge and Modrinth and Github | ||
uses: Kir-Antipov/[email protected] | ||
if: ${{ github.event.inputs.mod_platform == 'CurseForge and Modrinth and Github' }} | ||
with: | ||
github-tag: "${{ env.TAG_NAME }}" | ||
github-generate-changelog: false | ||
github-commitish: "${{ env.COMMITISH }}" # タグを生成するブランチ | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
modrinth-id: "${{ env.MODRINTH_ID }}" | ||
modrinth-token: "${{ secrets.MODRINTH_API_KEY }}" | ||
modrinth-dependencies: "${{ steps.dependencies.outputs.MODRINTH }}" | ||
curseforge-id: "${{ env.CURSEFORGE_ID }}" | ||
curseforge-token: "${{ secrets.CURSEFORGE_API_KEY }}" | ||
curseforge-dependencies: "${{ steps.dependencies.outputs.CURSEFORGE }}" | ||
files: | | ||
build/libs/!(*-@(dev|sources|javadoc)).jar | ||
build/libs/*-@(sources).jar | ||
name: "${{ env.NAME }}-${{ env.MC_VERSION }}(${{ env.MOD_LOADER == 'forge' && 'Forge' || 'Fabric' }})-${{ env.RELEASE_VERSION }}" | ||
changelog: "${{ steps.changelog.outputs.CHANGELOG }}" | ||
version: "${{ env.RELEASE_VERSION }}" | ||
version-type: "release" | ||
loaders: "${{ env.MOD_LOADER }}" | ||
game-versions: "${{ env.MC_VERSION }}" | ||
java: "${{ startsWith(env.MC_VERSION, '1.16.') && '16\n17\n18' || (startsWith(env.MC_VERSION, '1.17.') || startsWith(env.MC_VERSION, '1.18.') || startsWith(env.MC_VERSION, '1.19.') || startsWith(env.MC_VERSION, '1.20.')) && '17\n18' || '8' }}" | ||
retry-attempts: 2 | ||
|
||
- name: Publish only to Curseforge | ||
uses: Kir-Antipov/[email protected] | ||
if: ${{ github.event.inputs.mod_platform == 'CurseForge' }} | ||
with: | ||
curseforge-id: "${{ env.CURSEFORGE_ID }}" | ||
curseforge-token: "${{ secrets.CURSEFORGE_API_KEY }}" | ||
curseforge-dependencies: "${{ steps.dependencies.outputs.CURSEFORGE }}" | ||
files: | | ||
build/libs/!(*-@(dev|sources|javadoc)).jar | ||
build/libs/*-@(sources).jar | ||
name: "${{ env.NAME }}-${{ env.MC_VERSION }}(${{ env.MOD_LOADER == 'forge' && 'Forge' || 'Fabric' }})-${{ env.RELEASE_VERSION }}" | ||
changelog: "${{ steps.changelog.outputs.CHANGELOG }}" | ||
version: "${{ env.RELEASE_VERSION }}" | ||
version-type: "release" | ||
loaders: "${{ env.MOD_LOADER }}" | ||
game-versions: "${{ env.MC_VERSION }}" | ||
java: "${{ startsWith(env.MC_VERSION, '1.16.') && '16\n17\n18' || (startsWith(env.MC_VERSION, '1.17.') || startsWith(env.MC_VERSION, '1.18.') || startsWith(env.MC_VERSION, '1.19.') || startsWith(env.MC_VERSION, '1.20.')) && '17\n18' || '8' }}" | ||
retry-attempts: 2 | ||
|
||
- name: Publish only to Modrinth | ||
uses: Kir-Antipov/[email protected] | ||
if: ${{ github.event.inputs.mod_platform == 'Modrinth' }} | ||
with: | ||
modrinth-id: "${{ env.MODRINTH_ID }}" | ||
modrinth-token: "${{ secrets.MODRINTH_API_KEY }}" | ||
modrinth-dependencies: "${{ steps.dependencies.outputs.MODRINTH }}" | ||
files: | | ||
build/libs/!(*-@(dev|sources|javadoc)).jar | ||
build/libs/*-@(sources).jar | ||
name: "${{ env.NAME }}-${{ env.MC_VERSION }}(${{ env.MOD_LOADER == 'forge' && 'Forge' || 'Fabric' }})-${{ env.RELEASE_VERSION }}" | ||
changelog: "${{ steps.changelog.outputs.CHANGELOG }}" | ||
version: "${{ env.RELEASE_VERSION }}" | ||
version-type: "release" | ||
loaders: "${{ env.MOD_LOADER }}" | ||
game-versions: "${{ env.MC_VERSION }}" | ||
java: "${{ startsWith(env.MC_VERSION, '1.16.') && '16\n17\n18' || (startsWith(env.MC_VERSION, '1.17.') || startsWith(env.MC_VERSION, '1.18.') || startsWith(env.MC_VERSION, '1.19.') || startsWith(env.MC_VERSION, '1.20.')) && '17\n18' || '8' }}" | ||
retry-attempts: 2 | ||
|
||
- name: Publish only to Github | ||
uses: Kir-Antipov/[email protected] | ||
if: ${{ github.event.inputs.mod_platform == 'Github' }} | ||
with: | ||
github-tag: "${{ env.TAG_NAME }}" | ||
github-generate-changelog: false | ||
github-commitish: "${{ env.COMMITISH }}" # タグを生成するブランチ | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
files: | | ||
build/libs/!(*-@(dev|sources|javadoc)).jar | ||
build/libs/*-@(sources).jar | ||
name: "${{ env.NAME }}-${{ env.MC_VERSION }}(${{ env.MOD_LOADER == 'forge' && 'Forge' || 'Fabric' }})-${{ env.RELEASE_VERSION }}" | ||
changelog: "${{ steps.changelog.outputs.CHANGELOG }}" | ||
version: "${{ env.RELEASE_VERSION }}" | ||
version-type: "release" | ||
retry-attempts: 2 | ||
call_publish_base: | ||
uses: KatatsumuriPan/KpansGitHubActions/.github/workflows/publish_base.yml@main | ||
with: | ||
mod_platform: "${{ github.event.inputs.mod_platform }}" | ||
commitish: "${{ github.event.inputs.commitish }}" | ||
secrets: | ||
PAT_GITHUB: ${{ secrets.PAT_GITHUB }} | ||
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_API_KEY }} | ||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_API_KEY }} |