Skip to content

Commit 988a1b3

Browse files
committed
feat: add release workflow
1 parent 8be2783 commit 988a1b3

2 files changed

Lines changed: 116 additions & 1 deletion

File tree

.github/workflows/release.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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 }}`

packages/foundry-vite-plugin/src/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export async function generateModuleBundle(options: ModuleOptions) {
4747
url: options.repo,
4848
bugs: `${options.repo}/issues`,
4949
manifest: `${options.repo}/releases/latest/download/${options.id}.json`,
50-
download: `${options.repo}/releases/latest/download/${options.id}.zip`,
50+
download: `${options.repo}/releases/${options.id}-v${options.version}/download/${options.id}.zip`,
5151
readme: `${options.repo}/blob/main/modules/${options.id}/README.md`,
5252
changelog: `${options.repo}/blob/main/modules/${options.id}/CHANGELOG.md`,
5353
esmodules: ["./module.js"],

0 commit comments

Comments
 (0)