Skip to content

Commit

Permalink
publish.ymlのバグ修正&強化
Browse files Browse the repository at this point in the history
  • Loading branch information
KatatsumuriPan committed Feb 2, 2024
1 parent 6542b34 commit 00de498
Showing 1 changed file with 84 additions and 33 deletions.
117 changes: 84 additions & 33 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ on:
mod_platform:
description: 'Mod platform'
type: choice
default: 'CurseForge and Modrinth'
default: 'CurseForge and Modrinth and Github'
options:
- 'CurseForge and Modrinth'
- 'CurseForge and Modrinth and Github'
- 'CurseForge'
- 'Modrinth'
- 'Github'
commitish:
description: 'Commit id'

jobs:
build:
Expand All @@ -21,28 +24,68 @@ jobs:
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 #これが無いと正しくタグの存在を判定できない模様
fetch-depth: 0 # これが無いと正しくタグの存在を判定できない模様

- name: 環境変数の動的定義
- 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/" >> $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
- name: 環境変数の動的構築2
run: |
echo "TAG_NAME=${{ env.MC_VERSION }}-${{ env.MOD_LOADER }}-${{ env.RELEASE_VERSION }}" >> $GITHUB_ENV
- name: modの依存関係の動的定義
- name: modの依存関係の動的構築
id: dependencies
run: |
echo "CURSEFORGE_DEPENDENCIES=${{ env.MOD_LOADER == 'fabric' && (startsWith(env.MC_VERSION, '1.14.') && 'cloth-config(required)\nmodmenu(required)\nauto-config-updated-api(required)' || 'cloth-config(required)\nmodmenu(required)') || '' }}" >> $GITHUB_ENV
echo "MODRINTH_DEPENDENCIES=${{ env.MOD_LOADER == 'fabric' && 'cloth-config(required)\nmodmenu(required)' || '' }}" >> $GITHUB_ENV
{
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の中身保存
- name: CHANGELOGの中身(先頭のみ)取得
id: changelog
run: |
{
Expand All @@ -57,9 +100,10 @@ jobs:
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" "${{ env.CURSEFORGE_DEPENDENCIES }}"
echo "MODRINTH_DEPENDENCIES" "${{ env.MODRINTH_DEPENDENCIES }}"
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
Expand All @@ -74,6 +118,7 @@ jobs:
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."
Expand Down Expand Up @@ -102,27 +147,26 @@ jobs:
- name: Build Project
run: ./gradlew --scan --build-cache --info --stacktrace build

- name: Publish to Curseforge and Modrinth
- name: Publish to CurseForge and Modrinth and Github
uses: Kir-Antipov/mc-publish@v3.3
if: ${{ github.event.inputs.mod_platform == 'CurseForge and Modrinth' }}
if: ${{ github.event.inputs.mod_platform == 'CurseForge and Modrinth and Github' }}
with:
github-tag: "${{ env.TAG_NAME }}"
github-generate-changelog: false
github-draft: false
github-prerelease: false
github-commitish: "${{ env.COMMITISH }}" # タグを生成するブランチ
github-token: "${{ secrets.GITHUB_TOKEN }}"
modrinth-id: "${{ env.MODRINTH_ID }}"
modrinth-token: "${{ secrets.MODRINTH_API_KEY }}"
modrinth-dependencies: "${{ env.MODRINTH_DEPENDENCIES }}"
modrinth-dependencies: "${{ steps.dependencies.outputs.MODRINTH }}"
curseforge-id: "${{ env.CURSEFORGE_ID }}"
curseforge-token: "${{ secrets.CURSEFORGE_API_KEY }}"
curseforge-dependencies: "${{ env.CURSEFORGE_DEPENDENCIES }}"
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.MC_VERSION }}"
version: "${{ env.RELEASE_VERSION }}"
version-type: "release"
loaders: "${{ env.MOD_LOADER }}"
game-versions: "${{ env.MC_VERSION }}"
Expand All @@ -133,20 +177,15 @@ jobs:
uses: Kir-Antipov/mc-publish@v3.3
if: ${{ github.event.inputs.mod_platform == 'CurseForge' }}
with:
github-tag: "${{ env.TAG_NAME }}"
github-generate-changelog: false
github-draft: false
github-prerelease: false
github-token: "${{ secrets.GITHUB_TOKEN }}"
curseforge-id: "${{ env.CURSEFORGE_ID }}"
curseforge-token: "${{ secrets.CURSEFORGE_API_KEY }}"
curseforge-dependencies: "${{ env.CURSEFORGE_DEPENDENCIES }}"
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.MC_VERSION }}"
version: "${{ env.RELEASE_VERSION }}"
version-type: "release"
loaders: "${{ env.MOD_LOADER }}"
game-versions: "${{ env.MC_VERSION }}"
Expand All @@ -157,22 +196,34 @@ jobs:
uses: Kir-Antipov/mc-publish@v3.3
if: ${{ github.event.inputs.mod_platform == 'Modrinth' }}
with:
github-tag: "${{ env.TAG_NAME }}"
github-generate-changelog: false
github-draft: false
github-prerelease: false
github-token: "${{ secrets.GITHUB_TOKEN }}"
modrinth-id: "${{ env.MODRINTH_ID }}"
modrinth-token: "${{ secrets.MODRINTH_API_KEY }}"
modrinth-dependencies: "${{ env.MODRINTH_DEPENDENCIES }}"
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.MC_VERSION }}"
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/mc-publish@v3.3
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

0 comments on commit 00de498

Please sign in to comment.