Skip to content

fix: now it should be fixed #11

fix: now it should be fixed

fix: now it should be fixed #11

Workflow file for this run

name: Release Module
on:
push:
tags:
- '*-v*.*.*'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Setup repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 'latest'
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
cache: 'pnpm'
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Extract module info from tag
id: module_info
run: |
TAG=${GITHUB_REF#refs/tags/}
MODULE=$(echo $TAG | cut -d'-' -f1)
VERSION=$(echo $TAG | cut -d'v' -f2)
echo "module=$MODULE" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Extract module data from dist
id: module_data
run: |
MODULE="${{ steps.module_info.outputs.module }}"
DIST_PATH="modules/${MODULE}/dist"
if [ ! -d "$DIST_PATH" ]; then
echo "Error: dist directory not found at $DIST_PATH"
fi
if [ ! -f "$DIST_PATH/module.json" ]; then
echo "Error: module.json not found at $DIST_PATH"
fi
MODULE_ID=$(jq -r '.id' "$DIST_PATH/module.json")
MODULE_TITLE=$(jq -r '.title' "$DIST_PATH/module.json")
MODULE_DESCRIPTION=$(jq -r '.description' "$DIST_PATH/module.json")
echo "module_id=$MODULE_ID" >> $GITHUB_OUTPUT
echo "module_title=$MODULE_TITLE" >> $GITHUB_OUTPUT
echo "module_description=$MODULE_DESCRIPTION" >> $GITHUB_OUTPUT
echo "dist_path=$DIST_PATH" >> $GITHUB_OUTPUT
echo "Found module.json at $DIST_PATH/module.json"
- name: Update module.json for release
run: |
MODULE="${{ steps.module_info.outputs.module }}"
VERSION="${{ steps.module_info.outputs.version }}"
TAG="${{ steps.module_info.outputs.tag }}"
DIST_PATH="${{ steps.module_data.outputs.dist_path }}"
cd "$DIST_PATH"
jq --arg version "$VERSION" \
--arg tag "$TAG" \
--arg module "$MODULE" \
'.version = $version |
.manifest = "https://github.com/${{ github.repository }}/releases/download/latest/sounds/module.json" |
.download = "https://github.com/${{ github.repository }}/releases/download/\($tag)/\($module).zip"' \
module.json > module.json.tmp
mv module.json.tmp module.json
echo "Updated module.json with release URLs"
cat module.json
- name: Create module ZIP
run: |
MODULE="${{ steps.module_info.outputs.module }}"
DIST_PATH="${{ steps.module_data.outputs.dist_path }}"
(cd "$DIST_PATH" && zip -r "${MODULE}.zip" . -x "*.git*")
echo "Created $DIST_PATH/${MODULE}.zip"
ls -lh "$DIST_PATH/${MODULE}.zip"
- name: Create module release
uses: ncipollo/release-action@v1
with:
artifacts: |
${{ steps.module_data.outputs.dist_path }}/${{ steps.module_info.outputs.module }}.zip
${{ steps.module_data.outputs.dist_path }}/module.json
tag: ${{ steps.module_info.outputs.tag }}
name: "${{ steps.module_data.outputs.module_title }} v${{ steps.module_info.outputs.version }}"
makeLatest: false
body: |
${{ steps.module_data.outputs.module_description }}
## Installation
Use this manifest URL in Foundry VTT:
```
https://github.com/${{ github.repository }}/releases/download/${{ steps.module_info.outputs.tag }}/module.json
```
## Module Info
- **ID**: `${{ steps.module_data.outputs.module_id }}`
- **Version**: `${{ steps.module_info.outputs.version }}`
- name: Setup GitHub CLI
run: |
echo "${{ secrets.GH_TOKEN }}" | gh auth login --with-token
- name: Get latest release-index version
id: index_version
run: |
LATEST_INDEX=$(git tag -l "release-index-v*" | sort -V | tail -n1)
if [ -z "$LATEST_INDEX" ]; then
INDEX_VERSION=1
echo "Creating first release-index"
else
CURRENT_VERSION=$(echo $LATEST_INDEX | grep -oP '\d+$')
INDEX_VERSION=$((CURRENT_VERSION + 1))
echo "Incrementing from v$CURRENT_VERSION to v$INDEX_VERSION"
fi
INDEX_TAG="release-index-v${INDEX_VERSION}"
echo "version=$INDEX_VERSION" >> $GITHUB_OUTPUT
echo "tag=$INDEX_TAG" >> $GITHUB_OUTPUT
echo "previous_tag=$LATEST_INDEX" >> $GITHUB_OUTPUT
echo "New index tag: $INDEX_TAG"
- name: Prepare release-index files
run: |
MODULE="${{ steps.module_info.outputs.module }}"
PREVIOUS_TAG="${{ steps.index_version.outputs.previous_tag }}"
mkdir -p release-index
if [ -n "$PREVIOUS_TAG" ]; then
echo "Downloading previous release-index from $PREVIOUS_TAG"
gh release view "$PREVIOUS_TAG" --json assets --jq '.assets[].name' | grep '\.json$' | while read asset; do
echo "Downloading $asset"
gh release download "$PREVIOUS_TAG" -p "$asset" -D release-index/ || true
done
fi
echo "Adding/updating ${MODULE}.json"
cp "${{ steps.module_data.outputs.dist_path }}/module.json" "release-index/${MODULE}.json"
echo ""
echo "Release Index contents:"
ls -1 release-index/*.json 2>/dev/null | while read file; do
MODULE_NAME=$(basename "$file" .json)
MODULE_VERSION=$(jq -r '.version' "$file")
MODULE_TITLE=$(jq -r '.title' "$file")
echo "${MODULE_NAME}.json - $MODULE_TITLE v$MODULE_VERSION"
done
- name: Create release-index release
uses: ncipollo/release-action@v1
with:
artifacts: "release-index/*.json"
tag: ${{ steps.index_version.outputs.tag }}
name: "📚 Release Index v${{ steps.index_version.outputs.version }}"
makeLatest: true
body: |
Updated with: **${{ steps.module_data.outputs.module_title }}** v${{ steps.module_info.outputs.version }}