Skip to content

Commit

Permalink
added actions
Browse files Browse the repository at this point in the history
updated readme
fixed cli
  • Loading branch information
nshen committed Feb 5, 2020
1 parent 824105d commit 75d8c84
Show file tree
Hide file tree
Showing 84 changed files with 3,171 additions and 7,121 deletions.
20 changes: 20 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## 触发

每次`push`源代码到 `github` 时,会触发此流程

## 发布 starter

`github actions`会自动把 `/packages/starter` 目录 ,强`push``coding.net``gitee.com` 以下项目地址


- https://shed.coding.net/p/mini-shed-starter
- https://gitee.com/nshen/mini-shed-starter

使用`@shed/cli`命令行创建游戏时,实际上是从上边的地址clone下来的

```bash
shed create myGame
# 实际是从 https://e.coding.net/shed/mini-shed-starter.git 克隆
```
- [email protected]:nshen/mini-shed-starter.git
- [email protected]:shed/mini-shed-starter.git
14 changes: 14 additions & 0 deletions .github/actions/git-pub/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# based on http://github.com/wei/git-sync
FROM alpine

LABEL "com.github.actions.name"="Git Pub"
LABEL "com.github.actions.description"="🔃 push files to another git repository"
LABEL "com.github.actions.icon"="git-commit"
LABEL "com.github.actions.color"="blue"

RUN apk add --no-cache git openssh-client bash && \
echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config

ADD *.sh /

ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
26 changes: 26 additions & 0 deletions .github/actions/git-pub/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: git-pub
description: 'push files to another git repository'
branding:
icon: 'git-commit'
color: 'blue'
inputs:
ssh_private_key:
description: 'ssh private key of target git repository (secrets.gitee)'
required: true
target_repo:
description: 'target repository only support git proto'
required: true
target_branch:
description: 'target branch default master'
default: 'master'
source_folder:
description: 'source folder'
default: '.'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.ssh_private_key }}
- ${{ inputs.target_repo }}
- ${{ inputs.target_branch }}
- ${{ inputs.source_folder }}
38 changes: 38 additions & 0 deletions .github/actions/git-pub/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -e # 失败直接退出

INPUT_SSH_PRIVATE_KEY=$1
INPUT_TARGET_REPO=$2
INPUT_TARGET_BRANCH=$3
INPUT_SOURCE_FOLDER=$4

echo $INPUT_SSH_PRIVATE_KEY
echo $INPUT_TARGET_REPO
echo $INPUT_TARGET_BRANCH
echo $INPUT_SOURCE_FOLDER

if [[ -n "$INPUT_SSH_PRIVATE_KEY" ]]
then
mkdir -p /root/.ssh
echo "$INPUT_SSH_PRIVATE_KEY" > /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa
fi

