-
Notifications
You must be signed in to change notification settings - Fork 0
203 lines (162 loc) · 6.86 KB
/
release.yaml
File metadata and controls
203 lines (162 loc) · 6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
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 }}