|
| 1 | +name: Create Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'module.json' |
| 9 | + |
| 10 | +jobs: |
| 11 | + check-version: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + outputs: |
| 14 | + version: ${{ steps.get-version.outputs.version }} |
| 15 | + version-changed: ${{ steps.check-version.outputs.changed }} |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 2 |
| 21 | + |
| 22 | + - name: Get current version |
| 23 | + id: get-version |
| 24 | + run: | |
| 25 | + VERSION=$(jq -r '.version' module.json) |
| 26 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 27 | + echo "Current version: $VERSION" |
| 28 | +
|
| 29 | + - name: Check if version changed |
| 30 | + id: check-version |
| 31 | + run: | |
| 32 | + git diff HEAD^ HEAD -- module.json > diff.txt |
| 33 | + if grep -q '"version"' diff.txt; then |
| 34 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 35 | + echo "Version changed detected" |
| 36 | + else |
| 37 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 38 | + echo "Version not changed" |
| 39 | + fi |
| 40 | +
|
| 41 | + release: |
| 42 | + needs: check-version |
| 43 | + if: needs.check-version.outputs.version-changed == 'true' |
| 44 | + runs-on: ubuntu-latest |
| 45 | + permissions: |
| 46 | + contents: write |
| 47 | + steps: |
| 48 | + - name: Checkout code |
| 49 | + uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Get module info |
| 52 | + id: module-info |
| 53 | + run: | |
| 54 | + VERSION=$(jq -r '.version' module.json) |
| 55 | + TITLE=$(jq -r '.title' module.json) |
| 56 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 57 | + echo "title=$TITLE" >> $GITHUB_OUTPUT |
| 58 | + echo "Preparing release for $TITLE v$VERSION" |
| 59 | +
|
| 60 | + - name: Create module.zip |
| 61 | + run: | |
| 62 | + # Create the zip with only essential module files |
| 63 | + zip -r module.zip \ |
| 64 | + module.json \ |
| 65 | + scripts/ \ |
| 66 | + styles/ \ |
| 67 | + templates/ \ |
| 68 | + assets/ \ |
| 69 | + LICENSE |
| 70 | +
|
| 71 | + # Verify the zip was created |
| 72 | + ls -lh module.zip |
| 73 | + echo "Module packaged successfully" |
| 74 | +
|
| 75 | + # Show contents |
| 76 | + echo "Contents of module.zip:" |
| 77 | + unzip -l module.zip |
| 78 | +
|
| 79 | + - name: Create Release |
| 80 | + uses: softprops/action-gh-release@v1 |
| 81 | + with: |
| 82 | + tag_name: v${{ steps.module-info.outputs.version }} |
| 83 | + name: ${{ steps.module-info.outputs.title }} v${{ steps.module-info.outputs.version }} |
| 84 | + body: | |
| 85 | + ## ${{ steps.module-info.outputs.title }} v${{ steps.module-info.outputs.version }} |
| 86 | +
|
| 87 | + ### Installation |
| 88 | + Install this version using the following manifest URL: |
| 89 | + ``` |
| 90 | + https://github.com/${{ github.repository }}/releases/download/v${{ steps.module-info.outputs.version }}/module.json |
| 91 | + ``` |
| 92 | +
|
| 93 | + Or download `module.zip` and install manually. |
| 94 | +
|
| 95 | + ### Compatibility |
| 96 | + - Foundry VTT v13.332+ |
| 97 | +
|
| 98 | + See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details. |
| 99 | + files: | |
| 100 | + module.zip |
| 101 | + module.json |
| 102 | + draft: false |
| 103 | + prerelease: false |
| 104 | + env: |
| 105 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 106 | + |
| 107 | + - name: Update latest release links |
| 108 | + run: | |
| 109 | + echo "Release created successfully!" |
| 110 | + echo "Download URL: https://github.com/${{ github.repository }}/releases/download/v${{ steps.module-info.outputs.version }}/module.zip" |
| 111 | + echo "Manifest URL: https://github.com/${{ github.repository }}/releases/download/v${{ steps.module-info.outputs.version }}/module.json" |
0 commit comments