Skip to content

Workflow file for this run

name: Attach avatars to release assets
on:
release:
types:
- released
- prereleased
jobs:
get_avatar_branches:
name: Get avatar branches
uses: ./.github/workflows/get_target_branches.yml
with:
include_base: false
generate_readme:
name: Generate readme.txt
needs: get_avatar_branches
runs-on: ubuntu-latest
strategy:
matrix:
target_branch: ${{ fromJSON(needs.get_avatar_branches.outputs.target_branches) }}
steps:
- name: Checkout avatar repository
uses: actions/[email protected]
with:
path: ./avatar
ref: ${{ matrix.target_branch }}
- name: Checkout generator repository
uses: actions/[email protected]
with:
repository: Gakuto1112/FiguraAvatarsReadmeTemplate
path: ./generator
- name: Checkout packer repository
uses: actions/[email protected]
with:
repository: Gakuto1112/MyFiguraAvatarPacker
path: ./packer
- name: Setup [email protected]
uses: actions/[email protected]
with:
node-version: 20.12.0
cache: npm
cache-dependency-path: ./packer/package-lock.json
- name: Install dependencies
working-directory: ./packer
run: npm install
- name: Generate readme.txt
working-directory: ./packer/src
run: ../node_modules/.bin/ts-node ./readme_txt_generator.ts FiguraBlueArchiveCharacters ${TAG_NAME} ${RELEASE_DATE} true ${BRANCH_NAME}
env:
TAG_NAME: ${{ github.ref_name }}
RELEASE_DATE: ${{ github.event.release.created_at }}
BRANCH_NAME: ${{ matrix.target_branch }}
- name: Upload artifacts
uses: actions/[email protected]
with:
name: readme_${{ matrix.target_branch }}
path: ./out
retention-days: 1
pack_avatar:
name: Pack avatar
needs:
- get_avatar_branches
- generate_readme
runs-on: ubuntu-latest
strategy:
matrix:
target_branch: ${{ fromJSON(needs.get_avatar_branches.outputs.target_branches) }}
steps:
- name: Checkout
uses: actions/[email protected]
with:
ref: ${{ matrix.target_branch }}
- name: Prepare output directory
run: |
mkdir ./out
mkdir ./out/${AVATAR_NAME}
mkdir ./out/${AVATAR_NAME}/models
env:
AVATAR_NAME: ${{ matrix.target_branch }}
- name: Remove reference images from model files
run: |
for model_file in $(ls -1 ./models | grep '.bbmodel')
do
cat ./models/${model_file} | jq 'del(.reference_images)' | jq '.textures[].path = ""' > ./out/${AVATAR_NAME}/models/${model_file}
done
env:
AVATAR_NAME: ${{ matrix.target_branch }}
- name: Move necessary files
run: |
mv ./scripts ./out/${AVATAR_NAME}/scripts
mv ./textures ./out/${AVATAR_NAME}/textures
mv ./avatar.json ./out/${AVATAR_NAME}/avatar.json
mv ./avatar.png ./out/${AVATAR_NAME}/avatar.png
mv ./LICENSE ./out/LICENSE
env:
AVATAR_NAME: ${{ matrix.target_branch }}
- name: Replace script placeholders
run: |
sed "s/instance\.FBAC_VERSION\s=\s\".*\"/instance.FBAC_VERSION = \"${TAG_NAME}\"/g" ./out/${AVATAR_NAME}/scripts/avatar_modules/action_wheel/update_checker.lua > ./out/${AVATAR_NAME}/scripts/avatar_modules/action_wheel/tmp1.lua
sed "s/instance\.BRANCH_NAME\s=\s\".*\"/instance.BRANCH_NAME = \"${AVATAR_NAME}\"/g" ./out/${AVATAR_NAME}/scripts/avatar_modules/action_wheel/tmp1.lua > ./out/${AVATAR_NAME}/scripts/avatar_modules/action_wheel/tmp2.lua
rm ./out/${AVATAR_NAME}/scripts/avatar_modules/action_wheel/update_checker.lua
rm ./out/${AVATAR_NAME}/scripts/avatar_modules/action_wheel/tmp1.lua
mv ./out/${AVATAR_NAME}/scripts/avatar_modules/action_wheel/tmp2.lua ./out/${AVATAR_NAME}/scripts/avatar_modules/action_wheel/update_checker.lua
env:
TAG_NAME: ${{ github.ref_name }}
AVATAR_NAME: ${{ matrix.target_branch }}
- name: Download artifacts
uses: actions/[email protected]
with:
name: readme_${{ matrix.target_branch }}
path: ./readmes
- name: Move readme
run: |
mv ./readmes/README.txt ./out/README.txt
mv ./readmes/お読みください.txt ./out/お読みください.txt
- name: Upload artifact
uses: actions/[email protected]
with:
name: avatar_${{ matrix.target_branch }}
path: ./out
attach_avatar:
name: Attach avatars to release assets
needs: pack_avatar
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/[email protected]
with:
path: ./
pattern: avatar_*
- name: Prepare output directory
run: mkdir ./out
- name: Zip artifacts
run: |
for model_file in $(ls -1 | grep 'avatar_')
do
cd ./${model_file}
zip -r ../out/$(echo ${model_file} | sed 's/avatar_//').zip ./
cd ../
done
- name: Attach artifacts to release assets
run: |
for zip_file in $(ls -1)
do
gh release upload ${TAG_NAME} ./${zip_file} --repo ${REPOSITORY}
done
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.event.release.tag_name }}
REPOSITORY: ${{ github.repository }}
working-directory: ./out