Skip to content

Commit 7994fa1

Browse files
committed
Merge branch 'develop' into stable
2 parents ba65a39 + 6d8ce63 commit 7994fa1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3777
-2270
lines changed

.github/workflows/build-smapi.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Build SMAPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "[0-9]+.[0-9]+.[0-9]+" # stable version tag
7+
branches:
8+
- develop
9+
- build-test
10+
11+
jobs:
12+
build_and_release:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write # for creating releases
16+
id-token: write # for creating attestations
17+
attestations: write
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Get SMAPI assembly version
25+
id: smapi-version
26+
shell: pwsh
27+
run: |
28+
[xml]$xml = Get-Content build/common.targets
29+
[string]$version = $xml.Project.PropertyGroup.Version
30+
$version = $version.Trim()
31+
32+
$pattern = '^(\d+)\.(\d+)\.(\d+)$'
33+
if ($version -match $pattern) {
34+
$major = $Matches[1]
35+
$minor = $Matches[2]
36+
$patch = $Matches[3]
37+
}
38+
else {
39+
Write-Error "The version '$version' found in build/common.targets did not match the strict x.y.z format. Aborting."
40+
Write-Host 'Debug info:'
41+
Write-Host "Extracted version: $version"
42+
exit 1
43+
}
44+
45+
"smapi_version=$version" | Out-File $env:GITHUB_OUTPUT -Append
46+
"smapi_major=$major" | Out-File $env:GITHUB_OUTPUT -Append
47+
"smapi_minor=$minor" | Out-File $env:GITHUB_OUTPUT -Append
48+
"smapi_patch=$patch" | Out-File $env:GITHUB_OUTPUT -Append
49+
"VERSION=$major.$minor.$patch" | Out-File $env:GITHUB_ENV -Append
50+
51+
Write-Host "Version: $major.$minor.$patch"
52+
53+
- name: Verify SMAPI assembly version matches tag
54+
if: github.ref_type == 'tag'
55+
shell: pwsh
56+
run: |
57+
if ($env:VERSION -ne '${{github.ref_name}}') {
58+
Write-Error "The pushed tag '${{github.ref_name}}' doesn't match the version '$env:VERSION' found in build/common.targets. Aborting."
59+
Write-Host 'Debug info:'
60+
Write-Host 'Tag: ${{github.ref_name}}'
61+
Write-Host "In common.targets: $env:VERSION"
62+
exit 1
63+
}
64+
65+
- name: Update SMAPI assembly version
66+
if: github.ref_type != 'tag'
67+
shell: pwsh
68+
run: |
69+
$updatedPatch = [int]${{steps.smapi-version.outputs.smapi_patch}} + 1
70+
$timestamp = Get-Date -Format 'yyyyMMdd-HHmm'
71+
$updatedVersion = "${{steps.smapi-version.outputs.smapi_major}}.${{steps.smapi-version.outputs.smapi_minor}}.$updatedPatch-alpha.$timestamp"
72+
73+
"VERSION=$updatedVersion" | Out-File $env:GITHUB_ENV -Append
74+
75+
Write-Host "This is a dev version. Building as version: $updatedVersion"
76+
77+
./build/scripts/set-smapi-version.ps1 "$updatedVersion"
78+
Write-Host 'Version updated.'
79+
80+
- name: Checkout game reference assemblies
81+
run: |
82+
git clone --depth 1 https://github.com/StardewModders/mod-reference-assemblies.git "$HOME/StardewValley"
83+
84+
- name: Build SMAPI
85+
shell: pwsh
86+
run: |
87+
Write-Host "Building SMAPI $env:VERSION."
88+
./build/scripts/prepare-install-package.ps1 "$env:VERSION"
89+
90+
- name: Rename build zip
91+
run: mv "bin/SMAPI ${{env.VERSION}} installer.zip" "bin/SMAPI-${{env.VERSION}}-installer.zip"
92+
93+
- name: Upload installer
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: 'SMAPI ${{env.VERSION}} installer'
97+
path: 'bin/SMAPI-${{env.VERSION}}-installer.zip'
98+
if-no-files-found: 'error'
99+
100+
- name: Create GitHub release
101+
uses: ncipollo/release-action@v1
102+
if: github.ref_type == 'tag'
103+
with:
104+
artifacts: 'bin/SMAPI-${{env.VERSION}}*.zip'
105+
token: '${{secrets.GITHUB_TOKEN}}'
106+
tag: '${{github.ref_name}}'
107+
name: "${{env.VERSION}}"
108+
body: |
109+
Draft.
110+
draft: true
111+
112+
- name: Generate artifact attestations
113+
uses: actions/attest-build-provenance@v2
114+
with:
115+
subject-path: bin/SMAPI-${{env.VERSION}}-installer.zip

