13.2.0 #42
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release CI | |
| on: | |
| release: | |
| types: | |
| - published | |
| env: | |
| # 'system' or 'module' | |
| TYPE: system | |
| jobs: | |
| release: | |
| name: Create & Publish Release | |
| # if: startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 📡 Checkout | |
| uses: actions/checkout@v3 | |
| # Configures NodeJS. | |
| - name: ⚙️ Setup NodeJS 22 | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 22 | |
| # Installs & builds. | |
| - name: 🔧 Install Dependencies | |
| run: npm ci | |
| - name: 🧱 Build Project | |
| run: npm run build | |
| # Gets the system/module name. | |
| - name: 📄 Get Name | |
| id: name | |
| uses: notiz-dev/github-action-json-property@release | |
| with: | |
| path: dist/${{ env.TYPE }}.json | |
| prop_path: id | |
| # Gets the version tag. | |
| - name: 📄 Get Version | |
| id: version | |
| uses: notiz-dev/github-action-json-property@release | |
| with: | |
| path: dist/${{ env.TYPE }}.json | |
| prop_path: version | |
| # - name: 🏷️ Get Version Tag | |
| # id: version | |
| # uses: ncipollo/semantic-version-action@v1.0.1 | |
| # with: | |
| # tag: ${{ github.event.release.tag_name }} | |
| # Substitute the Manifest and Download URLs in the module.json | |
| - name: 📝 Substitute Manifest and Download Links For Versioned Ones | |
| id: manifest_link_version | |
| uses: microsoft/variable-substitution@v1 | |
| with: | |
| files: dist/${{ env.TYPE }}.json | |
| env: | |
| # version: ${{ steps.version.outputs.prop }} | |
| manifest: https://github.com/${{ github.repository }}/releases/latest/download/${{ env.TYPE }}.json | |
| download: https://github.com/${{ github.repository }}/releases/download/${{ github.event.release.tag_name }}/${{ steps.name.outputs.prop }}-fvtt_v${{ steps.version.outputs.prop }}.zip | |
| # Generates the changelog. | |
| # - name: 📜 Generate Changelog | |
| # id: changelog | |
| # uses: mikepenz/release-changelog-builder-action@v3.3.1 | |
| # env: | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Creates the ZIP artifact. | |
| - name: 📦 Create ZIP Archive | |
| run: | | |
| cd dist/ | |
| zip -r ../${{ steps.name.outputs.prop }}-fvtt_v${{ steps.version.outputs.prop }}.zip * | |
| # Creates the release with its artifacts and description. | |
| - name: 🚀 Update Release with Artifacts | |
| uses: ncipollo/release-action@v1.14.0 | |
| with: | |
| allowUpdates: true | |
| name: ${{ github.event.release.name }} | |
| draft: false | |
| prerelease: false | |
| tag: ${{ steps.version.outputs.tag }} | |
| body: ${{ github.event.release.body }} | |
| artifacts: './${{ steps.name.outputs.prop }}-fvtt_v${{ steps.version.outputs.prop }}.zip, ./dist/${{ env.TYPE }}.json' | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get Compatibility | |
| run: | | |
| echo 'COMPATIBILITY<<EOF' >> $GITHUB_ENV | |
| cat dist/${{ env.TYPE }}.json | jq .compatibility >> $GITHUB_ENV | |
| echo 'EOF' >> $GITHUB_ENV | |
| - name: 🚩 Publish Module to FoundryVTT Website | |
| run: | | |
| HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST 'https://foundryvtt.com/_api/packages/release_version/' \ | |
| --header 'Authorization: ${{ secrets.PACKAGE_TOKEN }}' \ | |
| --header 'Content-Type: application/json' \ | |
| --data '{ | |
| "id": "${{ steps.name.outputs.prop }}", | |
| "dry-run": ${{github.event.release.prerelease}}, | |
| "release": { | |
| "version": "${{ github.event.release.tag_name }}", | |
| "manifest": "https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/${{ env.TYPE }}.json", | |
| "notes": "https://github.com/${{github.repository}}/releases/tag/${{github.event.release.tag_name}}", | |
| "compatibility": ${{ env.COMPATIBILITY }} | |
| } | |
| }') | |
| # extract the body | |
| HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g') | |
| # extract the status | |
| HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') | |
| # print the body | |
| echo "$HTTP_BODY" | |
| # example using the status | |
| if [ ! $HTTP_STATUS -eq 200 ]; then | |
| echo "Error [HTTP status: $HTTP_STATUS]" | |
| exit 1 | |
| fi | |