Skip to content

Release

Release #18

Workflow file for this run

name: Release
on:
release:
types: [published]
env:
package_type: module
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Modify manifest
run: |
sed -i.bak "s|latest|${{ github.event.release.tag_name }}|g" module.json
rm module.json.bak
- name: Create zip file
run: zip -r ${{ env.package_type }}.zip . -x '*.git*'
- name: Create release
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 system.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": "image-z00m",
"release": {
"version": "${{ github.event.release.tag_name }}",
"manifest": "https://github.com/cussa/image-z00m/releases/download/${{ github.event.release.tag_name }}/module.json",
"notes": "https://github.com/cussa/image-z00m/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