|
| 1 | +name: Release Module |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*-v*.*.*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Setup repo |
| 13 | + uses: actions/checkout@v3 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + |
| 17 | + - name: Setup pnpm |
| 18 | + uses: pnpm/action-setup@v2 |
| 19 | + with: |
| 20 | + version: 'latest' |
| 21 | + |
| 22 | + - name: Setup Node.js |
| 23 | + uses: actions/setup-node@v3 |
| 24 | + with: |
| 25 | + node-version: '22' |
| 26 | + cache: 'pnpm' |
| 27 | + |
| 28 | + - name: Get pnpm store directory |
| 29 | + id: pnpm-cache |
| 30 | + shell: bash |
| 31 | + run: | |
| 32 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT |
| 33 | +
|
| 34 | + - name: Setup pnpm cache |
| 35 | + uses: actions/cache@v3 |
| 36 | + with: |
| 37 | + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 38 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 39 | + restore-keys: | |
| 40 | + ${{ runner.os }}-pnpm-store- |
| 41 | +
|
| 42 | + - name: Install dependencies |
| 43 | + run: pnpm install --frozen-lockfile |
| 44 | + |
| 45 | + - name: Build |
| 46 | + run: pnpm build |
| 47 | + |
| 48 | + - name: Extract module info from tag |
| 49 | + id: module_info |
| 50 | + run: | |
| 51 | + TAG=${GITHUB_REF#refs/tags/} |
| 52 | + MODULE=$(echo $TAG | cut -d'-' -f1) |
| 53 | + VERSION=$(echo $TAG | cut -d'v' -f2) |
| 54 | +
|
| 55 | + echo "module=$MODULE" >> $GITHUB_OUTPUT |
| 56 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 57 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 58 | +
|
| 59 | + - name: Extract module data from dist |
| 60 | + id: module_data |
| 61 | + run: | |
| 62 | + MODULE="${{ steps.module_info.outputs.module }}" |
| 63 | + DIST_PATH="modules/${MODULE}/dist" |
| 64 | +
|
| 65 | + if [ ! -d "$DIST_PATH" ]; then |
| 66 | + echo "Error: dist directory not found at $DIST_PATH" |
| 67 | + fi |
| 68 | +
|
| 69 | + if [ ! -d "$DIST_PATH/module.json" ]; then |
| 70 | + echo "Error: module.json not found at $DIST_PATH" |
| 71 | + fi |
| 72 | +
|
| 73 | + MODULE_ID=$(jq -r '.id' "$DIST_PATH/module.json") |
| 74 | + MODULE_TITLE=$(jq -r '.title' "$DIST_PATH/module.json") |
| 75 | + MODULE_DESCRIPTION=$(jq -r '.description "$DIST_PATH/module.json") |
| 76 | +
|
| 77 | + echo "module_id=$MODULE_ID" >> $GITHUB_OUTPUT |
| 78 | + echo "module_title=$MODULE_TITLE" >> $GITHUB_OUTPUT |
| 79 | + echo "module_description=$MODULE_DESCRIPTION" >> $GITHUB_OUTPUT |
| 80 | + echo "dist_path=$DIST_PATH" >> $GITHUB_OUTPUT |
| 81 | +
|
| 82 | + echo "Found module.json at $DIST_PATH/module.json" |
| 83 | +
|
| 84 | + - name: Create module ZIP |
| 85 | + run: | |
| 86 | + MODULE="${{ steps.module_info.outputs.module }}" |
| 87 | + DIST_PATH="${{ steps.module_data.outputs.dist_path }}" |
| 88 | +
|
| 89 | + cd "$DIST_PATH" |
| 90 | + zip -r "../../../${MODULE}.zip" . |
| 91 | +
|
| 92 | + echo "Created ${MODULE}.zip" |
| 93 | + ls -ln "../../../${MODULE}.zip" |
| 94 | +
|
| 95 | + - name: Create module release |
| 96 | + uses: ncipollo/release-action@v1 |
| 97 | + with: |
| 98 | + artifacts: "${{ steps.module_info.outputs.module }}.zip,${{ steps.module_data.outputs.dist_path }}/module.json" |
| 99 | + tag: ${{ steps.module_info.outputs.tag }} |
| 100 | + name: "${{ steps.module_data.outputs.module_name }} v${{ steps.module_info.outputs.version }}" |
| 101 | + body: | |
| 102 | + # ${{ steps.module_data.outputs.module_title }} v${{ steps.module_info.outputs.version }} |
| 103 | +
|
| 104 | + ${{ steps.module_data.outputs.module_description }} |
| 105 | +
|
| 106 | + ## Installation |
| 107 | +
|
| 108 | + Use this manifest URL in Foundry VTT: |
| 109 | + ``` |
| 110 | + https://github.com/${{ github.repository }}/releases/download/${{ steps.module_info.outputs.tag }}/module.json |
| 111 | + ``` |
| 112 | +
|
| 113 | + ## Module Info |
| 114 | + - **ID**: `${{ steps.module_data.outputs.module_id }}` |
| 115 | + - **Version**: `${{ steps.module_info.outputs.version }}` |
0 commit comments