Skip to content

Add Stack Artifact Indication submod #188

Add Stack Artifact Indication submod

Add Stack Artifact Indication submod #188

Workflow file for this run

name: VCMI Mod CI
on:
push:
branches:
- 'vcmi-*'
pull_request:
workflow_dispatch:
jobs:
validate-startup:
name: Test VCMI Startup
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Add VCMI PPA Repository
run: sudo add-apt-repository ppa:vcmi/vcmi-latest
- name: Update Repository
run: sudo apt update
- name: Install VCMI
run: sudo apt install vcmi
- name: Install H3 Data Placeholder
run: |
data_url="https://github.com/vcmi-mods/vcmi-test-data/releases/download/v2.0/heroes3.7z"
wget "$data_url" -O heroes3.7z
mkdir -p ~/.local/share/vcmi/Mods
mkdir -p ~/.config/vcmi
7za x -o"$HOME/.local/share/vcmi/" heroes3.7z
- name: Install Mod (all but HotA)
if: ${{ !contains(github.repository, 'horn-of-the-abyss') }}
run: |
MOD_NAME=$(basename ${{ github.repository }})
ln -sf "$(pwd)" ~/.local/share/vcmi/Mods/${MOD_NAME}
echo '{ "activePreset" : "default", "presets" : { "default" : { "mods" : [ "vcmi", "core", "' ${MOD_NAME} '" ]}}}' >~/.config/vcmi/modSettings.json
- name: Install Mod (HotA only)
if: ${{ contains(github.repository, 'horn-of-the-abyss') }}
run: |
ln -sf "$(pwd)" ~/.local/share/vcmi/Mods/hota
echo '{ "activePreset" : "default", "presets" : { "default" : { "mods" : [ "vcmi", "core", "hota" ]}}}' >~/.config/vcmi/modSettings.json
- name: Run VCMI
run: |
vcmiserver --dummy-run 2> >(tee error.log)
if [ ! -s error.log ]; then
echo "Validation OK!"
exit 0
else
echo "Validation failed!"
exit 1
fi
validate-json:
name: Validate JSON
runs-on: ubuntu-latest
defaults:
run:
shell: bash
outputs:
valid: ${{ steps.validate.outcome == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Update repository
run: sudo apt update
- name: Install jstyleson
run: sudo apt install python3-jstyleson
- name: Validate JSON syntax
id: validate
run: python3 .github/validate_json.py
format-json:
name: Format JSON
needs: validate-json
if: ${{ needs.validate-json.result == 'success' && github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
npm install -g prettier
- name: Format JSON files with Prettier
run: |
prettier --write "**/*.json" \
--parser jsonc \
--use-tabs \
--tab-width 4 \
--trailing-comma none \
--print-width 1
- name: Postprocess colon spacing
run: python3 .github/postprocess_colons.py
- name: Commit changes if needed
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: "Auto-format JSON files"
add: '*.json'
package-artifact:
name: Create release
needs: [validate-json, format-json]
if: >-
${{
needs.validate-json.result == 'success' &&
github.event_name != 'pull_request' &&
github.repository_owner == 'vcmi-mods' &&
startsWith(github.ref_name, 'vcmi-')
}}
runs-on: ubuntu-latest
permissions:
contents: write
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
fetch-depth: 0
- name: Prepare content ZIPs
run: bash .github/create_content_zip.sh
- name: Package release archive
run: bash .github/create_release_package.sh
- name: Move tag to current commit
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git tag -f "${GITHUB_REF_NAME}" "${GITHUB_SHA}"
git push origin "${GITHUB_REF_NAME}" --force
- name: Strip vcmi- prefix for TAG
run: echo "RELEASE_TAG=${GITHUB_REF_NAME#vcmi-}" >> $GITHUB_ENV
- name: Upload Mod Release Package
uses: ncipollo/release-action@v1
with:
tag: ${{ env.RELEASE_TAG }} # 1.7, 1.8 etc.
name: ${{ github.ref_name }}
body: |
Automated build for branch `${{ github.ref_name }}`.
Commit: `${{ github.sha }}`
artifacts: dist/${{ github.event.repository.name }}-${{ github.ref_name }}.zip
allowUpdates: true
replacesArtifacts: true
makeLatest: false
commit: ${{ github.sha }}
# Upload mod.json after Release Package is uploaded to correctly notify end users
- name: Upload mod.json
uses: ncipollo/release-action@v1
with:
tag: ${{ env.RELEASE_TAG }} # 1.7, 1.8 etc.
name: ${{ github.ref_name }}
artifacts: mod.json
allowUpdates: true
replacesArtifacts: true
makeLatest: false
commit: ${{ github.sha }}