-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/BusyCityGuy/finite-state-ma…
…chine-luau into temp/test-dump
- Loading branch information
Showing
21 changed files
with
661 additions
and
254 deletions.
There are no files selected for viewing
This file contains 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 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,223 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
get-version: | ||
name: Get version from release tag | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
tag-name: ${{ steps.output-version.outputs.tag_name }} | ||
version-with-dots: ${{ steps.output-version.outputs.version_with_dots }} | ||
version-with-dashes: ${{ steps.output-version.outputs.version_with_dashes }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Output version and tag name | ||
id: output-version | ||
run: | | ||
# Get the tag name (e.g., v0.1.0) | ||
tag_name="${{ github.event.release.tag_name }}" | ||
echo "tag_name=$tag_name" >> $GITHUB_OUTPUT | ||
echo "tag_name=$tag_name" | ||
# Strip the leading 'v' to get the version (e.g., 0.1.0) | ||
version_with_dots="${tag_name#v}" | ||
echo "version_with_dots=$version_with_dots" >> $GITHUB_OUTPUT | ||
echo "version_with_dots=$version_with_dots" | ||
# Replaces . with - for use in filenames (e.g., 0-1-0) | ||
version_with_dashes="${version_with_dots//./-}" | ||
echo "version_with_dashes=$version_with_dashes" >> $GITHUB_OUTPUT | ||
echo "version_with_dashes=$version_with_dashes" | ||
install-tools: | ||
name: Install tools and dependencies | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Install Rokit | ||
uses: CompeyDev/[email protected] | ||
|
||
- name: Setup Lune | ||
run: lune setup | ||
|
||
- name: Install dependencies with Wally | ||
run: wally install | ||
|
||
- name: Cache installed items | ||
uses: actions/[email protected] | ||
with: | ||
path: | | ||
~/.rokit | ||
~/.lune | ||
Packages | ||
DevPackages | ||
key: tools-${{ hashFiles('rokit.toml') }} | ||
|
||
preprocess-release: | ||
name: Preprocess release (update versions, copyright years) | ||
runs-on: ubuntu-latest | ||
needs: [install-tools, get-version] | ||
environment: Release Preprocessor | ||
permissions: | ||
contents: write | ||
outputs: | ||
commit-hash: ${{ steps.commit-and-push.outputs.commit_hash }} | ||
|
||
steps: | ||
- uses: actions/[email protected] | ||
id: release-preprocessor-bot-token | ||
with: | ||
app-id: ${{ vars.RELEASE_PREPROCESSOR_APP_ID }} | ||
private-key: ${{ secrets.RELEASE_PREPROCESSOR_PRIVATE_KEY }} | ||
|
||
- name: Checkout code | ||
uses: actions/[email protected] | ||
with: | ||
token: ${{ steps.release-preprocessor-bot-token.outputs.token }} | ||
|
||
- name: Restore installed items | ||
uses: actions/[email protected] | ||
with: | ||
path: | | ||
~/.rokit | ||
~/.lune | ||
Packages | ||
DevPackages | ||
key: tools-${{ hashFiles('rokit.toml') }} | ||
|
||
- name: Add rokit tools to PATH | ||
run: echo "$HOME/.rokit/bin" >> $GITHUB_PATH | ||
|
||
- name: Locally update version & copyright year in files | ||
run: lune run preprocessRelease ${{ needs.get-version.outputs.version-with-dots }} | ||
|
||
- name: Commit version & copyright year updates | ||
id: commit-and-push | ||
uses: stefanzweifel/[email protected] | ||
with: | ||
commit_message: "Preprocess release for version ${{ needs.get-version.outputs.version-with-dots }}" | ||
branch: main | ||
file_pattern: "README.md wally.toml src/StateQ/init.luau LICENSE.md" | ||
|
||
create-release-artifacts: | ||
name: Create release artifacts | ||
runs-on: ubuntu-latest | ||
needs: [install-tools, get-version, preprocess-release] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ needs.preprocess-release.outputs.commit-hash }} | ||
|
||
- name: Restore installed items | ||
uses: actions/[email protected] | ||
with: | ||
path: | | ||
~/.rokit | ||
~/.lune | ||
Packages | ||
DevPackages | ||
key: tools-${{ hashFiles('rokit.toml') }} | ||
|
||
- name: Add rokit tools to PATH | ||
run: echo "$HOME/.rokit/bin" >> $GITHUB_PATH | ||
|
||
- name: Build release artifacts | ||
run: lune run build ${{ needs.get-version.outputs.version-with-dashes }} | ||
|
||
- name: Cache artifacts | ||
uses: actions/[email protected] | ||
with: | ||
path: | | ||
build | ||
wally.toml | ||
key: artifacts-${{ needs.get-version.outputs.tag-name }} | ||
|
||
publish-wally-artifact: | ||
name: Publish release artifact to Wally | ||
runs-on: ubuntu-latest | ||
needs: | ||
[install-tools, get-version, preprocess-release, create-release-artifacts] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ needs.preprocess-release.outputs.commit-hash }} | ||
|
||
- name: Restore installed items | ||
uses: actions/[email protected] | ||
with: | ||
path: | | ||
~/.rokit | ||
~/.lune | ||
Packages | ||
DevPackages | ||
key: tools-${{ hashFiles('rokit.toml') }} | ||
|
||
- name: Restore build artifacts | ||
uses: actions/[email protected] | ||
with: | ||
path: | | ||
build | ||
wally.toml | ||
key: artifacts-${{ needs.get-version.outputs.tag-name }} | ||
|
||
- name: Add rokit tools to PATH | ||
run: echo "$HOME/.rokit/bin" >> $GITHUB_PATH | ||
|
||
- name: Log in to Wally | ||
run: wally login --token ${{ secrets.WALLY_ACCESS_TOKEN }} | ||
|
||
- name: Publish package to Wally | ||
run: wally publish | ||
|
||
upload-github-artifacts: | ||
name: Upload artifacts to the GitHub release | ||
runs-on: ubuntu-latest | ||
needs: [get-version, create-release-artifacts] | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Restore build artifacts | ||
uses: actions/[email protected] | ||
with: | ||
path: | | ||
build | ||
wally.toml | ||
key: artifacts-${{ needs.get-version.outputs.tag-name }} | ||
|
||
- name: Print files | ||
run: ls -R | ||
|
||
- name: Upload zip artifact to the GitHub release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: build/zip/StateQ-${{ needs.get-version.outputs.version-with-dashes}}.zip | ||
asset_name: StateQ-${{ needs.get-version.outputs.version-with-dashes}}.zip | ||
asset_content_type: application/zip | ||
|
||
- name: Upload rbxm artifact to the GitHub release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: build/rbxm/StateQ-${{ needs.get-version.outputs.version-with-dashes }}.rbxm | ||
asset_name: StateQ-${{ needs.get-version.outputs.version-with-dashes }}.rbxm | ||
asset_content_type: application/octet-stream |
This file contains 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 |
---|---|---|
|
@@ -8,4 +8,6 @@ globaltypes.d.luau | |
Packages | ||
DevPackages | ||
*sourcemap.json | ||
settings.json | ||
settings.json | ||
build | ||
.DS_Store |
This file contains 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 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 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,6 +1,6 @@ | ||
# Finite State Machine (FSM) in Luau | ||
# StateQ: A Finite State Machine (FSM) in Luau | ||
|
||
A feature rich and fully typed implementation of a Finite State Machine in [Luau](https://luau-lang.org/), developed for use in Roblox experiences. | ||
An intuitive fully-typed Finite State Machine in [Luau](https://luau-lang.org/) that supports async transitions by queueing events, developed for use in Roblox experiences. | ||
|
||
This project is licensed under the terms of the MIT license. See [LICENSE.md](https://github.com/busycityguy/finite-state-machine-luau/blob/main/LICENSE.md) for details. | ||
|
||
|
@@ -51,7 +51,7 @@ A simple state machine diagram for a light switch may look like this, where | |
- States are represented as rectangles, and squares indicate the State can be Final | ||
- Events are represented as capsules | ||
|
||
![Screen Shot 2023-12-14 at 18 04 33](https://github.com/BusyCityGuy/finite-state-machine-luau/assets/55513323/3d5b2118-91ea-4427-ac2d-688fb0094d1f) | ||
![ExampleUsage](https://github.com/BusyCityGuy/finite-state-machine-luau/assets/55513323/3d5b2118-91ea-4427-ac2d-688fb0094d1f) | ||
|
||
```luau | ||
local LightState = { | ||
|
@@ -64,7 +64,7 @@ local Event = { | |
SwitchOff = "SwitchOff", | ||
} | ||
local light = StateMachine.new(LightState.On, { | ||
local light = StateQ.new(LightState.On, { | ||
[Event.SwitchOn] = { | ||
canBeFinal = true, | ||
from = { | ||
|
@@ -107,22 +107,22 @@ light:handle(Event.SwitchOn) -- warns "Illegal event `SwitchOn` called during st | |
|
||
# Installation | ||
|
||
If your project is set up to build with Rojo, you can add this repository as a submodule of your project by running the following command: | ||
## Rojo users | ||
|
||
`git submodule add https://github.com/BusyCityGuy/finite-state-machine-luau path/to/your/dependencies` | ||
If your project is set up to build with Rojo, the preferred installation method is using [Wally](https://wally.run/). Add this to your `wally.toml` file: | ||
> StateQ = "busycityguy/[email protected]" | ||
<details> | ||
<summary>These alternative installations are not implemented yet</summary> | ||
If you're not using Wally, you can add this repository as a submodule of your project by running the following command: | ||
|
||
In the future, an alternative installation method will be to download your desired release file from the [Releases](https://github.com/BusyCityGuy/latest) page. | ||
> git submodule add https://github.com/BusyCityGuy/finite-state-machine-luau path/to/your/dependencies | ||
Provided in the release will be a `.zip` file that can be extracted into your Rojo project, or you can download the `.rbxm` and drag it into Roblox Studio if you're not using Rojo. | ||
If you want to avoid submodules too, you can download the `.zip` file from the [latest release](https://github.com/BusyCityGuy/finite-state-machine-luau/releases/latest) page. | ||
|
||
Also in the future, this project will be published on [Wally](https://wally.run/), and could be installed into your project by adding `finite-state-machine = "busycityguy/[email protected]"` to your `wally.toml` file. | ||
## Non-Rojo users | ||
|
||
</details> | ||
If you aren't using Rojo, you can download the `.rbxm` file from the [latest release](https://github.com/BusyCityGuy/finite-state-machine-luau/releases/latest) page and drag it into Roblox Studio. | ||
|
||
# Help! | ||
# Feedback | ||
|
||
If you have other questions, bugs, feature requests, or feedback, please [open an issue](https://github.com/BusyCityGuy/finite-state-machine-luau/issues)! | ||
|
||
|
This file contains 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,9 +1,9 @@ | ||
{ | ||
"name": "StateMachine", | ||
"tree": { | ||
"$path": "src/StateMachine", | ||
"Dependencies": { | ||
"$path": "Packages" | ||
} | ||
} | ||
} | ||
"name": "StateQ", | ||
"tree": { | ||
"$path": "src/StateQ", | ||
"Dependencies": { | ||
"$path": "Packages" | ||
} | ||
} | ||
} |
Oops, something went wrong.