Skip to content

Build and Release MCPACK #36

Build and Release MCPACK

Build and Release MCPACK #36

name: Build and Release MCPACK
on:
workflow_dispatch:
inputs:
tag_name:
description: "The tag name for the release"
required: true
default: "1.0.0"
type: string
release_message:
description: "The message for the release (use \\n for line breaks)"
required: true
default: "Release message"
type: string
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Clean up unnecessary files
run: |
mkdir -p build
rsync -av \
--exclude='build' \
--exclude='.git/' \
--exclude='.github/' \
--exclude='.gitignore' \
--exclude='README.md' \
--exclude='pnpm--lock.json' \
--exclude='package.json' \
--exclude='versions.json' \
--exclude='src/' \
--exclude='tsconfig.json' \
./ build/
- name: Create MCPACK
run: |
VERSION="${{ github.event.inputs.tag_name }}"
cd build
zip -r "../NoteBlockPlus_${VERSION}.mcpack" ./*
# 改行対応メッセージを準備
- name: Prepare release message
id: prep_msg
run: |
RELEASE_MSG="${{ github.event.inputs.release_message }}"
RELEASE_MSG=$(echo "$RELEASE_MSG" | sed 's/\\n/\n/g')
echo "message<<EOF" >> $GITHUB_OUTPUT
echo "$RELEASE_MSG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag_name }}
name: ${{ github.event.inputs.tag_name }}
body: ${{ steps.prep_msg.outputs.message }}
draft: false
prerelease: false
files: NoteBlockPlus_${{ github.event.inputs.tag_name }}.mcpack
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify Discord (Embed + Buttons + Mention)
run: |
PAYLOAD=$(jq -n \
--arg mention "<@&${{secrets.DISCORD_NOTIFY_ROLE_ID}}>" \
--arg title "📦 NoteBlockPlusのアップデート" \
--arg desc "${{ steps.prep_msg.outputs.message }}" \
--arg version "${{ github.event.inputs.tag_name }}" \
--arg url_changes "https://github.com/${{ github.repository }}/releases/tag/${{ github.event.inputs.tag_name }}" \
--arg url_issues "https://github.com/${{ github.repository }}/issues" \
--arg url_download "https://go.oasoobi.net/NoteBlockPlus" \
--arg time "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
'{
content: $mention,
embeds: [
{
title: $title,
description: $desc,
color: 8999977,
fields: [
{ name: "バージョン", value: ("`" + $version + "`"), inline: true }
],
timestamp: $time
}
],
components: [
{
type: 1,
components: [
{ type: 2, style: 5, label: "ダウンロード", url: $url_download, emoji: { "name": "📥" } },
{ type: 2, style: 5, label: "変更点を見る", url: $url_changes, emoji: { "name": "📋" } },
{ type: 2, style: 5, label: "問題を報告", url: $url_issues, emoji: { "name": "📢" } }
]
}
]
}'
)
curl -H "Content-Type: application/json" \
-X POST \
-d "$PAYLOAD" \
${{ secrets.DISCORD_WEBHOOK_URL }}