Skip to content

v1.12.13.1: Declare compatibility with FVTT v12 #371

v1.12.13.1: Declare compatibility with FVTT v12

v1.12.13.1: Declare compatibility with FVTT v12 #371

Workflow file for this run

name: Build Release
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10, v2.1.4rc5
permissions:
contents: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Prepare Environment
id: prepare_env
run: |
# Calculate project information
PROJECT="${GITHUB_REPOSITORY#ruipin/}"
PROJECT_NO_FVTT="${PROJECT#fvtt-}"
echo "PROJECT=${PROJECT}" >> $GITHUB_ENV
echo "PROJECT_NO_FVTT=${PROJECT_NO_FVTT}" >> $GITHUB_ENV
echo ::set-output name=PROJECT::${PROJECT}
echo ::set-output name=PROJECT_NO_FVTT::${PROJECT_NO_FVTT}
# Calculate version information
GIT_HASH="$(git rev-parse HEAD)"
VERSION="${GITHUB_REF#refs/*/v}"
SPLIT_VERSION_1="${VERSION#*.}"
SPLIT_VERSION_2="${SPLIT_VERSION_1#*.}"
MAJOR_VERSION="${VERSION%%.*}"
MINOR_VERSION="${SPLIT_VERSION_1%%.*}"
SPLIT_VERSION_3="${SPLIT_VERSION_2%%[^0-9]*}"
PATCH_VERSION="${SPLIT_VERSION_3}"
SUFFIX_VERSION="${SPLIT_VERSION_2#${SPLIT_VERSION_3}}"
SUFFIX_VERSION="${SUFFIX_VERSION#.}"
SUFFIX_VERSION="${SUFFIX_VERSION#-}"
IS_PRERELEASE="true"
if [[ "$SUFFIX_VERSION" != *rc* ]]; then
git merge-base --is-ancestor HEAD origin/master && IS_PRERELEASE="false"
fi
# Store environment
echo ::set-output name=VERSION::${VERSION}
echo ::set-output name=MAJOR_VERSION::${MAJOR_VERSION}
echo ::set-output name=MINOR_VERSION::${MINOR_VERSION}
echo ::set-output name=PATCH_VERSION::${PATCH_VERSION}
echo ::set-output name=SUFFIX_VERSION::${SUFFIX_VERSION}
echo ::set-output name=IS_PRERELEASE::${IS_PRERELEASE}
echo ::set-output name=GIT_HASH::${GIT_HASH}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "MAJOR_VERSION=${MAJOR_VERSION}" >> $GITHUB_ENV
echo "MINOR_VERSION=${MINOR_VERSION}" >> $GITHUB_ENV
echo "PATCH_VERSION=${PATCH_VERSION}" >> $GITHUB_ENV
echo "SUFFIX_VERSION=${SUFFIX_VERSION}" >> $GITHUB_ENV
echo "IS_PRERELEASE=${IS_PRERELEASE}" >> $GITHUB_ENV
echo "GIT_HASH=${GIT_HASH}" >> $GITHUB_ENV
echo "Project: '$PROJECT' ; Version: '$VERSION' ; Major: '$MAJOR_VERSION' ; Minor: '$MINOR_VERSION' ; Patch: '$PATCH_VERSION' ; Suffix: '$SUFFIX_VERSION' ; Hash: '$GIT_HASH' ; Pre-release: '$IS_PRERELEASE' ;"
# Sanity check
if ! grep "\"${VERSION}\"" module.json ; then
echo "module.json version does not match the tag"
exit 1
fi
shell: bash
- name: Fetch submodules
id: fetch_submodules
run: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
git submodule sync --recursive
git submodule update --init --recursive --force
shell: bash
- name: Prepare node
uses: actions/setup-node@v2
with:
node-version: '20.4'
- name: Prepare npm
run: npm install
- name: Run tests
run: npm run test
- name: Build
run: |
# Prepare 'dist' directory
mkdir -p "dist"
# Copy static files
cp *.md "LICENSE" dist/
[[ -d "templates" ]] && cp -r templates dist/templates
[[ -d "lang" ]] && cp -r lang dist/lang
# Edit module.json manifest
MANIFEST_EDITS=()
function add_manifest_edit {
MANIFEST_EDITS+=('-e' 's~(["'"'"']'"$1"'["'"'"'][[:space:]]*:).*[^,[:space:]](,?)[[:space:]]*$~\1 '"$2"'\2~')
}
add_manifest_edit 'git_version' '"${{ steps.prepare_env.outputs.GIT_HASH }}"'
add_manifest_edit 'esmodules' '\["lib-wrapper.js"\]'
add_manifest_edit 'styles' '\["lib-wrapper.css"\]'
add_manifest_edit 'manifest' '"https://github.com/ruipin/${{ steps.prepare_env.outputs.PROJECT }}/releases/latest/download/module.json"'
add_manifest_edit 'download' '"https://github.com/ruipin/${{ steps.prepare_env.outputs.PROJECT }}/releases/download/v${{ steps.prepare_env.outputs.VERSION }}/${{ steps.prepare_env.outputs.PROJECT_NO_FVTT }}-v${{ steps.prepare_env.outputs.VERSION }}.zip"'
sed -r \
"${MANIFEST_EDITS[@]}" \
module.json > dist/module.json
# Make sure to use modified version of module.json when building the artifact
cp dist/module.json module.json
# Build artifact
npm run build
# Create 7zip file
cd dist
7z a -tzip "../${{ steps.prepare_env.outputs.PROJECT_NO_FVTT }}-v${{ steps.prepare_env.outputs.VERSION }}.zip" "." -mx0
cd ..
cp dist/module.json "module.json"
- name: Create/Upload Zip
uses: ncipollo/release-action@215101a6e62db34b334af623ab3a43e27baa93d9
with:
artifacts: "./${{ steps.prepare_env.outputs.PROJECT_NO_FVTT }}-v${{ steps.prepare_env.outputs.VERSION }}.zip"
artifactContentType: application/zip
allowUpdates: true
replacesArtifacts: true
prerelease: ${{ steps.prepare_env.outputs.IS_PRERELEASE }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create/Upload Json
uses: ncipollo/release-action@215101a6e62db34b334af623ab3a43e27baa93d9
with:
artifacts: ./module.json
artifactContentType: application/json
allowUpdates: true
replacesArtifacts: true
prerelease: ${{ steps.prepare_env.outputs.IS_PRERELEASE }}
token: ${{ secrets.GITHUB_TOKEN }}