From d8831d278fcbbb17289dfa364fced6aea2bf19b1 Mon Sep 17 00:00:00 2001 From: Alan Date: Sun, 11 Jan 2026 12:36:45 +0000 Subject: [PATCH 1/2] Add SMAPI workflow. --- .github/workflows/build-smapi.yml | 147 ++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 .github/workflows/build-smapi.yml diff --git a/.github/workflows/build-smapi.yml b/.github/workflows/build-smapi.yml new file mode 100644 index 000000000..b7e5759e8 --- /dev/null +++ b/.github/workflows/build-smapi.yml @@ -0,0 +1,147 @@ +name: Build SMAPI + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" # On any d.d.d tag push. + branches: + - develop + +jobs: + build_and_release: + runs-on: ubuntu-latest + permissions: + contents: write # For creating releases. + id-token: write # For creating attestations. + attestations: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get trigger type. + id: trigger-type # Possible values: tag, dev-branch. + run: | + # If we ever decide to add manual workflow runs, this will need to be reworked. + + if [[ "${{ github.ref_type }}" == "tag" ]]; then + echo "Building regular release." + echo "trigger_type=tag" >> $GITHUB_OUTPUT + elif [[ "${{ github.ref_name }}" == "develop" ]]; then + echo "Building in-development release." + echo "trigger_type=dev-branch" >> $GITHUB_OUTPUT + else + echo "Ran into an unexpected trigger type. Aborting." + echo "Debug info:" + echo "ref_type: ${{ github.ref_type }}" + echo "ref_name: ${{ github.ref_name }}" + + exit 1 + fi + + - name: Extract current SMAPI version. + id: smapi-version + run: | + version=$(pwsh -Command "([xml](Get-Content build/common.targets)).Project.PropertyGroup.Version") + pattern="^([0-9]+)\.([0-9]+)\.([0-9]+)$" + + if [[ "$version" =~ $pattern ]]; then + MAJOR="${BASH_REMATCH[1]}" + MINOR="${BASH_REMATCH[2]}" + PATCH="${BASH_REMATCH[3]}" + else + echo "Input semver did not match the strict x.y.z format. Aborting." + echo "Debug info:" + echo "Extracted version: $version" + + exit 1 + fi + + echo "smapi_version=$version" >> $GITHUB_OUTPUT + echo "smapi_major=$MAJOR" >> $GITHUB_OUTPUT + echo "smapi_minor=$MINOR" >> $GITHUB_OUTPUT + echo "smapi_patch=$PATCH" >> $GITHUB_OUTPUT + echo "VERSION=$MAJOR.$MINOR.$PATCH" >> $GITHUB_ENV + echo "Version: $MAJOR.$MINOR.$PATCH" + + - name: Verify SMAPI version matches tag. + if: steps.trigger-type.outputs.trigger_type == 'tag' + run: | + if [[ "$VERSION" != "${{ github.ref_name }}" ]]; then + echo "The pushed tag doesn't match the version we have in build/common.targets. Aborting." + echo "Debug info: " + echo "Tag: ${{ github.ref_name }}" + echo "In common.targets: $VERSION" + + exit 1 + fi + + - name: Update SMAPI's current version for dev builds. + id: version-parsing + if: steps.trigger-type.outputs.trigger_type == 'dev-branch' + run: | + updated_patch=$((${{steps.smapi-version.outputs.smapi_patch}} + 1)) + date=$(date +"%Y%m%d") + updated_version=${{steps.smapi-version.outputs.smapi_major}}.${{steps.smapi-version.outputs.smapi_minor}}.$updated_patch-alpha.$date + echo "VERSION=$updated_version" >> $GITHUB_ENV + + echo "This is a dev version. Building as version: $updated_version" + + build/unix/set-smapi-version.sh "$updated_version" + echo "Version updated using build/unix/set-smapi-version.sh." + + - name: Checkout reference assemblies + uses: actions/checkout@v4 + with: + repository: "StardewModders/mod-reference-assemblies" + path: "stardew-reference-assemblies" + fetch-depth: 1 + + - name: Symlink reference assemblies to a valid location. # Simply cloning the repo to this location doesn't seem to work. + run: | + ln -s "$(pwd)/stardew-reference-assemblies" "$HOME/StardewValley" + + - name: Build SMAPI. + run: | + echo "Building SMAPI $VERSION." + build/unix/prepare-install-package.sh "$VERSION" + + - name: Rename build zips. + run: | + mv "bin/SMAPI ${{ env.VERSION }} installer.zip" "bin/SMAPI-${{ env.VERSION }}-installer.zip" + mv "bin/SMAPI ${{ env.VERSION }} installer for developers.zip" "bin/SMAPI-${{ env.VERSION }}-installer-for-developers.zip" + + - name: Upload regular installer. + uses: actions/upload-artifact@v4 + with: + name: 'SMAPI ${{ env.VERSION }} installer' + path: 'bin/SMAPI-${{ env.VERSION }}-installer.zip' + if-no-files-found: 'error' + + - name: Upload installer for developers. + uses: actions/upload-artifact@v4 + with: + name: "SMAPI ${{ env.VERSION }} installer for developers" + path: "bin/SMAPI-${{ env.VERSION }}-installer-for-developers.zip" + if-no-files-found: 'error' + + - name: Create release and upload artifact + uses: ncipollo/release-action@v1 + if: steps.trigger-type.outputs.trigger_type == 'tag' + with: + artifacts: "bin/SMAPI-${{ env.VERSION }}*.zip" + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + name: "${{ env.VERSION }}" + body: | + Draft. + draft: true + + - name: Generate artifact attestations + uses: actions/attest-build-provenance@v2 + id: attestation-step + with: + subject-path: | + bin/SMAPI-${{ env.VERSION }}-installer.zip + bin/SMAPI-${{ env.VERSION }}-installer-for-developers.zip \ No newline at end of file From a92937d5439e37bbef37ca3e05f2813331479193 Mon Sep 17 00:00:00 2001 From: Alan Date: Sun, 11 Jan 2026 12:54:08 +0000 Subject: [PATCH 2/2] Missed a newline at the end of the file. --- .github/workflows/build-smapi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-smapi.yml b/.github/workflows/build-smapi.yml index b7e5759e8..916c8edf1 100644 --- a/.github/workflows/build-smapi.yml +++ b/.github/workflows/build-smapi.yml @@ -144,4 +144,4 @@ jobs: with: subject-path: | bin/SMAPI-${{ env.VERSION }}-installer.zip - bin/SMAPI-${{ env.VERSION }}-installer-for-developers.zip \ No newline at end of file + bin/SMAPI-${{ env.VERSION }}-installer-for-developers.zip