0.0.1 #2
Workflow file for this run
This file contains 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 | |
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: "{}" | |
# 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 asset/ 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 |