build/common.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ repo. It imports the other MSBuild files as needed.
77
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
88
<PropertyGroup>
99
<!--set general build properties -->
10-
<Version>4.4.0</Version>
10+
<Version>4.5.0</Version>
1111
<Product>SMAPI</Product>
1212
<LangVersion>latest</LangVersion>
1313
<AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
3+
##########
4+
## Read config
5+
##########
6+
# get SMAPI version
7+
version="$1"
8+
if [ $# -eq 0 ]; then
9+
echo "SMAPI release version (like '4.0.0'):"
10+
read version
11+
fi
12+
13+
# get Windows bin path
14+
windowsBinPath="$2"
15+
if [ $# -le 1 ]; then
16+
echo "Windows compiled bin path:"
17+
read windowsBinPath
18+
fi
19+
20+
# installer internal folders
21+
buildFolders=("linux" "macOS" "windows")
22+
23+
24+
##########
25+
## Finalize release package
26+
##########
27+
# move files to Linux filesystem
28+
folderName = "SMAPI $version installer"
29+
echo "Preparing $folderName.zip..."
30+
echo "-------------------------------------------------"
31+
echo "copying '$windowsBinPath/$folderName' to Linux filesystem..."
32+
cp -r "$windowsBinPath/$folderName" .
33+
34+
# fix permissions
35+
echo "fixing permissions..."
36+
find "$folderName" -type d -exec chmod 755 {} \;
37+
find "$folderName" -type f -exec chmod 644 {} \;
38+
find "$folderName" -name "*.sh" -exec chmod 755 {} \;
39+
find "$folderName" -name "*.command" -exec chmod 755 {} \;
40+
find "$folderName" -name "SMAPI.Installer" -exec chmod 755 {} \;
41+
find "$folderName" -name "StardewModdingAPI" -exec chmod 755 {} \;
42+
43+
# convert bundle folder into final 'install.dat' files
44+
for build in ${buildFolders[@]}; do
45+
echo "packaging $folderName/internal/$build/install.dat..."
46+
pushd "$folderName/internal/$build/bundle" > /dev/null
47+
zip "install.dat" * --recurse-paths --quiet
48+
mv install.dat ../
49+
popd > /dev/null
50+
51+
rm -rf "$folderName/internal/$build/bundle"
52+
done
53+
54+
# zip installer
55+
echo "packaging installer..."
56+
zip -9 "$folderName.zip" "$folderName" --recurse-paths --quiet
57+
58+
# move zip back to Windows bin path
59+
echo "moving release zip to $windowsBinPath/$folderName.zip..."
60+
mv "$folderName.zip" "$windowsBinPath"
61+
rm -rf "$folderName"
62+
63+
echo ""
64+
echo ""
65+
66+
echo "Done!"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function In-Place-Regex {
1+
function In-Place-Regex {
22
param (
33
[Parameter(Mandatory)][string]$Path,
44
[Parameter(Mandatory)][string]$Search,

0 commit comments

Comments
 (0)