Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/switch-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Switch build and release

on:
push:
branches:
- main
tags:
- "v*"
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: switch-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref_type != 'tag' }}

jobs:
build:
name: Build Switch NRO
runs-on: blacksmith-4vcpu-ubuntu-2404
Comment thread
capy-ai[bot] marked this conversation as resolved.
container: devkitpro/devkita64:20260219
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Check out source
uses: actions/checkout@v4

- name: Install generator dependencies
run: |
apt-get update -qq
apt-get install -y --no-install-recommends python3-jinja2 python3-jsonschema

- name: Read and validate version
id: version
shell: bash
run: |
version="$(bash scripts/read-version.sh)"
if [[ "$GITHUB_REF_TYPE" == "tag" && "$GITHUB_REF_NAME" != "v$version" ]]; then
echo "Tag $GITHUB_REF_NAME does not match application version v$version." >&2
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Build NRO
env:
OPENNOW_BUILD_JOBS: "4"
run: bash scripts/build-switch-msys2.sh

- name: Package release files
run: bash scripts/package-release.sh "${{ steps.version.outputs.version }}"

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: SwitchNOW-${{ steps.version.outputs.version }}-${{ github.sha }}
path: |
dist/SwitchNOW-${{ steps.version.outputs.version }}.nro
dist/SwitchNOW-${{ steps.version.outputs.version }}.zip
if-no-files-found: error

release:
name: Publish GitHub release
if: github.ref_type == 'tag'
needs: build
runs-on: blacksmith-2vcpu-ubuntu-2404
permissions:
contents: write
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: SwitchNOW-${{ needs.build.outputs.version }}-${{ github.sha }}
path: dist

- name: Publish release with generated notes
uses: softprops/action-gh-release@v2
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
with:
name: OpenNOW Switch ${{ github.ref_name }}
generate_release_notes: true
fail_on_unmatched_files: true
files: |
dist/SwitchNOW-${{ needs.build.outputs.version }}.nro
dist/SwitchNOW-${{ needs.build.outputs.version }}.zip
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pkg_check_modules(JANSSON REQUIRED IMPORTED_TARGET jansson)
add_subdirectory(extern/borealis/library)
add_subdirectory(extern/libpeer)

target_include_directories(borealis PUBLIC ${DEVKITPRO}/portlibs/switch/include)
target_include_directories(borealis SYSTEM AFTER PUBLIC ${DEVKITPRO}/portlibs/switch/include)

file(GLOB_RECURSE APP_SOURCES CONFIGURE_DEPENDS
app/src/*.cpp
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ Create a release archive with:
.\scripts\package-release.ps1 -Version 0.0.6
```

On Linux or in CI, use the equivalent shell entry point:

```bash
bash scripts/package-release.sh 0.0.6
```

Pushing a version tag such as `v0.0.6` runs the Blacksmith release workflow,
publishes both files to GitHub Releases, and generates notes from the changes
since the previous release. The tag must match the version in
`app/src/app_version.hpp` and `CMakeLists.txt`.

## Repository layout

```text
Expand Down
1 change: 1 addition & 0 deletions scripts/build-switch-msys2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ detect_build_jobs() {
opennow_build_jobs="${OPENNOW_BUILD_JOBS:-$(detect_build_jobs)}"

cmake -B build/switch -G Ninja
cmake --build build/switch --target cjson mbedtls srtp2 usrsctp -j"$opennow_build_jobs"
cmake --build build/switch --target SwitchNOW.nro -j"$opennow_build_jobs"

printf '\nBuilt: %s\n' "$(pwd)/build/switch/SwitchNOW.nro"
63 changes: 63 additions & 0 deletions scripts/package-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ $# -lt 1 || $# -gt 2 ]]; then
printf 'Usage: %s <version> [build-directory]\n' "$0" >&2
exit 2
fi

version="$1"
build_directory="${2:-switch}"

if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
printf 'Invalid release version: %s\n' "$version" >&2
exit 2
fi

repo="$(cd "$(dirname "$0")/.." && pwd)"
nro="$repo/build/$build_directory/SwitchNOW.nro"

if [[ ! -f "$nro" ]]; then
printf 'Missing build artifact: %s. Run the Switch build first.\n' "$nro" >&2
exit 1
fi

dist="$repo/dist"
package_name="SwitchNOW-$version"
package_root="$dist/$package_name"
switch_directory="$package_root/switch/SwitchNOW"
versioned_nro="$dist/$package_name.nro"
zip_path="$dist/$package_name.zip"

rm -rf "$package_root"
rm -f "$versioned_nro" "$zip_path"
mkdir -p "$switch_directory"

cp "$nro" "$switch_directory/SwitchNOW.nro"
cp "$nro" "$versioned_nro"
cp "$repo/resources/icon/icon.jpg" "$switch_directory/icon.jpg"
cp "$repo/resources/icon/icon.png" "$switch_directory/icon.png"
cp "$repo/README.md" "$package_root/README.md"

cat > "$package_root/INSTALL.txt" <<EOF
SwitchNOW $version

Install:
1. Copy the switch folder from this package to the root of the SD card.
2. Launch Homebrew Menu with title override/application mode.
3. Start SwitchNOW from hbmenu.

Included:
- switch/SwitchNOW/SwitchNOW.nro
- switch/SwitchNOW/icon.jpg
- switch/SwitchNOW/icon.png
- README.md
EOF

(
cd "$package_root"
zip -qr "$zip_path" switch README.md INSTALL.txt
)

printf 'Packaged: %s\n' "$zip_path"
printf 'Versioned NRO: %s\n' "$versioned_nro"
20 changes: 20 additions & 0 deletions scripts/read-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")/.."

header_version="$(sed -n 's/.*kAppVersion = "\([^"]*\)".*/\1/p' app/src/app_version.hpp)"
cmake_version="$(sed -n 's/set(PROJECT_VERSION_STRING "\([^"]*\)")/\1/p' CMakeLists.txt)"

if [[ -z "$header_version" || -z "$cmake_version" ]]; then
printf 'Unable to read the application version from app_version.hpp and CMakeLists.txt.\n' >&2
exit 1
fi

if [[ "$header_version" != "$cmake_version" ]]; then
printf 'Version mismatch: app_version.hpp has %s, CMakeLists.txt has %s.\n' \
"$header_version" "$cmake_version" >&2
exit 1
fi

printf '%s\n' "$header_version"
Loading