diff --git a/.github/dotnet-sdk.sh b/.github/dotnet-sdk.sh new file mode 100755 index 0000000..9e23a19 --- /dev/null +++ b/.github/dotnet-sdk.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +INSTALL_DIR="${HOME}/.wine/drive_c/Programs/dotnet" +mkdir -p ${INSTALL_DIR} +wget -O "${INSTALL_DIR}/dotnet-sdk.zip" "https://download.visualstudio.microsoft.com/download/pr/5b2c6cee-abe2-4734-a099-729a346205e7/b5776361ebee2e1eeed9be4aad944652/dotnet-sdk-6.0.428-win-x64.zip" +unzip "${INSTALL_DIR}/dotnet-sdk.zip" -d "${INSTALL_DIR}" \ No newline at end of file diff --git a/.github/go.mod b/.github/go.mod new file mode 100644 index 0000000..5ecbdcc --- /dev/null +++ b/.github/go.mod @@ -0,0 +1,5 @@ +module ra-code-notes + +go 1.23.0 + +require github.com/joshraphael/go-retroachievements v1.0.1 \ No newline at end of file diff --git a/.github/go.sum b/.github/go.sum new file mode 100644 index 0000000..d9c617f --- /dev/null +++ b/.github/go.sum @@ -0,0 +1,2 @@ +github.com/joshraphael/go-retroachievements v1.0.1 h1:fhH9y8VIBSDhAumvBVEqsCkJXQ+C/pgdq5aMHNJ2vBY= +github.com/joshraphael/go-retroachievements v1.0.1/go.mod h1:C+9vQbOqyRJmnFt8XIJ5gwRot+AZS/acnaESp45jtCc= \ No newline at end of file diff --git a/.github/main.go b/.github/main.go new file mode 100644 index 0000000..9b27438 --- /dev/null +++ b/.github/main.go @@ -0,0 +1,34 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + + "github.com/joshraphael/go-retroachievements" + "github.com/joshraphael/go-retroachievements/models" +) + +func main() { + client := retroachievements.New(retroachievements.ClientConfig{ + Host: retroachievements.RetroAchievementHost, + UserAgent: "go-retroachievements/v1.0.1", + }) + notes, err := client.GetCodeNotes(models.GetCodeNotesParameters{ + GameID: 18190, + }) + if err != nil { + os.Exit(1) + fmt.Println("error getting code notes") + return + } + + jsonNotes, err := json.Marshal(notes.CodeNotes) + if err != nil { + os.Exit(1) + fmt.Println("error converting code notes to json") + return + } + + fmt.Println(string(jsonNotes)) +} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..99cd3d7 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,112 @@ +name: Test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "**" ] + +permissions: + contents: write + pull-requests: write + +jobs: + compile: + name: compile + runs-on: ubuntu-latest + env: + GAME_ID: 18190 + RATOOLS_VERSION: v1.15.0 + RALIBRETRO_DIR: ~/Installs/RALibretro-x64 # same as Makefile + DOTNET_ROOT_X64: C:\\Programs\\dotnet + DOTNET_ROOT: C:\\Programs\\dotnet + WINEPATH: C:\\Programs\\dotnet + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: '^1.23.0' + + - name: Set ENV vars for github + run: echo "RATOOLS_DIR=~/Installs/RATools-${{env.RATOOLS_VERSION}}" >> $GITHUB_ENV # same as Makefile + + - name: Create folders + run: mkdir -p ${{env.RATOOLS_DIR}} && mkdir -p ${{env.RALIBRETRO_DIR}}/RACache/Data + + - name: Install wine + run: sudo apt-get update && sudo apt-get install -y wine + + - name: Set Winecfg + run: winecfg /v win10 + + - name: Get RATools CLI + run: wget -O ${{env.RATOOLS_DIR}}/RATools-${{env.RATOOLS_VERSION}}.zip "https://github.com/Jamiras/RATools/releases/download/${{env.RATOOLS_VERSION}}/RATools-${{env.RATOOLS_VERSION}}.zip" + + - name: Unpack RATools + run: unzip ${{env.RATOOLS_DIR}}/RATools-${{env.RATOOLS_VERSION}}.zip -d ${{env.RATOOLS_DIR}} + + - name: Get .NET SDK 6.0.428 + run: bash .github/dotnet-sdk.sh + + - name: Get Code Notes + run: make notes + + - name: Compile Code + run: make compile + + - name: Upload Code Notes + uses: actions/upload-artifact@v4 + with: + name: notes-json + path: ${{env.RALIBRETRO_DIR}}/RACache/Data/${{env.GAME_ID}}-Notes.json + + - name: Upload Achievement and Leaderboard Code + uses: actions/upload-artifact@v4 + with: + name: user-text + path: ${{env.RALIBRETRO_DIR}}/RACache/Data/${{env.GAME_ID}}-User.txt + + - name: Upload Rich Presence + uses: actions/upload-artifact@v4 + with: + name: rich-text + path: ${{env.RALIBRETRO_DIR}}/RACache/Data/${{env.GAME_ID}}-Rich.txt + + autocr: + name: AutoCR + needs: compile + runs-on: ubuntu-latest + env: + GAME_ID: 18190 + steps: + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + + - name: Use autocr-cli + uses: actions/checkout@v4 + with: + repository: joshraphael/autocr-cli + ref: v1.1.3 + + - name: Download Code Notes + uses: actions/download-artifact@v4 + with: + name: notes-json + + - name: Download Achievement and Leaderboard Code + uses: actions/download-artifact@v4 + with: + name: user-text + + - name: Download Rich Presence + uses: actions/download-artifact@v4 + with: + name: rich-text + + - name: Run AutoCR + run: ./index.js --notes ${{env.GAME_ID}}-Notes.json --user ${{env.GAME_ID}}-User.txt --rich ${{env.GAME_ID}}-Rich.txt --severity error --report \ No newline at end of file diff --git a/Makefile b/Makefile index 5b45d3d..57952f2 100644 --- a/Makefile +++ b/Makefile @@ -25,4 +25,7 @@ load: cp saves/chapter${chapter}/PARAM.SFO ${RALIBRETRO_DIR}/Saves/PSP/SAVEDATA/${EUROPE} cp saves/chapter${chapter}/PARAM.SFO ${RALIBRETRO_DIR}/Saves/PSP/SAVEDATA/${USA} cp saves/chapter${chapter}/SAVE.S ${RALIBRETRO_DIR}/Saves/PSP/SAVEDATA/${EUROPE} - cp saves/chapter${chapter}/SAVE.S ${RALIBRETRO_DIR}/Saves/PSP/SAVEDATA/${USA} \ No newline at end of file + cp saves/chapter${chapter}/SAVE.S ${RALIBRETRO_DIR}/Saves/PSP/SAVEDATA/${USA} + +notes: + cd .github/ && go get -t ./... && go run main.go > ${RALIBRETRO_DIR}/RACache/Data/${GAME_ID}-Notes.json \ No newline at end of file diff --git a/README.md b/README.md index 249110f..f1e2f80 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,5 @@ Retro Achievements set design document for the game [Where is my Heart?](https:/ |Title|Command|Parameters|Description| |-|-|-|-| |Compile|`make compile`|None|Compile RAScript into achievement logic| +|Code Notes|`make notes`|None|Use the API to download the games code notes| |Load Save|`make load chapter=`|`number` - chapter number|Load specified chapter save file into emulator (both Europe and USA versions)| \ No newline at end of file