Update docs/API/ConfigurationFiles.md #2669
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: Build | |
on: [ push, pull_request ] | |
jobs: | |
prepare: | |
name: Prepare Build Variables | |
runs-on: ubuntu-latest | |
outputs: | |
VERSION: ${{ steps.save_version.outputs.version }} | |
VERSION_TYPE: ${{ steps.save_type.outputs.version_type }} | |
PREVIOUS_VERSION_TAG: ${{ steps.save_tag.outputs.previous_version_tag }} | |
CHANGES_IN_DOCS_ONLY: ${{ steps.save_changes.outputs.changes_in_docs_only }} | |
steps: | |
- name: Validate that a fork does not create a version tag | |
if: "github.repository != 'BetonQuest/BetonQuest' && startsWith(github.ref,'refs/tags/v')" | |
run: | | |
echo "Version tags are not supported in forks!" | |
exit 1 | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Read version from pom.xml | |
run: | | |
MAVEN_VERSION="$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)" | |
echo "MAVEN_VERSION=$MAVEN_VERSION" >> $GITHUB_ENV | |
echo "Collected the pom.xml version. The version is '$MAVEN_VERSION'" | |
- name: Get the previous build-number tag from Development Build | |
id: save_tag | |
if: "github.repository == 'BetonQuest/BetonQuest' && ( github.ref == 'refs/heads/main' || startsWith(github.ref,'refs/heads/main_v') || startsWith(github.ref,'refs/tags/v') )" | |
run: | | |
PREVIOUS_VERSION_TAG="$(git tag -l ${MAVEN_VERSION}-build-number-* | head -n 1)" | |
echo "PREVIOUS_VERSION_TAG=$PREVIOUS_VERSION_TAG" >> $GITHUB_ENV | |
echo "previous_version_tag=$PREVIOUS_VERSION_TAG" >> $GITHUB_OUTPUT | |
echo "Collected the previous build-number tag. The tag is '$PREVIOUS_VERSION_TAG'" | |
- name: Check for difference in docs only | |
id: save_changes | |
if: "github.repository == 'BetonQuest/BetonQuest' && ( github.ref == 'refs/heads/main' || startsWith(github.ref,'refs/heads/main_v') )" | |
run: | | |
DIFF_OUTSIDE="$(git diff --quiet ${PREVIOUS_VERSION_TAG} -- . ':(exclude)docs/' && echo Nothing || echo Changes)" | |
DIFF_INSIDE="$(git diff --quiet ${PREVIOUS_VERSION_TAG} -- docs/ && echo Nothing || echo Changes)" | |
if [[ $DIFF_OUTSIDE == Nothing && $DIFF_INSIDE == Changes ]]; then CHANGES_IN_DOCS_ONLY=true; else CHANGES_IN_DOCS_ONLY=false; fi | |
echo "CHANGES_IN_DOCS_ONLY=$CHANGES_IN_DOCS_ONLY" >> $GITHUB_ENV | |
echo "changes_in_docs_only=$CHANGES_IN_DOCS_ONLY" >> $GITHUB_OUTPUT | |
echo "Check for difference in docs only. The value is '$CHANGES_IN_DOCS_ONLY'" | |
- name: Generate build number for Development Build | |
if: "github.repository == 'BetonQuest/BetonQuest' && ( github.ref == 'refs/heads/main' || startsWith(github.ref,'refs/heads/main_v') ) && env.CHANGES_IN_DOCS_ONLY == 'false'" | |
uses: onyxmueller/build-tag-number@v1 | |
with: | |
token: ${{ secrets.github_token }} | |
prefix: ${{ env.MAVEN_VERSION }} | |
- name: Set version for 'Release Build' | |
if: "startsWith(github.ref,'refs/tags/v')" | |
run: | | |
TAG_VERSION="${GITHUB_REF#*/*/}" | |
echo "Collected the tag version. The version is '$TAG_VERSION'" | |
if [ ${TAG_VERSION:1} != $MAVEN_VERSION ]; then echo "::error::The version of the tag and the version of the pom are not equal! Tag is '$TAG_VERSION' and pom is '$MAVEN_VERSION'."; exit 1; fi | |
echo "MAVEN_VERSION=$MAVEN_VERSION" >> $GITHUB_ENV | |
echo "VERSION_TYPE=release" >> $GITHUB_ENV | |
- name: Set version for 'Development Build' | |
if: "github.repository == 'BetonQuest/BetonQuest' && ( github.ref == 'refs/heads/main' || startsWith(github.ref,'refs/heads/main_v') )" | |
run: | | |
if [ $CHANGES_IN_DOCS_ONLY == true ]; then MAVEN_VERSION=${PREVIOUS_VERSION_TAG/build-number/DEV}; else MAVEN_VERSION=${MAVEN_VERSION}-DEV-${BUILD_NUMBER}; fi | |
echo "MAVEN_VERSION=$MAVEN_VERSION" >> $GITHUB_ENV | |
echo "VERSION_TYPE=development" >> $GITHUB_ENV | |
- name: Set version for 'Artifact Build' | |
if: "github.repository != 'BetonQuest/BetonQuest' || !startsWith(github.ref,'refs/tags/v') && github.ref != 'refs/heads/main' && !startsWith(github.ref,'refs/heads/main_v')" | |
run: | | |
if [ ${{ github.repository }} != 'BetonQuest/BetonQuest' ]; then REPO=${{ github.repository }}-; fi | |
MAVEN_VERSION=${MAVEN_VERSION}-DEV-ARTIFACT-${REPO}${{ github.run_number }} | |
echo "MAVEN_VERSION=$MAVEN_VERSION" >> $GITHUB_ENV | |
echo "VERSION_TYPE=artifact" >> $GITHUB_ENV | |
- name: Save version to output variable | |
id: save_version | |
run: | | |
echo "The version is '$MAVEN_VERSION'" | |
echo "version=$MAVEN_VERSION" >> $GITHUB_OUTPUT | |
- name: Save version type to output variable | |
id: save_type | |
run: | | |
echo "The version type is '$VERSION_TYPE'" | |
echo "version_type=$VERSION_TYPE" >> $GITHUB_OUTPUT | |
build-artifacts: | |
name: Build Artifacts | |
needs: [ prepare ] | |
runs-on: ubuntu-latest | |
env: | |
VERSION: ${{ needs.prepare.outputs.VERSION }} | |
VERSION_TYPE: ${{ needs.prepare.outputs.VERSION_TYPE }} | |
PREVIOUS_VERSION_TAG: ${{ needs.prepare.outputs.PREVIOUS_VERSION_TAG }} | |
CHANGES_IN_DOCS_ONLY: ${{ needs.prepare.outputs.CHANGES_IN_DOCS_ONLY }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Setup JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
cache: 'maven' | |
- name: Cache target/artifacts | |
uses: actions/cache@v3 | |
with: | |
path: target/artifacts | |
key: ${{ runner.os }}-target/artifacts-${{ github.run_number }} | |
- name: Set CHANGELOG.md version | |
run: | | |
sed -i "s~## \[Unreleased\]~## \[${VERSION}\]~g" ./CHANGELOG.md | |
- name: Set plugin version | |
run: | | |
sed -i "s~\${betonquest\.version}~${VERSION}~g" ./src/main/resources/plugin.yml | |
- name: Set pom.xml BetonQuest version | |
if: "env.VERSION_TYPE == 'development'" | |
run: | | |
mvn versions:set-property -DgenerateBackupPoms=false -Dproperty=betonquest.version -DnewVersion="$VERSION" | |
- name: Activate lf line ending check in editorconfig | |
run: | | |
sed -i "s~#end_of_line = ~end_of_line = ~g" ./.editorconfig | |
- name: Build with Maven. Phase 'verify' | |
run: | | |
if [ $VERSION_TYPE == 'release' ]; then CHANGELIST=-Dchangelist=; fi | |
mvn $CHANGELIST -P Test-All -B verify | |
git diff > target/artifacts/changes.patch | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: BetonQuest-Artifacts | |
path: | | |
target/artifacts/BetonQuest.jar | |
target/artifacts/betonquest-*-*.jar | |
build-docs: | |
name: Build Docs | |
needs: [ prepare ] | |
runs-on: ubuntu-latest | |
env: | |
VERSION: ${{ needs.prepare.outputs.VERSION }} | |
VERSION_TYPE: ${{ needs.prepare.outputs.VERSION_TYPE }} | |
PREVIOUS_VERSION_TAG: ${{ needs.prepare.outputs.PREVIOUS_VERSION_TAG }} | |
CHANGES_IN_DOCS_ONLY: ${{ needs.prepare.outputs.CHANGES_IN_DOCS_ONLY }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Create LFS file list | |
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id | |
- name: Restore LFS cache | |
uses: actions/cache@v3 | |
id: lfs-cache | |
with: | |
path: .git/lfs | |
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1 | |
- name: Git LFS Pull | |
run: git lfs pull | |
- name: Select mkDocs requirements | |
run: | | |
[ -z $MKDOCS_MATERIAL_INSIDERS ] && TXT=docs-requirements.txt || TXT=docs-requirements-insiders.txt | |
echo "TXT=$TXT" >> $GITHUB_ENV | |
env: | |
MKDOCS_MATERIAL_INSIDERS: ${{ secrets.MKDOCS_MATERIAL_INSIDERS }} | |
- name: Setup Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
architecture: 'x64' | |
cache: 'pip' | |
cache-dependency-path: '**/config/${{ env.TXT }}' | |
- name: Cache target/docs | |
uses: actions/cache@v3 | |
with: | |
path: target/docs | |
key: ${{ runner.os }}-target/docs-${{ github.run_number }} | |
- name: Cache target/docs/.cache/plugins/optimize | |
uses: actions/cache@v3 | |
with: | |
path: target/docs/.cache/plugins/optimize | |
key: ${{ runner.os }}-hardcoded-media-cache | |
- name: Install pngquant, a CI only dependency for mkdocs-material image optimization | |
uses: awalsh128/[email protected] | |
with: | |
packages: pngquant | |
- name: Install dependencies | |
run: | | |
python3 -m pip install --upgrade pip | |
pip install -r ./config/$TXT | |
env: | |
MKDOCS_MATERIAL_INSIDERS: ${{ secrets.MKDOCS_MATERIAL_INSIDERS }} | |
- name: Set CHANGELOG.md version | |
run: | | |
sed -i "s~## \[Unreleased\]~## \[${VERSION}\]~g" ./CHANGELOG.md | |
DATE="$(date +%Y-%m-%d)" | |
sed -i "s~\${maven\.build\.timestamp}~$DATE~g" ./CHANGELOG.md | |
echo "$(cat ./CHANGELOG.md)" >> './docs/Documentation/CHANGELOG.md' | |
- name: Set user feedback form version in mkdocs.yml | |
run: | | |
sed -i "s~%VERSION%~${VERSION}~g" ./mkdocs.yml | |
- name: Set secret in downloads.js script | |
run: | | |
sed -i "s~\${REPOSITORY_URL}~$REPOSITORY_URL~g" ./docs/_webCode/js/downloads.js | |
env: | |
REPOSITORY_URL: ${{ vars.REPOSITORY_URL }} | |
- name: Build with mkdocs | |
run: | | |
if [ "$TXT" = "docs-requirements-insiders.txt" ] | |
then | |
mkdocs build --config-file mkdocs.insiders.yml | |
else | |
mkdocs build --config-file mkdocs.yml | |
fi | |
git diff > target/docs/changes.patch | |
env: | |
ANALYTICS_PROPERTY: ${{ vars.ANALYTICS_PROPERTY }} | |
- name: Upload Docs | |
uses: actions/upload-artifact@v3 | |
with: | |
name: BetonQuest-Docs | |
path: | | |
target/docs/ | |
!target/docs/changes.patch | |
deploy-artifacts: | |
name: Deploy Artifacts | |
if: "needs.prepare.outputs.VERSION_TYPE == 'release' || needs.prepare.outputs.VERSION_TYPE == 'development' && needs.prepare.outputs.CHANGES_IN_DOCS_ONLY == 'false'" | |
needs: [ prepare, build-artifacts, build-docs ] | |
runs-on: ubuntu-latest | |
env: | |
VERSION: ${{ needs.prepare.outputs.VERSION }} | |
VERSION_TYPE: ${{ needs.prepare.outputs.VERSION_TYPE }} | |
PREVIOUS_VERSION_TAG: ${{ needs.prepare.outputs.PREVIOUS_VERSION_TAG }} | |
CHANGES_IN_DOCS_ONLY: ${{ needs.prepare.outputs.CHANGES_IN_DOCS_ONLY }} | |
outputs: | |
UPLOAD_PATH: ${{ steps.save_upload_path.outputs.upload_path }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Setup JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
cache: 'maven' | |
- name: Cache target/artifacts | |
uses: actions/cache@v3 | |
with: | |
path: target/artifacts | |
key: ${{ runner.os }}-target/artifacts-${{ github.run_number }} | |
- name: Load patch file | |
run: | | |
git apply target/artifacts/changes.patch | |
rm target/artifacts/changes.patch | |
- name: Set mirror for all repositories in settings.xml | |
uses: whelk-io/maven-settings-xml-action@v21 | |
with: | |
servers: | | |
[ | |
{ | |
"id": "betonquest", | |
"username": "${env.REPOSITORY_USER}", | |
"password": "${env.REPOSITORY_PASS}", | |
"configuration": { | |
"httpConfiguration": { | |
"all": { | |
"usePreemptive": "true" | |
} | |
} | |
} | |
} | |
] | |
- name: Publish to Maven Repository | |
run: | | |
if [ $VERSION_TYPE == 'release' ]; then CHANGELIST=-Dchangelist=; fi | |
mvn $CHANGELIST -P Skip-Verification,Test-None -B deploy | tee maven-deploy.log | |
env: | |
REPOSITORY_URL: ${{ vars.REPOSITORY_URL }} | |
REPOSITORY_USER: ${{ secrets.REPOSITORY_USER }} | |
REPOSITORY_PASS: ${{ secrets.REPOSITORY_PASS }} | |
- name: Get upload URL from deploy log | |
id: save_upload_path | |
run: | | |
UPLOAD_PATH="$(grep -oP "(?<=Uploading to betonquest: $REPOSITORY_URL).*-shaded.jar" maven-deploy.log)" | |
echo "upload_path=$UPLOAD_PATH" >> $GITHUB_OUTPUT | |
env: | |
REPOSITORY_URL: ${{ vars.REPOSITORY_URL }} | |
deploy-docs: | |
name: Deploy Docs | |
concurrency: gh-pages-deploy | |
if: "needs.prepare.outputs.VERSION_TYPE == 'release' || needs.prepare.outputs.VERSION_TYPE == 'development'" | |
needs: [ prepare, build-artifacts, build-docs ] | |
runs-on: ubuntu-latest | |
env: | |
VERSION: ${{ needs.prepare.outputs.VERSION }} | |
VERSION_TYPE: ${{ needs.prepare.outputs.VERSION_TYPE }} | |
PREVIOUS_VERSION_TAG: ${{ needs.prepare.outputs.PREVIOUS_VERSION_TAG }} | |
CHANGES_IN_DOCS_ONLY: ${{ needs.prepare.outputs.CHANGES_IN_DOCS_ONLY }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Create LFS file list | |
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id | |
- name: Restore LFS cache | |
uses: actions/cache@v3 | |
id: lfs-cache | |
with: | |
path: .git/lfs | |
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1 | |
- name: Git LFS Pull | |
run: git lfs pull | |
- name: Select mkDocs requirements | |
run: | | |
[ -z $MKDOCS_MATERIAL_INSIDERS ] && TXT=docs-requirements.txt || TXT=docs-requirements-insiders.txt | |
echo "TXT=$TXT" >> $GITHUB_ENV | |
env: | |
MKDOCS_MATERIAL_INSIDERS: ${{ secrets.MKDOCS_MATERIAL_INSIDERS }} | |
- name: Setup Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
architecture: 'x64' | |
cache: 'pip' | |
cache-dependency-path: '**/config/${{ env.TXT }}' | |
- name: Cache target/docs | |
uses: actions/cache@v3 | |
with: | |
path: target/docs | |
key: ${{ runner.os }}-target/docs-${{ github.run_number }} | |
- name: Cache target/docs/.cache/plugins/optimize | |
uses: actions/cache@v3 | |
with: | |
path: target/docs/.cache/plugins/optimize | |
key: ${{ runner.os }}-hardcoded-media-cache | |
- name: Install pngquant, a CI only dependency for mkdocs-material image optimization | |
uses: awalsh128/[email protected] | |
with: | |
packages: pngquant | |
- name: Install dependencies | |
run: | | |
python3 -m pip install --upgrade pip | |
pip install -r ./config/$TXT | |
env: | |
MKDOCS_MATERIAL_INSIDERS: ${{ secrets.MKDOCS_MATERIAL_INSIDERS }} | |
- name: Load patch file | |
run: | | |
git apply target/docs/changes.patch | |
rm target/docs/changes.patch | |
- name: Deploy to Github Pages | |
if: "env.VERSION_TYPE == 'release' || env.VERSION_TYPE == 'development'" | |
run: | | |
git config --global user.name "BetonQuest-Bot" | |
git config --global user.email "[email protected]" | |
IFS='.' read -r major minor _ <<< "$VERSION" | |
TWO_DIGIT_VERSION="$major.$minor" | |
FLAGS=(--push --update-aliases) | |
VERSION=() | |
if [ "$TXT" = "docs-requirements-insiders.txt" ]; then FLAGS+=(--config-file mkdocs.insiders.yml); fi | |
if [ "$VERSION_TYPE" = release ]; then | |
VERSION+=("$TWO_DIGIT_VERSION" "$TWO_DIGIT_VERSION-DEV") | |
if [ ${{ github.ref }} == 'refs/heads/main' ] || { mike list --json "$TWO_DIGIT_VERSION" | grep -q '"aliases" *: *\[[^]]*"RELEASE"'; }; then | |
VERSION+=(RELEASE) | |
fi | |
elif [ "$VERSION_TYPE" = development ]; then | |
VERSION+=("$TWO_DIGIT_VERSION-DEV") | |
if ! { mike list --json | grep -q "\"version\" *: *\"$TWO_DIGIT_VERSION\""; }; then | |
VERSION+=("$TWO_DIGIT_VERSION") | |
fi | |
fi | |
if [ ${{ github.ref }} == 'refs/heads/main' ]; then VERSION+=(DEV); fi | |
if [ "$VERSION_TYPE" = release ]; then | |
mike delete "$TWO_DIGIT_VERSION-DEV" | |
fi | |
mike deploy "${FLAGS[@]}" "${VERSION[@]}" | |
create-release: | |
name: Create GitHub Release | |
if: "needs.prepare.outputs.VERSION_TYPE == 'release' && needs.deploy-artifacts.result == 'success' && needs.deploy-docs.result == 'success'" | |
needs: [ prepare, deploy-artifacts, deploy-docs ] | |
runs-on: ubuntu-latest | |
env: | |
VERSION: ${{ needs.prepare.outputs.VERSION }} | |
VERSION_TYPE: ${{ needs.prepare.outputs.VERSION_TYPE }} | |
PREVIOUS_VERSION_TAG: ${{ needs.prepare.outputs.PREVIOUS_VERSION_TAG }} | |
CHANGES_IN_DOCS_ONLY: ${{ needs.prepare.outputs.CHANGES_IN_DOCS_ONLY }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Cache target/artifacts | |
uses: actions/cache@v3 | |
with: | |
path: target/artifacts | |
key: ${{ runner.os }}-target/artifacts-${{ github.run_number }} | |
- name: Cache target/docs | |
uses: actions/cache@v3 | |
with: | |
path: target/docs | |
key: ${{ runner.os }}-target/docs-${{ github.run_number }} | |
- name: Zip Docs | |
run: | | |
zip -r target/docs/Docs.zip target/docs/ | |
- name: Set CHANGELOG.md version | |
run: | | |
sed -i "s~## \[Unreleased\]~## \[${VERSION}\]~g" ./CHANGELOG.md | |
DATE="$(date +%Y-%m-%d)" | |
sed -i "s~\${maven\.build\.timestamp}~$DATE~g" ./CHANGELOG.md | |
- name: Create release | |
uses: docker://antonyurchenko/git-release:latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DRAFT_RELEASE: false | |
PRE_RELEASE: false | |
CHANGELOG_FILE: CHANGELOG.md | |
RELEASE_NAME: BetonQuest ${{ env.VERSION }} | |
with: | |
args: | | |
target/artifacts/BetonQuest.jar | |
target/docs/Docs.zip | |
- name: Delete obsolete git tag | |
run: | | |
git push origin :${PREVIOUS_VERSION_TAG} | |
discord-announcement: | |
name: Official Deployment | |
if: "always() && !cancelled() && ( needs.prepare.outputs.VERSION_TYPE == 'release' || needs.prepare.outputs.VERSION_TYPE == 'development' && ( needs.prepare.outputs.CHANGES_IN_DOCS_ONLY == 'false' || failure() ) )" | |
needs: [ prepare, deploy-artifacts, deploy-docs, create-release ] | |
runs-on: ubuntu-latest | |
env: | |
VERSION: ${{ needs.prepare.outputs.VERSION }} | |
VERSION_TYPE: ${{ needs.prepare.outputs.VERSION_TYPE }} | |
PREVIOUS_VERSION_TAG: ${{ needs.prepare.outputs.PREVIOUS_VERSION_TAG }} | |
CHANGES_IN_DOCS_ONLY: ${{ needs.prepare.outputs.CHANGES_IN_DOCS_ONLY }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Publish to Discord | |
if: "always() && !cancelled()" | |
run: | | |
bash .github/scripts/discord.sh | |
env: | |
JOB_STATUS: ${{ job.status }} | |
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} | |
DOCS_URL: ${{ vars.DOCS_URL }} | |
UPLOAD_PATH: ${{ needs.deploy-artifacts.outputs.UPLOAD_PATH }} |