View Single Post
05/03/20, 07:03 AM   #6
Aenathel
 
Aenathel's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2020
Posts: 8
Sure. It's a bit rough, I have specified the necessary files manually, but I'll add some better filtering later.

The first script is bin/build.ps1, which copies files to a build/ directory and substitutes some variables:

Code:
Param(
    [Parameter()]
    [string] $AddOnVersion = "1",
    [Parameter()]
    [string] $Version = "0.0.0",
    [Parameter()]
    [string] $SavedVariables = "AenathelsKeybinds_SavedVariables"
)

$PSDefaultParameterValues['Out-File:Encoding'] = "utf8"

Remove-Item -Force -Recurse build -ErrorAction SilentlyContinue
New-Item -Type Directory -Path build > $null

Copy-Item AenathelsKeybinds.lua -Destination build/
Copy-Item AenathelsKeybinds.txt -Destination build/

Copy-Item CHANGELOG -Destination build/
Copy-Item DESCRIPTION -Destination build/
Copy-Item LICENSE -Destination build/

Copy-Item -Recurse -Path lang -Destination build/lang
Copy-Item -Recurse -Path xml -Destination build/xml

$manifest = Get-Content build/AenathelsKeybinds.txt | Out-String
$manifest = $manifest -replace "{{AddOnVersion}}", $AddOnVersion
$manifest = $manifest -replace "{{Version}}", $Version
$manifest = $manifest -replace "{{SavedVariables}}", $SavedVariables
$manifest | Set-Content build/AenathelsKeybinds.txt

$shared = Get-Content build/lang/shared.lua | Out-String
$shared = $shared -replace "{{Version}}", $Version
$shared | Set-Content build/lang/shared.lua
The second script is bin/deploy.ps1, which copies the build output to the AddOns folder:

Code:
Param(
    [Parameter()]
    [string] $AddOnsFolder = "$env:USERPROFILE\Documents\Elder Scrolls Online\live\AddOns"
)

. bin\build.ps1

$path = "$AddOnsFolder\AenathelsKeybinds"

Remove-Item -Force -Recurse $path -ErrorAction SilentlyContinue
New-Item -Force -Type Directory -Path $path > $null

Copy-Item -Force -Recurse -Path build/* -Destination $path
Finally, here's the raw watcher task--if you're using WebStorm or something like it, it should be possible to splice it into your existing .idea/watcherTasks.xml if you have it:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectTasksOptions">
    <TaskOptions isEnabled="true">
      <option name="arguments" value="&quot;&amp; $ProjectFileDir$\bin\deploy.ps1&quot;" />
      <option name="checkSyntaxErrors" value="true" />
      <option name="description" />
      <option name="exitCodeBehavior" value="ERROR" />
      <option name="fileExtension" value="*" />
      <option name="immediateSync" value="false" />
      <option name="name" value="Deploy to ESO AddOns" />
      <option name="output" value="" />
      <option name="outputFilters">
        <array />
      </option>
      <option name="outputFromStdout" value="false" />
      <option name="program" value="powershell.exe" />
      <option name="runOnExternalChanges" value="true" />
      <option name="scopeName" value="Project Files" />
      <option name="trackOnlyRoot" value="false" />
      <option name="workingDir" value="$ProjectFileDir$" />
      <envs />
    </TaskOptions>
  </component>
</project>
Here's what it looks like in WebStorm if you want to create it manually:



I'm planning to use this to publish new releases of my add-on through Azure Pipelines. (Massive overkill unless you already have an Azure DevOps setup, though, but I'll let you know when I get that far, as the approach should also be possible with GitHub Actions.)

If you have questions, let me know.
  Reply With Quote