Skip to content

Commit

Permalink
- Update workflow files
Browse files Browse the repository at this point in the history
  • Loading branch information
ParticleG committed Aug 9, 2024
1 parent ce2efc4 commit e5fe421
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 21 deletions.
37 changes: 37 additions & 0 deletions .github/actions/build_dotnet/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Build .Net'
description: 'Build .Net project'
inputs:
output_folder:
description: 'Output folder'
required: false
default: "./build"
project_name:
description: 'Project name'
required: false
default: "ZZZTOJ.Botris"
self_contained:
description: 'Self contained'
required: false
default: "false"
single_file:
description: 'Publish single file'
required: false
default: "true"
runs:
using: "composite"
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install dependencies
shell: bash
run: dotnet restore
- name: Build and publish
shell: bash
run: |
mkdir ${{ inputs.output_folder }}
dotnet publish ${{ inputs.project_name }} -p:PublishSingleFile=${{ inputs.single_file }} --self-contained ${{ inputs.self_contained }} -o ${{ inputs.output_folder }}
- name: Remove pdb files
shell: bash
run: rm ${{ inputs.output_folder }}/*.pdb
31 changes: 31 additions & 0 deletions .github/actions/get_tetris_ai/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Get tetris_ai_runner'
description: 'Get tetris_ai_runner'
inputs:
os:
description: 'Running OS'
required: true
output_folder:
description: 'Output folder'
required: false
default: "./build"
runs:
using: "composite"
steps:
- name: Download tetris_ai_runner
env:
TETRIS_AI_INPUT_FILENAME: ${{ fromJSON('{"macos":"libtetris_ai.dylib","ubuntu":"libtetris_ai.so","windows":"tetris_ai.dll"}')[inputs.os] }}
uses: robinraju/[email protected]
with:
repository: TetrisAI/tetris_ai_runner
latest: true
preRelease: true
fileName: ${{ TETRIS_AI_INPUT_FILENAME }}
tarBall: false
zipBall: false
out-file-path: ${{ inputs.output_folder }}
- name: Rename tetris_ai_runner
env:
TETRIS_AI_INPUT_FILENAME: ${{ fromJSON('{"macos":"libtetris_ai.dylib","ubuntu":"libtetris_ai.so","windows":"tetris_ai.dll"}')[inputs.os] }}
TETRIS_AI_OUTPUT_FILENAME: ${{ fromJSON('{"macos":"zzz_botris.dylib","ubuntu":"zzz_botris.so","windows":"zzz_botris.dll"}')[inputs.os] }}
shell: bash
run: mv ${{ inputs.output_folder }}/${{ env.TETRIS_AI_INPUT_FILENAME }} ${{ inputs.output_folder }}/${{ env.TETRIS_AI_OUTPUT_FILENAME }}
74 changes: 74 additions & 0 deletions .github/workflows/connect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: ZZZBotris Connect To the Room

on:
workflow_dispatch:
inputs:
os:
description: "Runnning OS"
required: true
type: choice
options:
- macos
- ubuntu
- windows
default: "ubuntu"
token:
description: "BotrisBattle API token"
required: true
type: string
master_key:
description: "BotrisBattle Room Master Key"
required: true
type: string
next_count:
description: "Next count"
required: false
type: number
default: 6
level:
description: "Level"
required: false
type: number
default: 8
bpm:
description: "BPM"
required: false
type: number
default: 200

jobs:
connect:
runs-on: ${{ inputs.os }}-latest
env:
OUTPUT_FOLDER: ./build
PROJECT_NAME: ZZZTOJ.Botris
steps:
- uses: actions/checkout@v4
- name: Build Project
uses: ./.github/actions/build_dotnet
with:
output_folder: ${{ env.OUTPUT_FOLDER }}
project_name: ${{ env.PROJECT_NAME }}
- name: Get tetris_ai_runner
uses: ./.github/actions/get_tetris_ai
with:
os: ${{ inputs.os }}
output_folder: ${{ env.OUTPUT_FOLDER }}
- name: Generate bot config
shell: python3 {0}
run: |
import json
config = {
"NextCnt": ${{ inputs.next_count }},
"Level": ${{ inputs.level }},
"BPM": ${{ inputs.bpm }},
"Token": "${{ inputs.token }}",
"RoomKey": "${{ inputs.master_key }}"
}
json.dump(config, open("${{ env.OUTPUT_FOLDER }}/botconfig.json", "w"))
- name: Run bot
shell: bash
run: |
pushd ${{ env.OUTPUT_FOLDER }}
chmod +x ${{ env.PROJECT_NAME }}
./${{ env.PROJECT_NAME }}
28 changes: 7 additions & 21 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,16 @@ jobs:
TETRIS_AI_OUTPUT_FILENAME: ${{ fromJSON('{"macos":"zzz_botris.dylib","ubuntu":"zzz_botris.so","windows":"zzz_botris.dll"}')[matrix.os] }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Build Project
uses: ./.github/actions/build_dotnet
with:
dotnet-version: 8.0.x
- name: Install dependencies
run: dotnet restore
- name: Build and publish
run: |
mkdir ${{ env.OUTPUT_FOLDER }}
dotnet publish ${{ env.PROJECT_NAME }} -p:PublishSingleFile=true --self-contained false -o ${{ env.OUTPUT_FOLDER }}
- name: Remove pdb files
run: rm ${{ env.OUTPUT_FOLDER }}/*.pdb
output_folder: ${{ env.OUTPUT_FOLDER }}
project_name: ${{ env.PROJECT_NAME }}
- name: Get tetris_ai_runner
uses: robinraju/[email protected]
uses: ./.github/actions/get_tetris_ai
with:
repository: TetrisAI/tetris_ai_runner
latest: true
preRelease: true
fileName: ${{ env.TETRIS_AI_INPUT_FILENAME }}
tarBall: false
zipBall: false
out-file-path: ${{ env.OUTPUT_FOLDER }}
- name: Rename tetris_ai_runner
run: mv ${{ env.OUTPUT_FOLDER }}/${{ env.TETRIS_AI_INPUT_FILENAME }} ${{ env.OUTPUT_FOLDER }}/${{ env.TETRIS_AI_OUTPUT_FILENAME }}
os: ${{ matrix.os }}
output_folder: ${{ env.OUTPUT_FOLDER }}
- name: Upload dotnet test results
uses: actions/upload-artifact@v4
with:
Expand Down

0 comments on commit e5fe421

Please sign in to comment.