-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (83 loc) · 4.34 KB
/
Copy pathrelease.yml
File metadata and controls
95 lines (83 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Release
# One tag, both front-ends. Push a vX.Y.Z tag and CI builds and publishes BOTH:
# the LichLoader DLL (this repo) and the WarcraftXL extension
# (brues-code/wxl-wrathclassicapi), each stamped to the tag. The wrapper repo is
# never touched by hand.
#
# Requires one secret: WRAPPER_REPO_TOKEN — a fine-grained PAT scoped to
# brues-code/wxl-wrathclassicapi with Contents: Read and write. It clones the
# wrapper, pushes the stamped wxl.json, the synced docs/API.md and the tag, and
# creates its release.
on:
push:
tags:
- 'v*'
permissions:
contents: write # GITHUB_TOKEN: this repo's release
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout WrathClassicAPI (at the tag)
uses: actions/checkout@v4
with:
submodules: recursive
path: WrathClassicAPI
- name: Checkout wxl-core (extension ABI)
uses: actions/checkout@v4
with:
repository: WarcraftXL/wxl-core
path: wxl-core
- name: Checkout wxl-wrathclassicapi (writable)
uses: actions/checkout@v4
with:
repository: brues-code/wxl-wrathclassicapi
ref: main
token: ${{ secrets.WRAPPER_REPO_TOKEN }}
path: wxl-wrathclassicapi
- name: Build WrathClassicAPI.dll (LichLoader front-end)
run: |
cmake -S WrathClassicAPI -B WrathClassicAPI/build -A Win32 "-DWRATHCLASSICAPI_TAG=${{ github.ref_name }}"
cmake --build WrathClassicAPI/build --config Release
- name: Build wxl-wrathclassicapi.dll (WXL extension front-end)
run: |
cmake -S wxl-wrathclassicapi -B wxl-wrathclassicapi/build -A Win32 "-DWRATHCLASSICAPI_TAG=${{ github.ref_name }}" "-DWRATHCLASSICAPI_DIR=${{ github.workspace }}/WrathClassicAPI" "-DWXL_CORE_DIR=${{ github.workspace }}/wxl-core"
cmake --build wxl-wrathclassicapi/build --config Release
- name: Stamp wxl.json, sync docs/API.md + tag the wrapper repo
shell: pwsh
working-directory: wxl-wrathclassicapi
run: |
$ver = "${{ github.ref_name }}".TrimStart('v')
$stamped = ([regex]'("version"\s*:\s*")[^"]*(")').Replace((Get-Content -Raw wxl.json), ('${1}' + $ver + '${2}'), 1)
[System.IO.File]::WriteAllText((Join-Path (Get-Location) 'wxl.json'), $stamped)
# The wrapper ships the per-function reference next to the DLL: docs/API.md
# is a copy of the core's, refreshed on every release so it matches the
# shipped build. The header marks it as synced so nobody edits the copy, and
# the core's repo-relative links (../README.md, ../src/...) are pointed at
# the core repository at this tag, since those files are not in the wrapper.
New-Item -ItemType Directory -Force docs | Out-Null
$core = "https://github.com/brues-code/WrathClassicAPI/blob/${{ github.ref_name }}/"
$header = "<!-- Synced from ${core}docs/API.md by the WrathClassicAPI release workflow. Edit it there, not here. -->`n`n"
$api = [System.IO.File]::ReadAllText("${{ github.workspace }}/WrathClassicAPI/docs/API.md") -replace '\]\(\.\./', ('](' + $core)
[System.IO.File]::WriteAllText((Join-Path (Get-Location) 'docs/API.md'), $header + $api, [System.Text.UTF8Encoding]::new($false))
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add wxl.json docs/API.md
if (git status --porcelain -- wxl.json docs/API.md) { git commit -m "release ${{ github.ref_name }}" }
git tag "${{ github.ref_name }}"
git push origin HEAD:main
git push origin "${{ github.ref_name }}"
- name: Release WrathClassicAPI.dll (this repo)
uses: softprops/action-gh-release@v2
with:
files: WrathClassicAPI/build/Release/WrathClassicAPI.dll
generate_release_notes: true
- name: Release wxl-wrathclassicapi.dll (extension repo)
shell: pwsh
env:
GH_TOKEN: ${{ secrets.WRAPPER_REPO_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" "wxl-wrathclassicapi/build/Release/wxl-wrathclassicapi.dll" --repo brues-code/wxl-wrathclassicapi --title "WrathClassicAPI ${{ github.ref_name }}" --generate-notes