generated from RPG-Made-Simple/FVTT-ModuleTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (87 loc) · 3.22 KB
/
foundry_release.yml
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
name: Create Foundry Release
on:
push:
tags:
- '*'
jobs:
# Release the packet
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Checkout to latest commit
- name: Checkout to Latest Commit
uses: actions/checkout@v3
# Check if tag already exists
- name: Verify if tag is not duplicate
id: check-tag
run: |
if git rev-parse "${{ github.action_ref }}" >/dev/null 2>&1; then
echo "Tag already exists"
exit 1
fi
# Get the module version and title
- name: Get Module Version
run: |
VERSION=$(jq -r '.version' module.json)
echo "VERSION=$VERSION" >> $GITHUB_ENV
TITLE=$(jq -r '.title' module.json)
echo "TITLE=$TITLE" >> $GITHUB_ENV
# Check if tag version and 'module.json' version are the same
- name: Check if 'module.json' is valid
run: |
if [ "${{ env.VERSION }}" != "${{ github.ref_name }}" ]; then
echo "Invalid 'module.json' - version difference"
echo "'module.json' version is '${{ env.VERSION }}'"
echo "tag version is '${{ github.ref_name }}'"
exit 1
fi
# Get the env values from the modified module.json
- name: Get Module Information
run: |
MODULE=$(jq -r '.id' module.json)
echo "MODULE=$MODULE" >> $GITHUB_ENV
MINIMUM=$(jq -r '.compatibility.minimum' module.json)
echo "MINIMUM=$MINIMUM" >> $GITHUB_ENV
VERIFIED=$(jq -r '.compatibility.verified' module.json)
echo "VERIFIED=$VERIFIED" >> $GITHUB_ENV
echo "MANIFEST=https://github.com/${{ github.repository }}/releases/download/${{ env.VERSION }}/module.json" >> $GITHUB_ENV
echo "CHANGELOG=https://github.com/${{ github.repository }}/releases/tag/${{ env.VERSION }}" >> $GITHUB_ENV
# Zip the files into module.zip
- name: Package Release
run: zip -r ./module.zip module.json LICENSE module/
# Generate notes
- name: Generate Changelog
uses: CSchoel/release-notes-from-changelog@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ env.VERSION }}
begin-pattern: '/^## Version ${{ env.VERSION }}/'
end-pattern: '/^## /'
# Create the release
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "module.zip,module.json"
bodyfile: RELEASE.md
# Release it at FoundryVTT
- name: Release Module to FoundryVTT
run: |
curl -X POST "https://api.foundryvtt.com/_api/packages/release_version/" \
-H "Content-Type: application/json" \
-H "Authorization: ${{ secrets.FOUNDRY_RELEASE_TOKEN }}" \
-d '{
"id": "${{ env.MODULE }}",
"dry-run": true,
"release": {
"version": "${{ env.VERSION }}",
"manifest": "${{ env.MANIFEST }}",
"notes": "${{ env.CHANGELOG }}",
"compatibility": {
"minimum": "${{ env.MINIMUM }}",
"verified": "${{ env.VERIFIED }}"
}
}
}'