-
Notifications
You must be signed in to change notification settings - Fork 3
Add Blacksmith Switch build and release CI #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| self-hosted-runner: | ||
| labels: | ||
| - blacksmith-2vcpu-ubuntu-2404 | ||
| - blacksmith-4vcpu-ubuntu-2404 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| name: Switch build and release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: switch-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| version: | ||
| name: Resolve next release version | ||
| runs-on: blacksmith-2vcpu-ubuntu-2404 | ||
| outputs: | ||
| version: ${{ steps.release.outputs.version }} | ||
| steps: | ||
| - name: Check out source | ||
| uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 | ||
|
|
||
| - name: Increment latest GitHub release | ||
| id: release | ||
| shell: bash | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| existing_tag="$( | ||
| gh api --paginate "repos/$GITHUB_REPOSITORY/releases?per_page=100" \ | ||
| --jq ".[] | select(.draft == false and .prerelease == false and .target_commitish == \"$GITHUB_SHA\") | .tag_name" \ | ||
| | head -n 1 | ||
| )" | ||
|
|
||
| if [[ "$existing_tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| version="${existing_tag#v}" | ||
| else | ||
| latest_tag="$(gh api "repos/$GITHUB_REPOSITORY/releases/latest" --jq .tag_name 2>/dev/null || printf 'v0.0.0')" | ||
| version="$(bash scripts/next-release-version.sh "$latest_tag")" | ||
| fi | ||
|
|
||
| echo "version=$version" >> "$GITHUB_OUTPUT" | ||
| echo "Building OpenNOW Switch v$version" | ||
|
|
||
| build: | ||
| name: Build Switch NRO | ||
| needs: version | ||
| runs-on: blacksmith-4vcpu-ubuntu-2404 | ||
|
capy-ai[bot] marked this conversation as resolved.
|
||
| container: devkitpro/devkita64@sha256:1fc388c3a0d34bd2045a6dadcb1020e069d5f876a187fd705de14b4440c00282 | ||
| outputs: | ||
| version: ${{ needs.version.outputs.version }} | ||
| steps: | ||
| - name: Check out source | ||
| uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 | ||
|
|
||
| - name: Install generator dependencies | ||
| run: | | ||
| apt-get update -qq | ||
| apt-get install -y --no-install-recommends python3-jinja2 python3-jsonschema | ||
|
|
||
| - name: Build NRO | ||
| env: | ||
| OPENNOW_BUILD_JOBS: "4" | ||
| OPENNOW_VERSION: ${{ needs.version.outputs.version }} | ||
| run: bash scripts/build-switch-msys2.sh | ||
|
|
||
| - name: Package release files | ||
| run: bash scripts/package-release.sh "${{ needs.version.outputs.version }}" | ||
|
|
||
| - name: Upload build artifact | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 | ||
| with: | ||
| name: SwitchNOW-${{ needs.version.outputs.version }}-${{ github.sha }} | ||
| path: | | ||
| dist/SwitchNOW-${{ needs.version.outputs.version }}.nro | ||
| dist/SwitchNOW-${{ needs.version.outputs.version }}.zip | ||
| if-no-files-found: error | ||
|
|
||
| release: | ||
| name: Publish GitHub release | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| needs: | ||
| - version | ||
| - build | ||
| runs-on: blacksmith-2vcpu-ubuntu-2404 | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Download build artifact | ||
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 | ||
| with: | ||
| name: SwitchNOW-${{ needs.build.outputs.version }}-${{ github.sha }} | ||
| path: dist | ||
|
|
||
| - name: Publish release with generated notes | ||
| uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 | ||
| with: | ||
| tag_name: v${{ needs.version.outputs.version }} | ||
| name: OpenNOW Switch v${{ needs.version.outputs.version }} | ||
| target_commitish: ${{ github.sha }} | ||
| generate_release_notes: true | ||
| fail_on_unmatched_files: true | ||
| files: | | ||
| dist/SwitchNOW-${{ needs.build.outputs.version }}.nro | ||
| dist/SwitchNOW-${{ needs.build.outputs.version }}.zip | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| #pragma once | ||
|
|
||
| #ifndef OPENNOW_APP_VERSION | ||
| #define OPENNOW_APP_VERSION "0.0.6" | ||
| #endif | ||
|
|
||
| namespace opennow | ||
| { | ||
|
|
||
| inline constexpr const char* kAppVersion = "0.0.6"; | ||
| inline constexpr const char* kAppVersion = OPENNOW_APP_VERSION; | ||
|
|
||
| } // namespace opennow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| if [[ $# -ne 1 ]]; then | ||
| printf 'Usage: %s <latest-release-tag>\n' "$0" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| latest_tag="$1" | ||
| if [[ ! "$latest_tag" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | ||
| printf 'Latest release tag is not a semantic version: %s\n' "$latest_tag" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| printf '%s.%s.%s\n' \ | ||
| "$((10#${BASH_REMATCH[1]}))" \ | ||
| "$((10#${BASH_REMATCH[2]}))" \ | ||
| "$((10#${BASH_REMATCH[3]} + 1))" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/^#define OPENNOW_APP_VERSION "\([^"]*\)"$/\1/p' app/src/app_version.hpp)" | ||
| cmake_version="$(sed -n 's/set(OPENNOW_VERSION "\([^"]*\)" CACHE.*/\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" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.