mkdir -p ~/.ssh
cp /root/.ssh/* ~/.ssh/ 2> /dev/null || true

# ssh -T [email protected]

# sh -c "/git-pub.sh $*"

cd $GITHUB_WORKSPACE
cd $INPUT_SOURCE_FOLDER
git config --global user.email "[email protected]"
git config --global user.name "mini-shed"
git init
git remote add origin $INPUT_TARGET_REPO
git add .
git commit -am 'update'
git push origin $INPUT_TARGET_BRANCH -f

2 changes: 2 additions & 0 deletions .github/actions/git-pub/git-pub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#/bin/bash

29 changes: 29 additions & 0 deletions .github/workflows/pub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: pub
on: [push]
jobs:
gitee:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: pub
uses: ./.github/actions/git-pub
with:
ssh_private_key: '${{ secrets.shed }}'
target_repo: '[email protected]:nshen/mini-shed-starter.git'
source_folder: './packages/starter'
coding:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: pub
uses: ./.github/actions/git-pub
with:
ssh_private_key: '${{ secrets.shed }}'
target_repo: '[email protected]:shed/mini-shed-starter.git'
source_folder: './packages/starter'


177 changes: 175 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,175 @@
# mini-shed
迷你屋是一个开放,高效的小游戏框架



<p align="center"><img width="404" src="logo.png" alt="mini-shed 小游戏,小框架"></a></p>
<h3 align="center">一个开放,模块化,数据驱动,前端友好的小游戏框架(实验中)</h3>

---

<!-- # mini-shed -->



<!-- 迷你屋是一个开放,高效的小游戏框架 -->

<!-- ## Table of Contents
- [koa-jwt](#koa-jwt)
- [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
- [Install](#install)
- [Usage](#usage)
- [Retrieving the token](#retrieving-the-token)
- [Passing the secret](#passing-the-secret)
- [Checking if the token is revoked](#checking-if-the-token-is-revoked)
- [Example](#example)
- [Token Verification Exceptions](#token-verification-exceptions)
- [Related Modules](#related-modules)
- [Tests](#tests)
- [Author](#author)
- [Credits](#credits)
- [Contributors](#contributors)
- [License](#license) -->

<!-- ## 简介
`mini-shed` 是一枚高效,开放,易扩展的微信小游戏框架。 -->

> mini-shed 正在独立开发中,有建议,想帮忙,想聊天的,都欢迎来骚扰我。[[联系方式]](https://nshen.net/about)
## 特性

- 基于前端流行技术 `TypeScript` 编写,`babel` + `rollup` 构建,用组合 `npm` 包的方式开发小游戏。
-`VSCode` 中开发,`Chrome`浏览器中实时刷新调试,秒编译到各个小游戏平台。
- 可发布 Web版`H5小游戏``微信/QQ小游戏``头条/抖音小游戏``OPPO/VIVO小游戏` 等快游戏平台。
- 迷你的`Entity-Component-System` 架构,数据驱动,简单高效,独立`System`自由组合,易于扩展。
- 没用`Adapter库`,原生`WebGL`高速渲染,跨小游戏平台统一API,专注于`小且快`

# 快速开始

## 获取最新脚手架

```
git clone https://github.com/nshen/shed.git myGame
```

## 然后进入目录

```
cd myGame
```

## 安装 npm 依赖

```
npm install
```

## 简单一条命令即可编译出小游戏

```
npm run build
```

## 打开微信小游戏开发工具,导入游戏,选择 `dist` 子目录即可

![create mini game](./create_minigame.png)

# 迷你ECS架构

Entity Component System 是一个经典架构,`Shed.js` 根据JS语言特性实现了这个迷你版本

## Component

`Component` **只有数据,没有方法。** 例如一个 `transform` 组件只是一个含 `type` 属性的 `Object`

```typescript
{ type: 'transform', x: 0, y: 0, rotation: 180 }
```

## Entity


`Entity` 仅是一个有唯一 `id`**容器**,并且保存了一个 `Components` 表。

例如一个添加了 `transform 组件``render 组件``Entity` **可以想象成**

```typescript
let entity = {
id: 'Entity121',
components: {
'transform': { type: 'transform', x: 0, y: 0, rotation: 180 },
'render': { image:'sprite.png' }
}
}
```

## System

System **只有方法,不存数据。** 以下是一个自定义 `System` 的写法

```typescript

import { System } from "@shed/ecs";

export class EmptySystem extends System {

update() {

// write you code here
}
}

```

一个 `System` 通常关注和操作一组指定类型的 `Entities`

例如一个 `RenderSystem` 就应该只关注同时含有 `render``transform` 组件的 `Entities`

确实 [@shed/render-system](https://github.com/nshen/shed-render-system) 就是这么做的。

这里可以看到,一个 `System` 可以发布成一个独立的 `npm包`。开发游戏时可以像拼插乐高一样按需安装系统。

`npm install shed-xxx-system`

这就是这个系统容易扩展的地方,更多信息请查看 [@shed/ecs](https://github.com/nshen/shed-ecs) 主页




# 生态系统

## 每个游戏都需要的核心库

| Project | Status | Description |
|---------|--------|-------------|
| [@shed/ecs] | [![shed-ecs-status]][@shed/ecs-package] | 迷你 `Entity-Component-System` 系统 |
| [@shed/math] | [![shed-math-status]][@shed/math-package] | Matrix,Vector 等数学支持库 |
| [@shed/gl] | [![shed-gl-status]][@shed/gl-package] |`Webgl API` 更简洁的帮助库 |



[@shed/ecs]: https://github.com/nshen/shed-ecs
[@shed/math]: https://github.com/nshen/shed-math
[@shed/gl]: https://github.com/nshen/shed-gl

[shed-ecs-status]: https://img.shields.io/npm/v/@shed/ecs.svg
[shed-math-status]: https://img.shields.io/npm/v/@shed/math.svg
[shed-gl-status]: https://img.shields.io/npm/v/@shed/gl.svg

[@shed/ecs-package]: https://www.npmjs.com/package/@shed/ecs
[@shed/math-package]: https://www.npmjs.com/package/@shed/math
[@shed/gl-package]: https://www.npmjs.com/package/@shed/gl

## Systems

| Project | Status | Description |
|---------|--------|-------------|
| [@shed/render-system] | [![@shed/render-system-status]][@shed/render-system-package] | 高效的 2D Batching 渲染系统 |

[@shed/render-system]: https://github.com/nshen/shed-render-system
[@shed/render-system-status]: https://img.shields.io/npm/v/@shed/render-system.svg
[@shed/render-system-package]: https://www.npmjs.com/package/@shed/render-system

目前 `System` 生态比较贫乏,期待你的加入。
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 75d8c84

Please sign in to comment.