-
Notifications
You must be signed in to change notification settings - Fork 34
112 lines (108 loc) · 4.39 KB
/
mod-builder.yml
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
on:
workflow_call:
inputs:
checkout-directory:
description: 'The directory the repository will reside in. Must not be `.`.'
required: true
type: string
build-script:
description: 'The script that builds the mod, runs within the checkout-directory.'
required: true
type: string
release-notes:
description: 'The release notes to use for tagged releases. Default is to only use generated notes.'
required: false
default: ''
type: string
modtek-download-url:
description: 'What ModTek to download and setup. Set to empty to disable.'
required: false
# not to be confused with https://github.com/BattletechModders/ModTek/releases/download/latest/ModTek.zip
# download/latest: latest tag with a release ; latest/download: release labeled latest
default: 'https://github.com/BattletechModders/ModTek/releases/latest/download/ModTek.zip'
type: string
latest-unstable-tag:
description: 'How to name the tag used for released based on the branches master or main. Set to empty to disable.'
required: false
default: 'latest'
type: string
secrets:
MANAGED_ARCHIVE_PW:
required: true
MANAGED_ARCHIVE_URL:
required: true
permissions:
contents: write
jobs:
mod-builder:
runs-on: ubuntu-latest
env:
# dirs
BATTLETECH_DIR: ${{ github.workspace }}/BATTLETECH
MODS_DIR: ${{ github.workspace }}/BATTLETECH/Mods # only there to make it clear its Mods not mods
MANAGED_DIR: ${{ github.workspace }}/BATTLETECH/BattleTech_Data/Managed
DIST_DIR: ${{ github.workspace }}/dist
steps:
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9
dotnet-quality: preview
- name: Prepare BATTLETECH/BattleTech_Data/Managed
env:
# TODO migrate these to a org-private git repo or org-private nuget package repo
MANAGED_ARCHIVE_URL: ${{ secrets.MANAGED_ARCHIVE_URL }}
MANAGED_ARCHIVE_PW: ${{ secrets.MANAGED_ARCHIVE_PW }}
run: |
curl -L -o Managed.7z "$MANAGED_ARCHIVE_URL"
mkdir -p "$MANAGED_DIR"
7z e -p"$MANAGED_ARCHIVE_PW" -o"$MANAGED_DIR" Managed.7z
rm Managed.7z
- name: Prepare BATTLETECH/Mods/ModTek
if: inputs.modtek-download-url != ''
continue-on-error: true # not all mods require ModTek, just more convenient to have it installed by default
env:
MODTEK_DOWNLOAD_URL: ${{ inputs.modtek-download-url }}
run: |
curl -L -o ModTek.zip "$MODTEK_DOWNLOAD_URL"
7z x -r -o"$BATTLETECH_DIR" ModTek.zip
rm ModTek.zip
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ inputs.checkout-directory }}
fetch-depth: 0 # tags for GitVersion
submodules: true
- name: Build Mod
working-directory: ${{ inputs.checkout-directory }}
run: ${{ inputs.build-script }}
- name: Release Latest
if: inputs.latest-unstable-tag != '' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' )
working-directory: ${{ inputs.checkout-directory }}
env:
LATEST_UNSTABLE_TAG: ${{ inputs.latest-unstable-tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release delete "$LATEST_UNSTABLE_TAG" --cleanup-tag || true
git tag -d "$LATEST_UNSTABLE_TAG" || true
git push --delete origin refs/tags/"$LATEST_UNSTABLE_TAG" || true
git tag "$LATEST_UNSTABLE_TAG"
git push --force origin refs/tags/"$LATEST_UNSTABLE_TAG"
gh release create "$LATEST_UNSTABLE_TAG" "$DIST_DIR"/* \
--generate-notes \
--title "Latest (unstable)" \
--verify-tag \
--prerelease
- name: Release Tag
if: startsWith(github.ref, 'refs/tags/v')
working-directory: ${{ inputs.checkout-directory }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NOTES: ${{ inputs.release-notes }}
run: |
gh release delete "$GITHUB_REF_NAME" || true
gh release create "$GITHUB_REF_NAME" "$DIST_DIR"/* \
--generate-notes \
${RELEASE_NOTES:+ --notes "$RELEASE_NOTES"} \
--verify-tag \
--latest