mirror of
https://github.com/Kornstalx/5etools-mirror-2.github.io.git
synced 2025-10-28 20:45:35 -05:00
v1.198.1
This commit is contained in:
6
.github/create-rsync-filter.sh
vendored
Normal file
6
.github/create-rsync-filter.sh
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
sed -e '/^\*/d' -e 's/^!/+ /' .dockerignore > .rsync-filter
|
||||
echo -e "\n- /*" >> .rsync-filter
|
||||
47
.github/generate-release-notes.sh
vendored
Normal file
47
.github/generate-release-notes.sh
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "No arguments provided. Usage: generate-release-notes.sh <version>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version=$1
|
||||
|
||||
# Release version number without "v" prefix to match the format of changelog.json.
|
||||
version_number="${version#v}"
|
||||
|
||||
# This parses the JSON blob for this specific version from changelog.json.
|
||||
changelog="$(
|
||||
jq --arg version "$version_number" --compact-output \
|
||||
'.[] | select(.ver == $version)' \
|
||||
data/changelog.json
|
||||
)"
|
||||
|
||||
if [[ -z "$changelog" ]]; then
|
||||
echo "_No changelogs are available for $version._"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
{
|
||||
# The "gh" tool reads all text up to the first empty line as the release
|
||||
# title.
|
||||
# * For changelog entries with a title, this is formatted as
|
||||
# '<version>, "<title>" Edition' to match the format of the site's
|
||||
# changelog page.
|
||||
#
|
||||
# * For changelog entries without a title, this is formatted as simply
|
||||
# '<version>'.
|
||||
echo -n "$version"
|
||||
jq -r 'if has("title") then ", \(.title | tojson) Edition\n" else "\n" end' <<< "$changelog"
|
||||
|
||||
# Some changelogs include an alternate title. This is included in the body
|
||||
# of the release notes and formatted as 'AKA "<altTitle>" Edition' to match
|
||||
# the site's changelog page.
|
||||
jq -j 'if has("titleAlt") then "AKA \(.titleAlt | tojson) Edition\n" else "" end' <<< "$changelog"
|
||||
|
||||
# Changelog text is already markdown-formatted, so no additional formatting
|
||||
# needs to be done here.
|
||||
jq -r '.txt' <<< "$changelog"
|
||||
}
|
||||
15
.github/set-deployed-flag.sh
vendored
Normal file
15
.github/set-deployed-flag.sh
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "No arguments provided. Usage: set-deployed-flag.sh <version>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version=$1
|
||||
|
||||
# Set the IS_DEPLOYED variable for production.
|
||||
sed -i 's/IS_DEPLOYED\s*=\s*undefined/IS_DEPLOYED='"\"${version}\""'/g' js/utils.js
|
||||
|
||||
sed -i 's#DEPLOYED_IMG_ROOT\s*=\s*undefined#DEPLOYED_IMG_ROOT='"\"https://raw.githubusercontent.com/5etools-mirror-2/5etools-img/main/\""'#g' js/utils.js
|
||||
133
.github/workflows/main.yml
vendored
Normal file
133
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
name: Build and Upload Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v**'
|
||||
|
||||
# Allow running manually from the actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
# See: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio
|
||||
IMAGE_NAME: 5etools
|
||||
|
||||
# Used to force a clean (i.e., non-incremental) Docker build
|
||||
DO_CLEAN_BUILD: 1
|
||||
|
||||
concurrency:
|
||||
group: "release"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- name: Generate Release Notes
|
||||
run: bash ./.github/generate-release-notes.sh ${{ github.ref_name }} | tee RELEASE_NOTES.md
|
||||
|
||||
- name: Archive Release
|
||||
run: |
|
||||
zip -r 5etools-${{ github.ref_name }}.zip . -x '*.git*' '*node_modules*' '*.github*'
|
||||
|
||||
- name: Upload Release
|
||||
run: |
|
||||
gh release create "${{github.ref_name}}" --title "${{github.ref_name}}" --notes-file RELEASE_NOTES.md 5etools-${{ github.ref_name }}.zip
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
create-image:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
# See: https://stackoverflow.com/a/58178121
|
||||
- name: Set Env
|
||||
run: |
|
||||
IMAGE_VERSION=${{ github.ref_name }}
|
||||
# Strip "v" prefix from tag name
|
||||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && IMAGE_VERSION=$(echo $IMAGE_VERSION | sed -e 's/^v//')
|
||||
echo "IMAGE_VERSION=$IMAGE_VERSION" >> $GITHUB_ENV
|
||||
|
||||
echo "IMAGE_ID=$(echo ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
|
||||
|
||||
- name: Set Deployed Flag
|
||||
run: |
|
||||
bash ./.github/set-deployed-flag.sh ${{ github.ref_name }}
|
||||
|
||||
# Remove entries from the `.gitignore` so the gh-pages action can correctly add+commit them to the pages branch
|
||||
- name: Build Service Worker
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
npm i
|
||||
npm run build:sw:prod
|
||||
sed -i 's/sw.js//g' .gitignore
|
||||
sed -i 's/sw-injector.js//g' .gitignore
|
||||
|
||||
- name: Build SEO Pages
|
||||
env:
|
||||
VET_SEO_IS_DEV_MODE: true
|
||||
VET_BASE_SITE_URL: https://5etools-mirror-2.github.io/
|
||||
VET_SEO_IS_SKIP_UA_ETC: true
|
||||
run: |
|
||||
npm run build:seo -- ${{ github.ref_name }}
|
||||
|
||||
# region See: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio
|
||||
- name: Build Image
|
||||
run: |
|
||||
if [[ "${{ github.ref }}" == "refs/tags/"* ]]
|
||||
then
|
||||
VERSION_ARRAY=( ${IMAGE_VERSION//./ } )
|
||||
MAJOR=${VERSION_ARRAY[0]}
|
||||
MINOR=${VERSION_ARRAY[1]}
|
||||
POINT=${VERSION_ARRAY[2]}
|
||||
|
||||
# Create a clean docker image every 4 minor version.
|
||||
if [[ $(echo "$MINOR % 4" | bc) == 0 && $POINT == 0 ]]
|
||||
then
|
||||
DO_CLEAN_BUILD=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $DO_CLEAN_BUILD == 1 ]]
|
||||
then
|
||||
# Build a clean image
|
||||
echo "Version is ${{ github.ref_name }}, doing a clean docker build"
|
||||
docker build -t $IMAGE_NAME .
|
||||
else
|
||||
# Build an incremental image...
|
||||
echo "Version is ${{ github.ref_name }}, doing an incremental docker build"
|
||||
|
||||
# Pull the old image
|
||||
docker pull $IMAGE_ID:latest
|
||||
|
||||
# Save the current CMD from the image
|
||||
SAVE_CMD=$(docker inspect --format='{{json .Config.Cmd}}' $IMAGE_ID:latest)
|
||||
|
||||
# Convert .dockerignore to .rsync-filter
|
||||
bash ./.github/create-rsync-filter.sh
|
||||
|
||||
# Run up the previous container, and rsync the current new of files into it
|
||||
CONTAINER_ID=$(docker run -d -v "$(pwd)":/tmp/5et-new $IMAGE_ID:latest rsync -rlcvF --delete-excluded /tmp/5et-new/ /var/www/localhost/htdocs/)
|
||||
docker logs -f $CONTAINER_ID
|
||||
|
||||
# Commit the changes
|
||||
docker commit -c "CMD $SAVE_CMD" $CONTAINER_ID $IMAGE_NAME
|
||||
fi
|
||||
|
||||
- name: Log In to Registry
|
||||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
|
||||
- name: Push Image
|
||||
run: |
|
||||
echo IMAGE_ID=$IMAGE_ID
|
||||
echo IMAGE_VERSION=$IMAGE_VERSION
|
||||
docker tag $IMAGE_NAME $IMAGE_ID:$IMAGE_VERSION
|
||||
# Always tag latest when pushing a tag, as we don't expect to ever merge old tags
|
||||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && docker tag $IMAGE_NAME $IMAGE_ID:latest
|
||||
docker push $IMAGE_ID:$IMAGE_VERSION
|
||||
docker push $IMAGE_ID:latest
|
||||
# endregion
|
||||
83
.github/workflows/pages.yml
vendored
Normal file
83
.github/workflows/pages.yml
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
name: Build and Deploy Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v**'
|
||||
|
||||
# Allow running manually from the actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# Single deploy job since we're just deploying
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Set Deployed Flag
|
||||
run: |
|
||||
bash ./.github/set-deployed-flag.sh ${{ github.ref_name }}
|
||||
|
||||
# Notably: remove anything which should not be added to the service worker manifest:
|
||||
# - `homebrew`
|
||||
# - `prerelease`
|
||||
- name: Cleanup
|
||||
run: |
|
||||
rm -rf .gitmodules *.md *.zip scss spellcheck homebrew prerelease
|
||||
ls -lah
|
||||
|
||||
# Remove entries from the `.gitignore` so the gh-pages action can correctly add+commit them to the pages branch
|
||||
- name: Build Service Worker
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
npm i
|
||||
npm run build:sw:prod
|
||||
sed -i 's/sw.js//g' .gitignore
|
||||
sed -i 's/sw-injector.js//g' .gitignore
|
||||
|
||||
- name: Build SEO Pages
|
||||
env:
|
||||
VET_SEO_IS_DEV_MODE: true
|
||||
VET_BASE_SITE_URL: https://5etools-mirror-2.github.io/
|
||||
VET_SEO_IS_SKIP_UA_ETC: true
|
||||
run: |
|
||||
npm run build:seo -- ${{ github.ref_name }}
|
||||
|
||||
- name: Cleanup
|
||||
run: |
|
||||
rm -rf node_modules node
|
||||
ls -lah
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@master
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@master
|
||||
with:
|
||||
path: '.'
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@master
|
||||
with:
|
||||
# Timeout in millis (10 mins)
|
||||
timeout: 600000
|
||||
Reference in New Issue
Block a user