-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (65 loc) · 2.85 KB
/
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
name: Release
on:
release:
types: [published]
env:
package_type: system
package_id: trued6
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Substitute Manifest and Download Links For Versioned Ones
id: sub_manifest_link_version
uses: microsoft/variable-substitution@v1
with:
files: 'system.json'
env:
version: ${{github.event.release.tag_name}}
manifest: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/system.json
download: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/system.zip
flags: "{}"
- name: Disable debug
run: sed -i 's/TRUED6\.debug = true;/TRUED6.debug = false;/g' "module/helpers/config.mjs"
# Create a zip file with all files required by the system to add to the release
- run: zip -r ${{ env.package_type }}.zip LICENSE README.md system.json template.json assets/ css/ lang/ lib/ module/ packs/ templates/
# Create a release for this specific version
- name: Update Release with Files
id: create_version_release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
name: ${{ github.event.release.name }}
artifacts: './${{ env.package_type }}.json, ./${{ env.package_type }}.zip'
body: ${{ github.event.release.body }}
- name: Get Compatibility
run: |
echo 'COMPATIBILITY<<EOF' >> $GITHUB_ENV
cat ${{ env.package_type }}.json | jq .compatibility >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Send package to foundry
run: |
HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X POST 'https://api.foundryvtt.com/_api/packages/release_version/' \
--header 'Authorization: ${{ secrets.PACKAGE_TOKEN }}' \
--header 'Content-Type: application/json' \
--data '{
"id": "${{env.package_id}}",
"release": {
"version": "${{ github.event.release.tag_name }}",
"manifest": "https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/${{ env.package_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