|
81 | 81 |
|
82 | 82 | echo "Found module.json at $DIST_PATH/module.json" |
83 | 83 |
|
| 84 | + - name: Update module.json for release |
| 85 | + run: | |
| 86 | + ODULE="${{ steps.module_info.outputs.module }}" |
| 87 | + VERSION="${{ steps.module_info.outputs.version }}" |
| 88 | + TAG="${{ steps.module_info.outputs.tag }}" |
| 89 | + DIST_PATH="${{ steps.module_data.outputs.dist_path }}" |
| 90 | +
|
| 91 | + cd "$DIST_PATH" |
| 92 | +
|
| 93 | + jq --arg version "$VERSION" \ |
| 94 | + --arg tag "$TAG" \ |
| 95 | + --arg module "$MODULE" \ |
| 96 | + '.version = $version | |
| 97 | + .manifest = "https://github.com/${{ github.repository }}/releases/download/latest/sounds/module.json" | |
| 98 | + .download = "https://github.com/${{ github.repository }}/releases/download/\($tag)/\($module).zip"' \ |
| 99 | + module.json > module.json.tmp |
| 100 | +
|
| 101 | + mv module.json.tmp module.json |
| 102 | +
|
| 103 | + echo "Updated module.json with release URLs" |
| 104 | + cat module.json |
| 105 | +
|
84 | 106 | - name: Create module ZIP |
85 | 107 | run: | |
86 | 108 | MODULE="${{ steps.module_info.outputs.module }}" |
@@ -113,3 +135,68 @@ jobs: |
113 | 135 | ## Module Info |
114 | 136 | - **ID**: `${{ steps.module_data.outputs.module_id }}` |
115 | 137 | - **Version**: `${{ steps.module_info.outputs.version }}` |
| 138 | +
|
| 139 | + - name: Setup GitHub CLI |
| 140 | + run: | |
| 141 | + echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token |
| 142 | +
|
| 143 | + - name: Get latest release-index version |
| 144 | + id: index_version |
| 145 | + run: | |
| 146 | + LATEST_INDEX=$(git tag -l "release-index-v*" | sort -V | tail -n1) |
| 147 | +
|
| 148 | + if [ -z "$LATEST_INDEX" ]; then |
| 149 | + INDEX_VERSION=1 |
| 150 | + echo "Creating first release-index" |
| 151 | + else |
| 152 | + CURRENT_VERSION=$(echo $LATEST_INDEX | grep -oP '\d+$') |
| 153 | + INDEX_VERSION=$((CURRENT_VERSION + 1)) |
| 154 | + echo "Incrementing from v$CURRENT_VERSION to v$INDEX_VERSION" |
| 155 | + fi |
| 156 | +
|
| 157 | + INDEX_TAG="release-index-v${INDEX_VERSION}" |
| 158 | +
|
| 159 | + echo "version=$INDEX_VERSION" >> $GITHUB_OUTPUT |
| 160 | + echo "tag=$INDEX_TAG" >> $GITHUB_OUTPUT |
| 161 | + echo "previous_tag=$LATEST_INDEX" >> $GITHUB_OUTPUT |
| 162 | +
|
| 163 | + echo "New index tag: $INDEX_TAG" |
| 164 | +
|
| 165 | + - name: Prepare release-index files |
| 166 | + run: | |
| 167 | + MODULE="${{ steps.module_info.outputs.module }}" |
| 168 | + PREVIOUS_TAG="${{ steps.index_version.outputs.previous_tag }}" |
| 169 | +
|
| 170 | + mkdir -p release-index |
| 171 | +
|
| 172 | + if [ -n "$PREVIOUS_TAG" ]; then |
| 173 | + echo "Downloading previous release-index from $PREVIOUS_TAG" |
| 174 | +
|
| 175 | + gh release view "$PREVIOUS_TAG" --json assets --jq '.assets[].name' | grep '\.json$' | while read asset; do |
| 176 | + echo "Downloading $asset" |
| 177 | + gh release download "$PREVIOUS_TAG" -p "$asset" -D release-index/ || true |
| 178 | + done |
| 179 | + fi |
| 180 | +
|
| 181 | + echo "Adding/updating ${MODULE}.json" |
| 182 | + cp "${{ steps.module_data.outputs.dist_path }}/module.json" "release-index/${MODULE}.json" |
| 183 | +
|
| 184 | + echo "" |
| 185 | + echo "Release Index contents:" |
| 186 | + ls -1 release-index/*.json 2>/dev/null | while read file; do |
| 187 | + MODULE_NAME=$(basename "$file" .json) |
| 188 | + MODULE_VERSION=$(jq -r '.version' "$file") |
| 189 | + MODULE_TITLE=$(jq -r '.title' "$file") |
| 190 | + echo "${MODULE_NAME}.json - $MODULE_TITLE v$MODULE_VERSION" |
| 191 | + done |
| 192 | +
|
| 193 | + - name: Create release-index release |
| 194 | + uses: ncipollo/release-action@v1 |
| 195 | + with: |
| 196 | + artifacts: "release-index/*.json" |
| 197 | + tag: ${{ steps.index_version.outputs.tag }} |
| 198 | + name: "Release Index v${{ steps.index_version.outputs.version }}" |
| 199 | + body: | |
| 200 | + # 📚 Release Index v${{ steps.index_version.outputs.version }} |
| 201 | +
|
| 202 | + Updated with: **${{ steps.module_data.outputs.module_title }}** v${{ steps.module_info.outputs.version }} |
0 commit comments